Skip to content

Commit 6521a39

Browse files
committed
modified asm channel to combine input and assembled and excluded things that have reads to prevent doubling up
1 parent 4aa8ebc commit 6521a39

2 files changed

Lines changed: 25 additions & 19 deletions

File tree

bohra/bohra.nf

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ println "Running bohra - microbial genomics pipeline!"
2020

2121
// get a list of samples
2222
def samples = [:]
23+
def rds = []
2324
def asms = [:]
2425
def asmblr = [:]
2526
def sp = [:]
@@ -32,12 +33,17 @@ input_file = file(params.isolates) // need to make this an input file
3233
line = line.split("\t")
3334
// println "The line is : $line"
3435
samples[line[0]] = line[0]
36+
if (line[1] != "not_supplied") {
37+
rds << line[0]
38+
}
3539
asms[line[0]] = line[3]
3640
// asmblr[line[0]] = line[3]
3741
sp[line[0]] = line[4]
3842
ctrl[line[0]] = line[5]
3943
}
4044
}
45+
// println "The samples are : $samples"
46+
// println "The samples with reads are : $rds"
4147

4248
println "Will run : $params.modules"
4349
// println samples
@@ -61,10 +67,12 @@ workflow {
6167
// .map { files -> tuple([id: files.getParent().getName(), modules:samples[files.getParent().getName()], input_type:'ont_reads', asm :asms[files.getParent().getName()],assembler:asmblr[files.getParent().getName()],species:sp[files.getParent().getName()]], files)}
6268

6369
asm = Channel.fromPath( ["${params.outdir}/*/contigs.fa"])
64-
.filter { files -> samples.containsKey(files.getParent().getName())}
70+
.filter { files -> samples.containsKey(files.getParent().getName())}
71+
.filter { files -> rds.contains(files.getParent().getName()) == false } // only take assemblies for samples that don't have reads
6572
.map { files -> tuple([id: files.getParent().getName(), input_type:'asm', asm :files, species:sp[files.getParent().getName()], control: ctrl[files.getParent().getName()]], files)}
6673

67-
74+
// println reads_pe.view()
75+
// println asm.view()
6876
results = Channel.empty()
6977

7078
// println reads_pe.view()
@@ -78,41 +86,39 @@ workflow {
7886
versions = READ_ANALYSIS.out.version_seqkit_reads
7987
versions = versions.concat( READ_ANALYSIS.out.version_kmc )
8088
versions = versions.concat( READ_ANALYSIS.out.version_bohra )
81-
// reads_pe = READ_ANALYSIS.out.reads_pe
89+
reads_pe = READ_ANALYSIS.out.reads_pe
8290
// if there is assembly in the modules list then generate an assembly and run assembly analysis
83-
91+
asm_out = Channel.empty()
8492
if (params.modules.contains("assemble") ){
8593
// assembly is only done if the input is reads
8694
RUN_ASSEMBLE ( reads_pe.filter { cfg, files -> cfg.control != 'control' } )
8795
// RUN_ASSEMBLE ( reads_ont )
88-
asm = RUN_ASSEMBLE.out.contigs
96+
asm_out = RUN_ASSEMBLE.out.contigs
97+
8998
versions = versions.concat( RUN_ASSEMBLE.out.versions )
9099
results = results.concat( RUN_ASSEMBLE.out.insertiqr )
91100

92101
}
102+
asm_input = asm.mix(asm_out)
103+
93104
if (params.modules.contains("prokka") ){
94-
ASSEMBLY_ANALYSIS_FULL ( asm )
105+
ASSEMBLY_ANALYSIS_FULL ( asm_input )
95106
assembly_stats = ASSEMBLY_ANALYSIS_FULL.out.assembly_stats
96107
versions = versions.concat( ASSEMBLY_ANALYSIS_FULL.out.version_prokka, ASSEMBLY_ANALYSIS_FULL.out.version_seqkit_asm )
97108
// update the results with the assembly stats
98109
results = results.concat( assembly_stats )
99110
} else {
100-
ASSEMBLY_ANALYSIS_QUICK ( asm )
111+
ASSEMBLY_ANALYSIS_QUICK ( asm_input )
101112
assembly_stats = ASSEMBLY_ANALYSIS_QUICK.out.assembly_stats
102113
versions = versions.concat( ASSEMBLY_ANALYSIS_QUICK.out.version_seqkit_asm )
103114
// update the results with the assembly stats
104115
results = results.concat( assembly_stats )
105116
}
106-
// ASSEMBLY_ANALYSIS ( asm )
107-
// assembly_stats = ASSEMBLY_ANALYSIS.out.assembly_stats
108-
// versions = versions.concat( ASSEMBLY_ANALYSIS.out.version_prokka, ASSEMBLY_ANALYSIS.out.version_seqkit_asm )
109-
// update the results with the assembly stats
110-
results = results.concat( assembly_stats )
111-
117+
112118
if (params.modules.contains("species") ){
113119

114120
RUN_SPECIES_READS ( reads_pe )
115-
RUN_SPECIES_ASM ( asm )
121+
RUN_SPECIES_ASM ( asm_input )
116122
versions = versions.concat( RUN_SPECIES_READS.out.version, RUN_SPECIES_ASM.out.version )
117123
reads_species_obs = RUN_SPECIES_READS.out.species_obs
118124
asm_species_obs = RUN_SPECIES_ASM.out.species_obs
@@ -152,7 +158,7 @@ workflow {
152158
if (params.modules.contains("typing") ){
153159
// assembly is only done if the input is reads
154160
// find any tb as plasmid and mlst and abritamr no good - use tbtamr
155-
asm_typing = asm.filter { cfg, asm -> cfg.species != 'Mycobacterium tuberculosis' }.filter { cfg, files -> cfg.control != 'control' }
161+
asm_typing = asm_input.filter { cfg, asm -> cfg.species != 'Mycobacterium tuberculosis' }.filter { cfg, files -> cfg.control != 'control' }
156162
reads_nottb = reads_pe.filter { cfg, reads -> cfg.species != 'Mycobacterium tuberculosis' }.filter { cfg, files -> cfg.control != 'control' }
157163
reads_tb = reads_pe.filter { cfg, reads -> cfg.species == 'Mycobacterium tuberculosis' }.filter { cfg, files -> cfg.control != 'control' }
158164
RUN_TYPING ( asm_typing, reads_nottb )

bohra/modules/datasmryzr/bin/run_datasmryzr.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ def check_contigs(upper, lower, contigs:list) -> str:
6767
"""
6868
# print(contigs[0])
6969
# print(lower, upper)
70-
if contigs[1]:
70+
if contigs['is_control']:
7171
return 1
72-
if contigs[0] == "":
72+
if contigs['# Contigs'] == "":
7373
return 1
74-
if (contigs[0] >= lower) and (contigs[0] <= upper):
74+
if (contigs['# Contigs'] >= lower) and (contigs['# Contigs'] <= upper):
7575
return 1
7676
else:
77-
return f"Number of contigs: {contigs[0]} is outside the expected range of {lower} and {upper}."
77+
return f"Number of contigs: {contigs['# Contigs']} is outside the expected range of {lower} and {upper}."
7878

7979
def check_filesize(filesize) -> str:
8080
"""

0 commit comments

Comments
 (0)