Skip to content

Commit

Permalink
Merge pull request #5 from tiagofilipe12/consensus
Browse files Browse the repository at this point in the history
started implementation of consensus approach
  • Loading branch information
tiagofilipe12 committed Mar 19, 2018
2 parents 38e446e + 5538edf commit 784cded
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 7 deletions.
54 changes: 49 additions & 5 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if (params.assembly) {

//todo implement checks on file type

if (params.mapping == true) {
if (params.mapping) {

//fetch indexes for mapping approach, available in Docker
// bowtie2Index = "/home/data/indexes/bowtie2idx/bowtie2.idx" // idx_file
Expand Down Expand Up @@ -94,7 +94,7 @@ process mashScreen {
val refSketch from refSketchChannel

output:
file "sortedMashScreenResults_${sample}.txt" into mashScreenResults
set sample, file("sortedMashScreenResults_${sample}.txt") into mashScreenResults

"""
mash screen -i ${params.identity} -v ${params.pValue} -p \
Expand All @@ -109,7 +109,10 @@ process mashOutputJson {
tag { "dumping json file from: " + mashtxt }

input:
file mashtxt from mashScreenResults
set sample, file(mashtxt) from mashScreenResults

output:
file "sortedMashScreenResults_${sample}.json" into mashScreenOutput

script:
template "mashscreen2json.py"
Expand All @@ -129,7 +132,7 @@ process runMashDist {
val refSketch from refSketchChannel2

output:
file "${fasta}_mashdist.txt" into mashDistResults
set fasta, file("${fasta}_mashdist.txt") into mashDistResults

"""
mash dist -p ${params.threads} -v ${params.pValue} \
Expand All @@ -143,7 +146,10 @@ process mashDistOutputJson {
tag { "dumping json file from: " + mashtxt }

input:
file mashtxt from mashDistResults
set fasta, file(mashtxt) from mashDistResults

output:
file "${fasta}_mashdist.json" into mashDistOutput

script:
template "mashdist2json.py"
Expand Down Expand Up @@ -215,6 +221,44 @@ process jsonDumpingMapping {
set sample, file(depthFile) from samtoolsResults
val lengthJson from lengthJsonChannel

output:
file "samtoolsDepthOutput_${sample}.txt.json" into mappingOutput

script:
template "mapping2json.py"
}


/**
* After generating all output jsons check again the params specified.
* If mapping and mash_screen are executed the consensus process will generate
* a consensus from these two json outputs. If assembly is also provided, the
* consensus will have the consensus between the three approaches. Otherwise,
* no consensus will be generated.
*/
if (params.mapping && params.mash_screen) {
if (params.assembly) {
test = mappingOutput.merge(mashDistOutput, mashScreenOutput)
}
else {
test = mappingOutput.merge(mashScreenOutput)
}
}
else {
test = Channel.empty()
}

/**
* A process that creates a consensus from all the outputted json files
*/
process fullConsensus {

tag { "Creating consensus json file" }

input:
file(list_of_files) from test

script:
template "pATLAS_consensus_json.py"

}
39 changes: 38 additions & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ process {
$mappingBowtie.container = 'tiagofilipe12/patlasflow_mapping:1.0.3'
$samtoolsView.container = 'tiagofilipe12/patlasflow_mapping:1.0.3'
$jsonDumpingMapping.container = 'tiagofilipe12/patlasflow_mapping:1.0.3'
$fullConsensus.container = 'tiagofilipe12/patlasflow_mapping:1.0.3'
}

// this should be passed with the -profile mash_screen
Expand All @@ -55,5 +56,41 @@ profiles {
singularity {
singularity.enabled = true
}
// TODO make a profile for slurm
slurm {
process.executor = "slurm"
shifter.enabled = true

$mashScreen.cpu = 4
$mashOutputJson.cpu = 1
$runMashDist.cpu = 4
$mashDistOutputJson.cpu = 1
$mappingBowtie.cpu = 4
$samtoolsView.cpu = 4
$jsonDumpingMapping.cpu = 1
$fullConsensus.cpu = 1

$mashScreen.memory = { 4.GB * task.attempt }
$mashScreen.errorStategy = { task.exitStatus == 140 ? "retry" : "terminate" }
$mashScreen.maxRetries = 3

$mashOutputJson.memory = "1GB"

$runMashDist.memory = { 4.GB * task.attempt }
$runMashDist.errorStategy = { task.exitStatus == 140 ? "retry" : "terminate" }
$runMashDist.maxRetries = 3

$mashDistOutputJson.memory = "1GB"

$mappingBowtie.memory = { 6.GB * task.attempt }
$mappingBowtie.errorStategy = { task.exitStatus == 140 ? "retry" : "terminate" }
$mappingBowtie.maxRetries = 3

$samtoolsView.memory = { 6.GB * task.attempt }
$samtoolsView.errorStategy = { task.exitStatus == 140 ? "retry" : "terminate" }
$samtoolsView.maxRetries = 3

$jsonDumpingMapping.memory = "1GB"

$fullConsensus.memory = "1GB"
}
}
2 changes: 1 addition & 1 deletion templates

0 comments on commit 784cded

Please sign in to comment.