Skip to content

Commit f944a34

Browse files
committed
fixed generate_config with or without precomp busco
1 parent 27da84e commit f944a34

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

bin/generate_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def parse_args(args=None):
4747
parser.add_argument("--blastx", help="Path to the blastx database", required=True)
4848
parser.add_argument("--blastn", help="Path to the blastn database", required=True)
4949
parser.add_argument("--taxdump", help="Path to the taxonomy database", required=True)
50-
parser.add_argument("--busco_output", action="append", help="Path to BUSCO output directory", required=True)
50+
parser.add_argument("--busco_output", action="append", help="Path to BUSCO output directory", required=False)
5151
parser.add_argument("--version", action="version", version="%(prog)s 2.0")
5252
return parser.parse_args(args)
5353

@@ -337,7 +337,7 @@ def main(args=None):
337337
taxon_info = fetch_taxon_info(args.taxon_query)
338338
classification = get_classification(taxon_info)
339339

340-
precomputed_busco = [os.path.basename(path).replace("run_", "") for path in args.busco_output]
340+
precomputed_busco = [os.path.basename(path).replace("run_", "") for path in (args.busco_output or [])]
341341
odb_arr = get_odb(taxon_info, args.lineage_tax_ids, args.busco, precomputed_busco)
342342
taxon_id = adjust_taxon_id(args.nt, taxon_info)
343343

modules/local/generate_config.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ process GENERATE_CONFIG {
1515
tuple val(meta3), path(blastx, stageAs: 'blastx/*')
1616
tuple val(meta4), path(blastn, stageAs: 'blastn/*')
1717
tuple val(meta5), path(taxdump)
18-
tuple val(busco_meta), path(busco_output)
18+
val (busco_outputs)
1919

2020
output:
2121
tuple val(meta), path("*.yaml") , emit: yaml
@@ -33,7 +33,7 @@ process GENERATE_CONFIG {
3333
def busco_param = busco_lin ? "--busco '${busco_lin}'" : ""
3434
def accession_params = params.accession ? "--accession ${params.accession}" : ""
3535
def input_reads = reads.collect{"--read_id ${it[0].id} --read_type ${it[0].datatype} --read_layout ${it[0].layout} --read_path ${it[1]}"}.join(' ')
36-
def busco_output_param = "--busco_output ${busco_output}"
36+
def busco_output_param = busco_outputs.collect { meta, path -> "--busco_output ${path}" }.join(' ')
3737
"""
3838
generate_config.py \\
3939
--fasta $fasta \\

subworkflows/local/input_check.nf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ workflow INPUT_CHECK {
143143
ch_databases.blastx,
144144
ch_databases.blastn,
145145
ch_databases.taxdump,
146-
ch_parsed_busco.map { meta, path -> [meta, path] }.groupTuple()
146+
ch_parsed_busco.toList()
147147
)
148148
ch_versions = ch_versions.mix(GENERATE_CONFIG.out.versions.first())
149149

@@ -178,6 +178,16 @@ workflow INPUT_CHECK {
178178
ch_parsed_csv.busco_lineage
179179
| collect
180180
| set { ch_busco_lineages }
181+
ch_busco_lineages.view()
182+
ch_parsed_busco.view()
183+
184+
// Remove any invalid lineages from busco_outputs
185+
ch_busco_lineages_list = ch_busco_lineages.flatten()
186+
ch_parsed_busco_filtered = ch_parsed_busco
187+
.filter { meta, path ->
188+
ch_busco_lineages.contains(meta.lineage)
189+
}
190+
ch_parsed_busco_filtered = ch_parsed_busco_filtered.ifEmpty { Channel.empty() }
181191

182192
emit:
183193
reads // channel: [ val(meta), path(datafile) ]
@@ -189,7 +199,7 @@ workflow INPUT_CHECK {
189199
blastn = ch_databases.blastn // channel: [ val(meta), path(blastn_db) ]
190200
blastp = ch_databases.blastp // channel: [ val(meta), path(blastp_db) ]
191201
blastx = ch_databases.blastx // channel: [ val(meta), path(blastx_db) ]
192-
busco_output = Channel.empty() // channel: [ val(meta), path(busco_output) ]
202+
busco_output = ch_parsed_busco_filtered // channel: [ val(meta), path(busco_output) ]
193203
busco_db = ch_databases.busco.map { _, db_path -> db_path } // channel: [ path(busco_db) ]
194204
taxdump = ch_databases.taxdump.map { _, db_path -> db_path } // channel: [ path(taxdump) ]
195205
versions = ch_versions // channel: [ versions.yml ]

0 commit comments

Comments
 (0)