Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ cloudgene.report.json
*.jar
.idea
scratch
imputationserver2.iml
36 changes: 26 additions & 10 deletions modules/local/compression/compression_encryption_vcf.nf
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,38 @@ process COMPRESSION_ENCRYPTION_VCF {
def panel_version = params.refpanel.id
def scale = params.encryption.thread_scale ?: 1
def threads = Math.max(1, Math.floor(task.cpus * scale) as int)
def first_vcf = getFirstFile(imputed_vcf_data)


"""
# concat info files
bcftools concat --threads ${threads} -n ${info_joined} -o ${info_name} -Oz

# concat dosage files and update header
bcftools concat --threads ${threads} -n ${imputed_joined} -o intermediate_${imputed_name} -Oz

# annotate files
if [[ "${params.encryption.annotate}" = true ]]
then
echo "##mis_pipeline=${workflow.manifest.version}" > add_header.txt
echo "##mis_phasing=${params.phasing.engine}" >> add_header.txt
echo "##mis_panel=${panel_version}" >> add_header.txt

bcftools annotate --threads ${threads} -h add_header.txt intermediate_${imputed_name} -o ${imputed_name} -Oz
#Extracting the original header to append the new one
bcftools view -h "${first_vcf}" > header_from_chunk.txt

# build final header: keep ## lines, add custom lines, then #CHROM last
awk -v pipeline="${workflow.manifest.version}" \
-v phasing="${params.phasing.engine}" \
-v panel="${panel_version}" '
/^#CHROM/ {
print "##mis_pipeline=" pipeline
print "##mis_phasing=" phasing
print "##mis_panel=" panel
}
{ print }
' header_from_chunk.txt > final_header.txt

# concat dosage files and update header
bcftools concat --threads ${threads} -n ${imputed_joined} -Oz | bcftools reheader -h final_header.txt -o ${imputed_name}

rm intermediate_${imputed_name}
else
bcftools concat --threads ${threads} -n ${imputed_joined} -o intermediate_${imputed_name} -Oz
mv intermediate_${imputed_name} ${imputed_name}
fi
fi

# write meta files
if [[ "${params.imputation.meta}" = true ]]
Expand Down Expand Up @@ -90,3 +101,8 @@ def compareFilenames(a, b) {
def processFileList(fileList) {
return fileList.sort { a, b -> compareFilenames(a, b) }.join(" ")
}

def getFirstFile(fileList) {
def sorted = fileList.sort { a, b -> compareFilenames(a, b) }
return sorted[0]
}
Loading