Skip to content

Commit

Permalink
refactor: spades for ica CDCgov#149
Browse files Browse the repository at this point in the history
  • Loading branch information
slsevilla committed Apr 1, 2024
1 parent c75a6a9 commit e2c3145
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions modules/local/spades.nf
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ process SPADES {
tuple val(meta), path("*_spades_outcome.csv") , emit: spades_outcome

script:
// Adding if/else for if running on ICA it is a requirement to state where the script is, however, this causes CLI users to not run the pipeline from any directory.
if (params.ica==false) { ica = "" }
else if (params.ica==true) { ica = "bash ${workflow.launchDir}/bin/" }
else { error "Please set params.ica to either \"true\" if running on ICA or \"false\" for all other methods." }
// define variables
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
Expand All @@ -37,14 +33,17 @@ process SPADES {
def phred_offset = params.phred
def extended_qc_arg = extended_qc ? "-c" : ""
def container = task.container.toString() - "staphb/spades@"
def script_stats = params.ica ? "${params.ica_path}/pipeline_stats_writer_trimd.sh" : "pipeline_stats_writer_trimd.sh"
def script_before = params.ica ? "${params.ica_path}/beforeSpades.sh" : "beforeSpades.sh"
def script_after = params.ica ? "${params.ica_path}/afterSpades.sh" : "afterSpades.sh"
"""
# preemptively create _summary_line.csv and .synopsis file in case spades fails (no contigs or scaffolds created) we can still collect upstream stats.
${ica}pipeline_stats_writer_trimd.sh -a ${fastp_raw_qc} -b ${fastp_total_qc} -c ${reads[0]} -d ${reads[1]} -e ${kraken2_trimd_report} -f ${k2_bh_summary} -g ${krona_trimd}
${ica}beforeSpades.sh -k ${k2_bh_summary} -n ${prefix} -d ${full_outdir} ${extended_qc_arg}
${script_stats} -a ${fastp_raw_qc} -b ${fastp_total_qc} -c ${reads[0]} -d ${reads[1]} -e ${kraken2_trimd_report} -f ${k2_bh_summary} -g ${krona_trimd}
${script_before} -k ${k2_bh_summary} -n ${prefix} -d ${full_outdir} ${extended_qc_arg}
#get version information
bspades_version=\$(${ica}beforeSpades.sh -V)
pipestats_version=\$(${ica}pipeline_stats_writer_trimd.sh -V)
aspades_version=\$(${ica}afterSpades.sh -V)
bspades_version=\$(${script_before} -V)
pipestats_version=\$(${script_stats} -V)
aspades_version=\$(${script_after} -V)
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down Expand Up @@ -93,6 +92,6 @@ process SPADES {
#Create a summaryline file that will be deleted later if spades is successful if not this line shows up in the final Phoenix_output_summary file
#create file '*_spades_outcome.csv' to state if spades fails, if contigs or scaffolds are created. See spades_failure.nf subworkflow
#This file will determine if downstream process GENERATE_PIPELINE_STATS_FAILURE and CREATE_SUMMARY_LINE_FAILURE will run (if spades creates contigs, but not scaffolds).
${ica}afterSpades.sh
${script_after}
"""
}

0 comments on commit e2c3145

Please sign in to comment.