Skip to content

Commit

Permalink
Merge pull request #162 from CDCgov/161-refactor-bakta-to-a-single-su…
Browse files Browse the repository at this point in the history
…bworkflow-instead-of-calling-the-processes-in-the-main-workflow

161 refactor bakta with extra params
  • Loading branch information
jessicarowell authored Feb 19, 2024
2 parents 80fe673 + 85c3e12 commit fa3248c
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 140 deletions.
35 changes: 1 addition & 34 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,4 @@ process {
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]

withName: BAKTA {
ext.args = {
[
params.complete ? '--complete' : '',
params.meta ? '--meta' : '',
params.keep_contig_headers ? '--keep-contig-headers' : '',
params.version ? '--version' : '',
params.verbose ? '--verbose' : '',
params.help ? '--help' : '',
params.debug ? '--debug' : '',
params.skip_trna ? '--skip-trna' : '',
params.skip_tmrna ? '--skip-tmrna' : '',
params.skip_rrna ? '--skip-rrna' : '',
params.skip_ncrna ? '--skip-ncrna' : '',
params.skip_ncrna_region ? '--skip-ncrna-region' : '',
params.skip_crispr ? '--skip-crispr' : '',
params.skip_cds ? '--skip-cds' : '',
params.skip_pseudo ? '--skip-pseudo' : '',
params.skip_sorf ? '--skip-sorf' : '',
params.skip_gap ? '--skip-gap' : '',
params.skip_ori ? '--skip-ori' : '',
params.skip_plot ? '--skip-plot' : '',
params.bakta_min_contig_length ? '--min-contig-length',
params.bakta_genus ? '--genus',
params.bakta_species ? '--species',
params.bakta_strain ? '--strain',
params.bakta_plasmid ? '--plasmid',
params.bakta_locus ? '--locus',
params.bakta_locus_tag ? '--locus-tag',
params.bakta_translation_table ? '--translation-table'
]
}
}
}
67 changes: 34 additions & 33 deletions conf/test_params.config
Original file line number Diff line number Diff line change
Expand Up @@ -140,39 +140,40 @@ params {
BAKTA
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
bakta_output_dir = "bakta_outputs"
bakta_db_type = "light" // light or full
download_bakta_db = false
bakta_db_path = ""
bakta_min_contig_length = 200 // due to compliant mode default, otherwise default is 1
bakta_genus = "Genus"
bakta_species = "species"
bakta_strain = "strain"
bakta_plasmid = "unnamed"
bakta_complete = ""
bakta_compliant = ""
bakta_translation_table = 11
bakta_gram = "?"
bakta_locus = "contig"
bakta_locus_tag = "LOCUSTAG123" // set a meaningful locus tag here for compliant mode
bakta_keep_contig_headers = ""
// optional bakta params, for now need to add these to modules/nf-core/bakta/bakta/main.nf
bakta_prodigal_df = ""
bakta_replicons = ""
bakta_proteins = ""
bakta_skip_trna = ""
bakta_skip_tmrna = ""
bakta_skip_rrna = ""
bakta_skip_ncrna = ""
bakta_skip_ncrna_region = ""
bakta_skip_crispr = ""
bakta_skip_cds = ""
bakta_skip_pseudo = ""
bakta_skip_sorf = ""
bakta_skip_gap = ""
bakta_skip_ori = ""
bakta_skip_plot = ""

// required bakta params
bakta_output_dir = "bakta_outputs"
bakta_db_type = "light" // light or full
download_bakta_db = false
bakta_db_path = ""
bakta_min_contig_length = 200 // due to compliant mode default, otherwise default is 1
bakta_genus = "Genus"
bakta_species = "species"
bakta_strain = "unnamed"
bakta_plasmid = "unnamed"
bakta_complete = ""
bakta_compliant = true
bakta_translation_table = 11
bakta_gram = "?"
bakta_locus = "contig"
bakta_locus_tag = "LOCUSTAG123" // set a meaningful locus tag here for compliant mode

// optional bakta params
bakta_keep_contig_headers = ""
bakta_prodigal_tf = ""
bakta_replicons = ""
bakta_proteins = ""
bakta_skip_trna = ""
bakta_skip_tmrna = ""
bakta_skip_rrna = ""
bakta_skip_ncrna = ""
bakta_skip_ncrna_region = ""
bakta_skip_crispr = ""
bakta_skip_cds = ""
bakta_skip_pseudo = ""
bakta_skip_sorf = ""
bakta_skip_gap = ""
bakta_skip_ori = ""
bakta_skip_plot = ""
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SUBMISSION
Expand Down
49 changes: 29 additions & 20 deletions modules/nf-core/bakta/bakta/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ process BAKTA {

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def proteins = params.bakta_proteins ? "--proteins ${proteins[0]}" : ""
def prodigal_tf = params.bakta_prodigal_tf ? "--prodigal-tf ${prodigal_tf[0]}" : ""
def skip_trna = params.bakta_skip_trna ? "--skip-trna" : ""
def skip_tmrna = params.bakta_skip_tmrna ? "--skip-tmrna" : ""
def skip_rrna = params.bakta_skip_rrna ? "--skip-rrna" : ""
def skip_ncrna = params.bakta_skip_ncrna ? "--skip-ncrna" : ""
def skip_ncrna_region = params.bakta_skip_ncrna_region ? "--skip-ncrna-region" : ""
def skip_crispr = params.bakta_skip_crispr ? "--skip-crispr" : ""
def skip_cds = params.bakta_skip_cds ? "--skip-cds" : ""
def skip_sorf = params.bakta_skip_sorf ? "--skip-sorf" : ""
def skip_gap = params.bakta_skip_gap ? "--skip-gap" : ""
def skip_ori = params.bakta_skip_ori ? "--skip-ori" : ""
def compliant = params.bakta_compliant ? "--compliant" : ""
def complete = params.bakta_complete ? "--complete" : ""
def keep_contig_headers = params.bakta_keep_contig_headers ? "--keep-contig-headers" : ""

"""
bakta --db $db_path \
Expand All @@ -34,30 +50,23 @@ process BAKTA {
--complete $params.bakta_complete \
--translation-table $params.bakta_translation_table \
--gram $params.bakta_gram \
--compliant \
--locus $params.bakta_locus \
--locus-tag $params.bakta_locus_tag \
--keep-contig-headers \
$compliant \
$keep_contig_headers \
$proteins \
$prodigal_tf \
$skip_trna \
$skip_rrna \
$skip_ncrna \
$skip_ncrna_region \
$skip_crispr \
$skip_cds \
$skip_sorf \
$skip_gap \
$skip_ori \
$fasta_path
"""
// optional args
// --prodigal-tf $params.bakta_prodigal_tf
// --replicons $params.bakta_replicons
// --proteins $params.bakta_proteins
// --skip-trna
// --skip-tmrna
// --skip-rrna
// --skip-ncrna
// --skip-ncrna-region
// --skip-crispr
// --skip-cds
// --skip-pseudo
// --skip-sorf
// --skip-gap
// --skip-ori
// --skip-plot



output:
path "${fasta_path.getSimpleName()}/*.fna", emit: fna
Expand Down
12 changes: 8 additions & 4 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ params {

// general params
help = false
publish_dir_mode = 'copy'
output_dir = ""
overwrite_output = false
// To Do check if we need these three dirs
Expand Down Expand Up @@ -85,7 +86,7 @@ params {
clear_nf_results = false
overwrite_output = true

// batka annotation
// required bakta params
bakta_output_dir = ""
bakta_db_type = "light" // light or full
download_bakta_db = false
Expand All @@ -101,10 +102,11 @@ params {
bakta_gram = ""
bakta_locus = "contig"
bakta_locus_tag = "LOCUSTAG123" // set a meaningful locus tag here for compliant mode
bakta_keep_contig_headers = ""

// optional bakta params, for now need to add these to modules/nf-core/bakta/bakta/main.nf
bakta_prodigal_df = ""
// optional bakta params
bakta_compliant = ""
bakta_keep_contig_headers = ""
bakta_prodigal_tf = ""
bakta_replicons = ""
bakta_proteins = ""
bakta_skip_trna = ""
Expand Down Expand Up @@ -227,6 +229,8 @@ profiles {
}
}

// Load modules.config for DSL2 module specific options
includeConfig 'conf/modules.config'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
41 changes: 16 additions & 25 deletions subworkflows/local/bakta_entry.nf → subworkflows/local/bakta.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,34 @@
include { BAKTA } from "../../modules/nf-core/bakta/bakta/main"
include { BAKTADBDOWNLOAD } from "../../modules/nf-core/bakta/baktadbdownload/main"
include { BAKTA_POST_CLEANUP } from "../../modules/local/post_bakta_annotation/main"
// get BAKTA related processes

workflow RUN_BAKTA {
take:
run_utility
fasta
utility_signal
fasta_ch

main:
if ( params.download_bakta_db ) {
BAKTADBDOWNLOAD (
run_utility
)

BAKTA (
run_utility,
BAKTADBDOWNLOAD.out.db,
fasta
)
if ( params.download_bakta_db ) {
BAKTADBDOWNLOAD (
utility_signal
)
BAKTA (
utility_signal,
BAKTADBDOWNLOAD.out.db,
fasta_ch
)
}

else {
BAKTA (
run_utility,
params.bakta_db_path,
fasta
utility_signal,
params.bakta_db_path,
fasta_ch
)
}

BAKTA_POST_CLEANUP (
BAKTA.out.bakta_results,
params.meta_path,
fasta
)

emit:
cleaned_fasta = BAKTA_POST_CLEANUP.out.fasta
cleaned_gff = BAKTA_POST_CLEANUP.out.gff

gff3 = BAKTA.out.gff3
}


33 changes: 9 additions & 24 deletions workflows/tostadas.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ include { METADATA_VALIDATION } from "../modules/l

// get viral annotation process/subworkflows
include { LIFTOFF } from "../modules/local/liftoff_annotation/main"
include { REPEATMASKER_LIFTOFF } from "../subworkflows/local/repeatmasker_liftoff"
include { REPEATMASKER_LIFTOFF } from "../subworkflows/local/repeatmasker_liftoff"
include { RUN_VADR } from "../subworkflows/local/vadr"

// get BAKTA related processes
include { BAKTADBDOWNLOAD } from "../modules/nf-core/bakta/baktadbdownload/main"
include { BAKTA } from "../modules/nf-core/bakta/bakta/main"
include { BAKTA_POST_CLEANUP } from "../modules/local/post_bakta_annotation/main"
// get BAKTA subworkflow
include { RUN_BAKTA } from "../subworkflows/local/bakta"

// get submission related process/subworkflows
include { FULL_SUBMISSION } from "../subworkflows/local/full_submission"
Expand Down Expand Up @@ -125,7 +123,7 @@ workflow TOSTADAS {
if ( params.vadr ) {
RUN_VADR (
RUN_UTILITY.out,
CHECK_FILES.out.fasta_files.sort().flatten()
fasta_ch
)
vadr_gff_ch = RUN_VADR.out.collect().flatten()
.map {
Expand All @@ -138,30 +136,17 @@ workflow TOSTADAS {
if ( params.bacteria ) {
// run bakta annotation process
if ( params.bakta == true ) {
if ( params.download_bakta_db ) {
BAKTADBDOWNLOAD (
RUN_UTILITY.out
RUN_BAKTA(
RUN_UTILITY.out,
fasta_ch
)
BAKTA (
RUN_UTILITY.out,
BAKTADBDOWNLOAD.out.db,
fasta_ch
)
}
else {
BAKTA (
RUN_UTILITY.out,
params.bakta_db_path,
fasta_ch
)
bakta_gff_ch = BAKTA.out.gff3.flatten()
// set up submission channels
bakta_gff_ch = RUN_BAKTA.out.gff3.flatten()
.map {
def meta = [:]
meta['id'] = it.getSimpleName()
[ meta, it ]
}
}
// set up submission channels
submission_ch = metadata_ch.join(fasta_ch)
submission_ch = submission_ch.join(bakta_gff_ch)
}
Expand Down

0 comments on commit fa3248c

Please sign in to comment.