Skip to content

Commit

Permalink
refactor: mlst, amrfinder for terra, ica CDCgov#149
Browse files Browse the repository at this point in the history
  • Loading branch information
slsevilla committed Apr 3, 2024
1 parent b056478 commit 8c76843
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 50 deletions.
8 changes: 3 additions & 5 deletions modules/local/check_mlst.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,21 @@ process CHECK_MLST {
tuple val(meta), path("*_status.txt"), emit: status
path("versions.yml") , emit: versions

when:
task.ext.when == null || task.ext.when

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 = "python ${workflow.launchDir}/bin/" }
else { error "Please set params.ica to either \"true\" if running on ICA or \"false\" for all other methods." }
def container_version = "base_v2.1.0"
def container = task.container.toString() - "quay.io/jvhagey/phoenix@"
def script = params.ica ? "python ${params.ica_path}/fix_MLST2.py" : "fix_MLST2.py"
"""
${ica}fix_MLST2.py --input $mlst_file --taxonomy $taxonomy_file --mlst_database ${local_dbases}
${script} --input $mlst_file --taxonomy $taxonomy_file --mlst_database ${local_dbases}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
python: \$(python --version | sed 's/Python //g')
fix_MLST2.py: \$(${ica}fix_MLST2.py --version )
fix_MLST2.py: \$(${script} --version )
phoenix_base_container_tag: ${container_version}
phoenix_base_container: ${container}
END_VERSIONS
Expand Down
7 changes: 2 additions & 5 deletions modules/local/get_taxa_for_amrfinder.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ process GET_TAXA_FOR_AMRFINDER {
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 container_version = "base_v2.1.0"
def container = task.container.toString() - "quay.io/jvhagey/phoenix@"
def script = params.ica ? "python ${params.ica_path}/get_taxa_for_amrfinder.py" : "get_taxa_for_amrfinder.py"
"""
${ica}get_taxa_for_amrfinder.py -t $taxa_file -o ${prefix}_AMRFinder_Organism.csv
${script} -t $taxa_file -o ${prefix}_AMRFinder_Organism.csv
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
17 changes: 3 additions & 14 deletions modules/local/run_amrfinder.nf
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,13 @@ process AMRFINDERPLUS_RUN {
task.ext.when == null || task.ext.when

script:
// use --organism
if ( "${organism_param[0]}" != "No Match Found") {
organism = "--organism ${organism_param[0]}"
} else { organism = "" }
//set up for terra
if (params.terra==false) {
terra = ""
terra_exit = ""
} else if (params.terra==true) {
terra = "PATH=/opt/conda/envs/amrfinderplus/bin:\$PATH"
terra_exit = """PATH="\$(printf '%s\\n' "\$PATH" | sed 's|/opt/conda/envs/amrfinderplus/bin:||')" """
} else {
error "Please set params.terra to either \"true\" or \"false\""
}
// define variables
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def container = task.container.toString() - "staphb/ncbi-amrfinderplus@"
def terra = params.terra ? "PATH=/opt/conda/envs/amrfinderplus/bin:\$PATH" : ""
def terra_exit = params.terra ? """PATH="\$(printf '%s\\n' "\$PATH" | sed 's|/opt/conda/envs/amrfinderplus/bin:||')" """ : ""
def organism = "${organism_param[0]}" != "No Match Found" ? "--organism ${organism_param[0]}" : ""
//get name of amrfinder database file
db_name = db.toString() - '.tar.gz'
"""
Expand Down
52 changes: 26 additions & 26 deletions workflows/phoenix.nf
Original file line number Diff line number Diff line change
Expand Up @@ -330,37 +330,37 @@ workflow PHOENIX_EXTERNAL {
)
ch_versions = ch_versions.mix(DO_MLST.out.versions)

// /*// Fetch AMRFinder Database
// AMRFINDERPLUS_UPDATE( )
// ch_versions = ch_versions.mix(AMRFINDERPLUS_UPDATE.out.versions)*/
/*// Fetch AMRFinder Database
AMRFINDERPLUS_UPDATE( )
ch_versions = ch_versions.mix(AMRFINDERPLUS_UPDATE.out.versions)*/

// // Create file that has the organism name to pass to AMRFinder
// GET_TAXA_FOR_AMRFINDER (
// DETERMINE_TAXA_ID.out.taxonomy
// )
// ch_versions = ch_versions.mix(GET_TAXA_FOR_AMRFINDER.out.versions)
// Create file that has the organism name to pass to AMRFinder
GET_TAXA_FOR_AMRFINDER (
DETERMINE_TAXA_ID.out.taxonomy
)
ch_versions = ch_versions.mix(GET_TAXA_FOR_AMRFINDER.out.versions)

// // Combining taxa and scaffolds to run amrfinder and get the point mutations.
// amr_channel = BBMAP_REFORMAT.out.filtered_scaffolds.map{ meta, reads -> [[id:meta.id], reads]}\
// .join(GET_TAXA_FOR_AMRFINDER.out.amrfinder_taxa.splitCsv(strip:true).map{meta, amrfinder_taxa -> [[id:meta.id], amrfinder_taxa ]}, by: [0])\
// .join(PROKKA.out.faa.map{ meta, faa -> [[id:meta.id], faa ]}, by: [0])\
// .join(PROKKA.out.gff.map{ meta, gff -> [[id:meta.id], gff ]}, by: [0])
// Combining taxa and scaffolds to run amrfinder and get the point mutations.
amr_channel = BBMAP_REFORMAT.out.filtered_scaffolds.map{ meta, reads -> [[id:meta.id], reads]}\
.join(GET_TAXA_FOR_AMRFINDER.out.amrfinder_taxa.splitCsv(strip:true).map{meta, amrfinder_taxa -> [[id:meta.id], amrfinder_taxa ]}, by: [0])\
.join(PROKKA.out.faa.map{ meta, faa -> [[id:meta.id], faa ]}, by: [0])\
.join(PROKKA.out.gff.map{ meta, gff -> [[id:meta.id], gff ]}, by: [0])

// // Run AMRFinder
// AMRFINDERPLUS_RUN (
// amr_channel, params.amrfinder_db
// )
// ch_versions = ch_versions.mix(AMRFINDERPLUS_RUN.out.versions)
// Run AMRFinder
AMRFINDERPLUS_RUN (
amr_channel, params.amrfinder_db
)
ch_versions = ch_versions.mix(AMRFINDERPLUS_RUN.out.versions)

// // Combining determined taxa with the assembly stats based on meta.id
// assembly_ratios_ch = DETERMINE_TAXA_ID.out.taxonomy.map{meta, taxonomy -> [[id:meta.id], taxonomy]}\
// .join(QUAST.out.report_tsv.map{ meta, report_tsv -> [[id:meta.id], report_tsv]}, by: [0])
// Combining determined taxa with the assembly stats based on meta.id
assembly_ratios_ch = DETERMINE_TAXA_ID.out.taxonomy.map{meta, taxonomy -> [[id:meta.id], taxonomy]}\
.join(QUAST.out.report_tsv.map{ meta, report_tsv -> [[id:meta.id], report_tsv]}, by: [0])

// // Calculating the assembly ratio and gather GC% stats
// CALCULATE_ASSEMBLY_RATIO (
// assembly_ratios_ch, params.ncbi_assembly_stats
// )
// ch_versions = ch_versions.mix(CALCULATE_ASSEMBLY_RATIO.out.versions)
// Calculating the assembly ratio and gather GC% stats
CALCULATE_ASSEMBLY_RATIO (
assembly_ratios_ch, params.ncbi_assembly_stats
)
ch_versions = ch_versions.mix(CALCULATE_ASSEMBLY_RATIO.out.versions)

// GENERATE_PIPELINE_STATS_WF (
// GET_RAW_STATS.out.combined_raw_stats, \
Expand Down

0 comments on commit 8c76843

Please sign in to comment.