Skip to content

Commit

Permalink
refactor: ica handling, filtering CDCgov#147 CDCgov#149
Browse files Browse the repository at this point in the history
  • Loading branch information
slsevilla committed Mar 31, 2024
1 parent e9abaa2 commit 3c87d90
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions modules/local/get_trimd_stats.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,39 @@ process GET_TRIMD_STATS {

output:
tuple val(meta), path('*_trimmed_read_counts.txt'), emit: fastp_total_qc
tuple val(meta), path('*_summary.txt'), emit: outcome
path('*_summaryline.tsv'), optional:true, emit: summary_line
tuple val(meta), path('*_summary_old_3.txt'), emit: outcome_to_edit
tuple val(meta), path('*.synopsis'), optional:true, emit: synopsis
path('*_summaryline.tsv'), optional:true, emit: summary_line
tuple val(meta), path('*_summary_fastp.txt'), emit: outcome
tuple val(meta), path('*.synopsis'), optional:true, emit: synopsis
path("versions.yml"), emit: versions

script: // This script is bundled with the pipeline, in cdcgov/phoenix/bin/
// 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 = "python ${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 prefix = task.ext.prefix ?: "${meta.id}"
def busco_parameter = busco_val ? "--busco" : ""
def container_version = "base_v2.1.0"
def container = task.container.toString() - "quay.io/jvhagey/phoenix@"
def script_fastp = params.ica ? "python ${params.ica_path}/FastP_QC.py" : "FastP_QC.py"
def script_fairy = params.ica ? "python ${params.ica_path}/fairy.py" : "fairy.py"
"""
${ica}FastP_QC.py \\
${script_fastp} \\
--trimmed_json ${fastp_trimd_json} \\
--single_json ${fastp_singles_json} \\
--name ${prefix}
# Check that there are still reads in R1 and R2 before fastqc. If there aren't reads then fastqc dies.
# making a copy of the summary file - this avoids writing to the previous file
cp ${fairy_outcome} ${prefix}_input.txt
# Output check for messages indicating there are no trimmed reads after filtering.
${ica}fairy.py -r ${raw_qc} -f ${fairy_outcome} -t ${prefix}_trimmed_read_counts.txt ${busco_parameter}
${script_fairy} -r ${raw_qc} -f ${prefix}_input.txt -t ${prefix}_trimmed_read_counts.txt ${busco_parameter}
#making a copy of the summary file to pass to BBMAP_REFORMAT to handle file names being the same
cp ${prefix}_summary.txt ${prefix}_summary_old_3.txt
mv ${prefix}_summary.txt ${prefix}_summary_fastp.txt
cat <<-END_VERSIONS > versions.yml
"${task.process}":
python: \$(python --version | sed 's/Python //g')
fairy.py: \$( ${ica}fairy.py --version )
FastP_QC.py: \$(${ica}FastP_QC.py --version )
fairy.py: \$( ${script_fairy} --version )
FastP_QC.py: \$(${script_fastp} --version )
phoenix_base_container_tag: ${container_version}
phoenix_base_container: ${container}
END_VERSIONS
Expand Down

0 comments on commit 3c87d90

Please sign in to comment.