Skip to content

Commit

Permalink
Merge pull request #2 from genepi/features/parallelize-variant-calling
Browse files Browse the repository at this point in the history
Features/parallelize variant calling
  • Loading branch information
seppinho authored Feb 21, 2024
2 parents 7ca114b + 380a843 commit 43abbb9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ RUN jbang export portable -O=PatternSearch.jar PatternSearch.java

COPY ./bin/MutservePerformance.java ./
RUN jbang export portable -O=MutservePerformance.jar MutservePerformance.java

WORKDIR "/opt"
ENV GENOMIC_UTILS_VERSION="v0.3.7"
RUN wget https://github.com/genepi/genomic-utils/releases/download/${GENOMIC_UTILS_VERSION}/genomic-utils.jar
16 changes: 8 additions & 8 deletions modules/local/call_variants_mutserve.nf
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
process CALL_VARIANTS_MUTSERVE {

publishDir "${params.outdir}/mutserve", mode: "copy"
//publishDir "${params.outdir}/mutserve", mode: "copy"

input:
path bamFiles
path bam_file
path ref_fasta
val(contig)

output:
path "${params.project}.txt", emit: variants_ch
path "${params.project}_raw.txt", emit: variants_raw_ch
path "${bam_file.simpleName}.txt", emit: variants_ch
path "${bam_file.simpleName}_raw.txt", emit: variants_raw_ch

script:
def avail_mem = 1024
if (!task.memory) {
log.info 'Available memory not known - defaulting to 1GB. Specify process memory requirements to change this.'
//log.info 'Available memory not known - defaulting to 1GB. Specify process memory requirements to change this.'
} else {
avail_mem = (task.memory.mega*0.8).intValue()
}

"""
java -Xmx${avail_mem}M -jar /opt/mutserve/mutserve.jar \
call \
--output ${params.project}.vcf \
--write-raw --reference ${ref_fasta} \
--output ${bam_file.simpleName}.txt \
--write-raw \
--reference ${ref_fasta} \
--level ${params.mutserve_detection_limit} \
--deletions \
--baseQ ${params.mutserve_baseQ} \
--mapQ ${params.mutserve_mapQ} \
--alignQ ${params.mutserve_alignQ} \
--contig-name ${contig} \
--threads ${task.cpus} \
--no-ansi \$PWD
"""
}
2 changes: 1 addition & 1 deletion modules/local/detect_type.nf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
process DETECT_TYPE {
publishDir "${params.outdir}/pattern", mode: "copy", pattern: '*pattern.txt'
//publishDir "${params.outdir}/pattern", mode: "copy", pattern: '*pattern.txt'
input:
path bamFile
path lpaRegion
Expand Down
27 changes: 27 additions & 0 deletions modules/local/merge_variants_mutserve.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
process MERGE_VARIANTS_MUTSERVE {

publishDir "${params.outdir}/variant_calling", mode: "copy"

input:
path variants
path variants_raw

output:
path "${params.project}.txt.gz"
path "${params.project}_raw.txt.gz"
"""
java -jar /opt/genomic-utils.jar csv-concat \
--separator '\t' \
--output-sep '\t' \
--gz \
--output ${params.project}.txt.gz \
${variants}
java -jar /opt/genomic-utils.jar csv-concat \
--separator '\t' \
--output-sep '\t' \
--gz \
--output ${params.project}_raw.txt.gz \
${variants_raw}
"""
}
6 changes: 4 additions & 2 deletions workflows/vntr-calling.nf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include { EXTRACT_READS } from '../modules/local/extract_reads' addPara
include { BAM_TO_FASTQ } from '../modules/local/bam_to_fastq' addParams(outdir: "$outdir")
include { REALIGN_FASTQ } from '../modules/local/realign_fastq' addParams(outdir: "$outdir")
include { CALL_VARIANTS_MUTSERVE} from '../modules/local/call_variants_mutserve' addParams(outdir: "$outdir")
include { MERGE_VARIANTS_MUTSERVE} from '../modules/local/merge_variants_mutserve' addParams(outdir: "$outdir")
include { CALCULATE_PERFORMANCE } from '../modules/local/calculate_performance' addParams(outdir: "$outdir")


Expand Down Expand Up @@ -54,8 +55,9 @@ workflow VNTR_CALLING {
EXTRACT_READS ( bam_bed_tuple )
BAM_TO_FASTQ ( EXTRACT_READS.out.extracted_bams_ch )
REALIGN_FASTQ ( BAM_TO_FASTQ.out.fastq_ch,ref_fasta,BUILD_BWA_INDEX.out.bwa_index_ch )
CALL_VARIANTS_MUTSERVE ( REALIGN_FASTQ.out.realigned_ch.collect(),ref_fasta, contig )

CALL_VARIANTS_MUTSERVE ( REALIGN_FASTQ.out.realigned_ch,ref_fasta, contig )
MERGE_VARIANTS_MUTSERVE ( CALL_VARIANTS_MUTSERVE.out.variants_ch.collect(), CALL_VARIANTS_MUTSERVE.out.variants_raw_ch.collect())

if(params.gold != null) {
gold_standard = file(params.gold, checkIfExists: true)
CALCULATE_PERFORMANCE ( CALL_VARIANTS_MUTSERVE.out.variants_ch,gold_standard )
Expand Down

0 comments on commit 43abbb9

Please sign in to comment.