Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

started implementation of consensus approach #5

Merged
merged 7 commits into from
Mar 19, 2018
Merged
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
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