-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from TRON-Bioinformatics/support-bams
Support bams
- Loading branch information
Showing
21 changed files
with
1,788 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
process BAM2FASTQ { | ||
cpus params.cpus | ||
memory params.memory | ||
tag "${name}" | ||
publishDir "${params.output}/${name}", mode: "copy", pattern: "*.txt" | ||
module params.bowtie2_module | ||
|
||
conda (params.enable_conda ? "bioconda::samtools=1.18 bioconda::gatk4=4.2.5.0" : null) | ||
|
||
input: | ||
tuple val(name), val(bam) | ||
val(contigs) | ||
|
||
output: | ||
tuple val("${name}"), path("${name}.hla.1.fastq.gz"), path("${name}.hla.2.fastq.gz") | ||
|
||
script: | ||
""" | ||
samtools index $bam | ||
# gets reads in the provided regions | ||
# only non duplicated reads | ||
samtools view \ | ||
-b \ | ||
-L ${contigs} \ | ||
-F 1024 \ | ||
${bam} > ${name}.mhc.bam | ||
# Extract unmap reads | ||
samtools view -b -f 4 $bam > ${name}.unmap.bam | ||
#Merge bam files | ||
samtools merge -o ${name}.merge.bam ${name}.unmap.bam ${name}.mhc.bam | ||
#Create fastq | ||
gatk SamToFastq --VALIDATION_STRINGENCY SILENT -I ${name}.merge.bam -F ${name}.hlatmp.1.fastq -F2 ${name}.hlatmp.2.fastq | ||
#Change fastq ID | ||
cat ${name}.hlatmp.1.fastq |awk '{if(NR%4 == 1){O=\$0;gsub("/1"," 1",O);print O}else{print \$0}}' | gzip > ${name}.hla.1.fastq.gz | ||
cat ${name}.hlatmp.2.fastq |awk '{if(NR%4 == 1){O=\$0;gsub("/2"," 2",O);print O}else{print \$0}}' | gzip > ${name}.hla.2.fastq.gz | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
process HLAHD { | ||
cpus params.cpus | ||
memory params.memory | ||
tag "${name}" | ||
publishDir "${params.output}/${name}", mode: "copy", pattern: "*.txt" | ||
module params.bowtie2_module | ||
|
||
input: | ||
tuple val(name), val(fastq1), val(fastq2) | ||
|
||
output: | ||
tuple val("${name}"), path("*final*") | ||
|
||
script: | ||
""" | ||
mkdir temp | ||
# HLA-HD wants its own binaries and bowtie2 in path | ||
export PATH=${params.hlahd_folder}/bin/:${params.bowtie2_folder}:\$PATH | ||
export LD_LIBRARY_PATH=${params.ld_library_path} | ||
zcat ${fastq1} > input_fastq1.fastq | ||
zcat ${fastq2} > input_fastq2.fastq | ||
# HLA HD does not accept gzipped fastq files, unzip them first | ||
hlahd.sh \ | ||
-m ${params.read_length} \ | ||
-t ${task.cpus} \ | ||
-f ${params.hlahd_folder}/freq_data/ \ | ||
input_fastq1.fastq \ | ||
input_fastq2.fastq \ | ||
${params.hlahd_folder}/HLA_gene.split.txt \ | ||
${params.hlahd_folder}/dictionary/ \ | ||
${name} \ | ||
temp | ||
# moves the final result to base folder | ||
mv temp/${name}/result/* . | ||
# deletes temp folder | ||
rm -rf temp | ||
rm -f input_fastq1.fastq | ||
rm -f input_fastq2.fastq | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
chr6 28477797 33448354 | ||
chr6_apd_hap1 1 4622290 | ||
chr6_cox_hap2 1 4795371 | ||
chr6_dbb_hap3 1 4610396 | ||
chr6_mann_hap4 1 4683263 | ||
chr6_mcf_hap5 1 4833398 | ||
chr6_qbl_hap6 1 4611984 | ||
chr6_ssto_hap7 1 4928567 |
Oops, something went wrong.