Skip to content

Commit

Permalink
Merge pull request #3 from genomic-medicine-sweden/chewbbaca-batch-input
Browse files Browse the repository at this point in the history
Chewbbaca batch input and file lock removal
  • Loading branch information
ryanjameskennedy authored Feb 9, 2023
2 parents 16f144f + 3d7a862 commit 823ea22
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion modules/bwa/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ process bwa_index {

script:
"""
bwa index ${reference}
bwa index ${reference} ${reference.baseName}/${reference}
"""
}

Expand Down
56 changes: 36 additions & 20 deletions modules/chewbbaca/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,76 @@ params = initParams(params)

process chewbbaca_allelecall {
label "process_medium"
tag "${sampleName}"
tag "${workflow.runName}"
publishDir "${params.publishDir}",
mode: params.publishDirMode,
overwrite: params.publishDirOverwrite

input:
tuple val(sampleName), path(input)
val sampleName
path batchInput
path schemaDir
path trainingFile

output:
tuple val(sampleName), path('output_dir/*/results_alleles.tsv')
val sampleName, emit: sampleName
path 'output_dir/results_alleles.tsv', emit: calls
//tuple val(sampleName), path("${missingLoci}"), emit: missing

script:
output = "${sampleName}.vcf"
missingLoci = "chewbbaca.missingloci"
trainingFile = trainingFile ? "--ptf ${trainingFile}" : ""
flockfile = file(params.localTempDir + '/chewbbaca.lock')
flocking = flockfile.exists() ? "flock -e $flockfile \\" : ""

"""
echo ${input} > batch_input.list
${flocking}
chewBBACA.py AlleleCall \\
-i batch_input.list \\
${params.args.join(' ')} \\
--cpu ${task.cpus} \\
--output-directory output_dir \\
${trainingFile} \\
--schema-directory ${schemaDir}
chewie AlleleCall \\
-i ${batchInput} \\
${params.args.join(' ')} \\
--cpu ${task.cpus} \\
--output-directory output_dir \\
${trainingFile} \\
--schema-directory ${schemaDir}
#bash parse_missing_loci.sh batch_input.list 'output_dir/*/results_alleles.tsv' ${missingLoci}
"""
}

process chewbbaca_create_batch_list {
label "process_low"
publishDir params.publishDir,
mode: params.publishDirMode,
overwrite: params.publishDirOverwrite

input:
path maskedAssembly

output:
path "batch_input.list"

script:
output = "batch_input.list"
"""
realpath $maskedAssembly > $output
"""
}

process chewbbaca_split_results {
label "process_low"
tag "${assembly.simpleName}"
tag "${sampleName}"
publishDir "${params.publishDir}",
mode: params.publishDirMode,
overwrite: params.publishDirOverwrite

input:
each sampleName
path input

output:
path("${output}")
tuple val(sampleName), path("${output}")

script:
id = "${input.simpleName}"
output = "${id}.chewbbaca"
output = "${sampleName}.chewbbaca"
"""
head -1 ${input} > ${output}
grep ${id} ${input} >> ${output}
grep ${sampleName} ${input} >> ${output}
"""
}

Expand Down
2 changes: 0 additions & 2 deletions modules/cmd/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ process save_analysis_metadata {
mode: params.publishDirMode,
overwrite: params.publishDirOverwrite

input:

output:
path(output)

Expand Down

0 comments on commit 823ea22

Please sign in to comment.