Skip to content

Commit 6eb57b3

Browse files
committed
fixing up species #210 and added new env var for mlst #214
1 parent 44f47bd commit 6eb57b3

5 files changed

Lines changed: 28 additions & 16 deletions

File tree

bohra/bohra.nf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ workflow {
8585
READ_ANALYSIS ( reads_pe )
8686
read_stats = READ_ANALYSIS.out.read_stats
8787
reads_pe = READ_ANALYSIS.out.reads_pe
88+
// println reads_pe.view()
8889
results = results.concat( read_stats)
8990
versions = READ_ANALYSIS.out.version_seqkit_reads
9091
versions = versions.concat( READ_ANALYSIS.out.version_kmc )
@@ -208,7 +209,8 @@ workflow {
208209
reads = reads_pe.filter { cfg,files -> cfg.control != 'control' }.map { cfg, files -> tuple(cfg.id, cfg, files) }
209210
//
210211
asm_tmp = asm.filter { cfg,files -> cfg.control != 'control' }.map { cfg, files -> tuple(cfg.id, cfg , files) }
211-
// println reads.view()
212+
println reads.view()
213+
println asm_tmp.view()
212214
sequences = reads.join(asm_tmp, remainder:true).map( v -> { v.size() == 4 ? v[1] ? [v[1],v[2]] : [v[2],v[3]] : [v[1],v[2]]} )
213215

214216
}

bohra/environments/mlst.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ channels:
22
- conda-forge
33
- bioconda
44
dependencies:
5-
- mlst>=2.32.2
5+
- mlst>=2.35
66
- csvtk
77
- pandas

bohra/launcher/BohraTyping.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ def _missing_reads(input_table: pd.DataFrame) -> bool:
4848

4949
def _setup_typing_args(kwargs:dict, command:dict, mtb:False) -> dict:
5050

51-
typing_dbs = ["blast_db", "data_dir", "mobsuite_db"]
51+
# typing_dbs = ["mlst_dbdir", "mobsuite_db"]
52+
typing_dbs = {
53+
"blastdb": f"{kwargs['mlst_dbdir']}/blast/mlst.fa",
54+
"datadir":f"{kwargs['mlst_dbdir']}/pubmlst",
55+
"mobsuite_db": f"{kwargs['mobsuite_db']}"}
5256
input_table = _open_input_file(kwargs['input_file'])
5357
command = _setup_assembly_args(kwargs, command, mtb)
5458
command['modules'].append('typing')
5559
for d in typing_dbs:
56-
db = _check_databases(path = kwargs[d], dtbtype = d)
60+
db = _check_databases(path = typing_dbs[d], dtbtype = d)
5761
command["params"].append(db)
5862

5963
exclude = eval(kwargs['mlst_exclude'])

bohra/launcher/Utils.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,15 @@ def _get_run_cmd_options() -> dict:
412412
"amr_typing": [
413413

414414
{
415-
"name":"blast_db",
416-
"help":"Path to the mlst blast_db, defaults to what is installed in the environment.",
417-
"default":f"{os.getenv('BLAST_DB', '')}"
418-
},
419-
{
420-
"name":"data_dir",
421-
"help":"Path to the mlst datadir, defaults to what is installed in the environment.",
422-
"default":f"{os.getenv('PUBMLST_DB','')}"
423-
},
415+
"name":"mlst_dbdir",
416+
"help":"Path to the mlst blast and publmlst, defaults to what is installed in the environment.",
417+
"default":f"{os.getenv('MLST_DBDIR', '')}"
418+
},
419+
# {
420+
# "name":"data_dir",
421+
# "help":"Path to the mlst datadir, defaults to what is installed in the environment.",
422+
# "default":f"{os.getenv('PUBMLST_DB','')}"
423+
# },
424424
{
425425
"name":"mlst_exclude",
426426
"short_name":"-me",

bohra/modules/collation/bin/collate_kraken2.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
try:
2727
sp = pd.read_csv(f"{sys.argv[2]}", sep = "\t", header = None, names = ["perc","cumulative",'direct','rank','taxon_id','name'])
2828
sp['name'] = sp['name'].apply(lambda x: x.strip())
29-
uc = sp[sp['rank'] == "U"]['perc'].values[0]
29+
uc = sp[sp['rank'] == "U"]
30+
if uc.shape[0] == 0:
31+
uc = 0
32+
else:
33+
uc = uc['perc'].values[0]
3034
print(uc)
3135
spc = sp[sp['rank'] == "S"].sort_values(['perc'], ascending = False).head(3)
3236
print(spc)
@@ -42,8 +46,10 @@
4246
levs = levs +1
4347

4448
df = pd.DataFrame(res, index = [0])
45-
print(df[["Isolate","Unclassified (%)","Match 1","Detected_1 (%)","Match 2","Detected_2 (%)","Match 3","Detected_3 (%)"]])
46-
df[["Isolate","Unclassified (%)","Match 1","Detected_1 (%)","Match 2","Detected_2 (%)","Match 3","Detected_3 (%)"]].to_csv(f"{sys.argv[3]}", sep = "\t", index = False)
49+
cols = ["Isolate","Unclassified (%)","Match 1","Detected_1 (%)","Match 2","Detected_2 (%)","Match 3","Detected_3 (%)"]
50+
cols = [i for i in cols if i in df.columns.tolist()]
51+
print(df[cols])
52+
df[cols].to_csv(f"{sys.argv[3]}", sep = "\t", index = False)
4753
except Exception as e:
4854
print(f"Something has gone wrong opening the kraken report: {e}")
4955

0 commit comments

Comments
 (0)