@@ -121,7 +121,8 @@ def runIPRpython(Input):
121
121
sys .exit (1 )
122
122
if not os .path .isfile (os .path .join (parentdir , 'DB' , args .eggnog_db + '_4.5.hmm' )):
123
123
lib .log .error ("%s EggNog DB not found, trying to download and format..." % args .eggnog_db )
124
- subprocess .call ([os .path .join (parentdir , 'util' , 'getEggNog.sh' ), args .eggnog_db , os .path .join (parentdir , 'DB' )], stdout = FNULL , stderr = FNULL )
124
+ cmd = [os .path .join (parentdir , 'util' , 'getEggNog.sh' ), args .eggnog_db , os .path .join (parentdir , 'DB' )]
125
+ lib .runSubprocess (cmd , '.' , lib .log )
125
126
if not os .path .isfile (os .path .join (parentdir , 'DB' , args .eggnog_db + '_4.5.hmm' )):
126
127
lib .log .error ("Downloading failed, exiting" )
127
128
sys .exit (1 )
@@ -133,6 +134,11 @@ def runIPRpython(Input):
133
134
lib .download_buscos (args .busco_db )
134
135
135
136
#need to do some checks here of the input
137
+ genbank = ''
138
+ Scaffolds = ''
139
+ Proteins = ''
140
+ Transcripts = ''
141
+ GFF = ''
136
142
if not args .input :
137
143
#did not parse folder of funannotate results, so need either gb + gff or fasta + proteins, + gff and also need to have args.out for output folder
138
144
if not args .out :
@@ -226,7 +232,7 @@ def runIPRpython(Input):
226
232
227
233
#get organism and isolate from GBK file
228
234
if not args .species :
229
- if args . genbank :
235
+ if genbank != '' :
230
236
with open (genbank , 'rU' ) as gbk :
231
237
SeqRecords = SeqIO .parse (gbk , 'genbank' )
232
238
for record in SeqRecords :
@@ -239,8 +245,8 @@ def runIPRpython(Input):
239
245
isolate = args .isolate
240
246
break
241
247
else :
242
- organism = '???'
243
- isolate = '???'
248
+ lib . log . error ( "No species name given will cause problems downstream, please pass a name to -s,--species" )
249
+ sys . exit ( 1 )
244
250
else :
245
251
organism = args .species
246
252
if not args .isolate :
@@ -355,21 +361,22 @@ def runIPRpython(Input):
355
361
os .makedirs (IPROUT )
356
362
#now split XML file
357
363
splitter = os .path .join (parentdir , 'util' , 'prepare_ind_xml.pl' )
358
- subprocess .call ([splitter , args .iprscan , IPROUT ], stdout = FNULL , stderr = FNULL )
364
+ cmd = [splitter , args .iprscan , IPROUT ]
365
+ lib .runSubprocess (cmd , '.' , lib .log )
359
366
360
367
#now collect the results from InterProscan, then start to reformat results
361
368
lib .log .info ("InterProScan has finished, now pulling out annotations from results" )
362
369
IPR_terms = os .path .join (outputdir , 'annotate_misc' , 'annotations.iprscan.txt' )
363
370
if not os .path .isfile (IPR_terms ):
364
371
IPR2TSV = os .path .join (parentdir , 'util' , 'ipr2tsv.py' )
365
- with open ( IPR_terms , 'w' ) as output :
366
- subprocess . call ([ sys . executable , IPR2TSV , IPROUT ], stdout = output , stderr = FNULL )
372
+ cmd = [ sys . executable , IPR2TSV , IPROUT ]
373
+ lib . runSubprocess2 ( cmd , '.' , lib . log , IPR_terms )
367
374
GO_terms = os .path .join (outputdir , 'annotate_misc' , 'annotations.GO.txt' )
368
375
if not os .path .isfile (GO_terms ):
369
376
IPR2GO = os .path .join (parentdir , 'util' , 'ipr2go.py' )
370
377
OBO = os .path .join (parentdir , 'DB' , 'go.obo' )
371
- with open ( GO_terms , 'w' ) as output :
372
- subprocess . call ([ sys . executable , IPR2GO , OBO , IPROUT ], stdout = output , stderr = FNULL )
378
+ cmd = [ sys . executable , IPR2GO , OBO , IPROUT ]
379
+ lib . runSubprocess2 ( cmd , '.' , lib . log , GO_terms )
373
380
374
381
375
382
#check if antiSMASH data is given, if so parse and reformat for annotations and cluster textual output
@@ -409,7 +416,8 @@ def runIPRpython(Input):
409
416
#launch gag
410
417
GAG = os .path .join (outputdir , 'annotate_misc' , 'gag' )
411
418
lib .log .info ("Adding annotations to GFF using GAG" )
412
- subprocess .call (['gag.py' , '-f' , Scaffolds , '-g' , GFF , '-a' , ANNOTS , '-o' , GAG ], stdout = FNULL , stderr = FNULL )
419
+ cmd = ['gag.py' , '-f' , Scaffolds , '-g' , GFF , '-a' , ANNOTS , '-o' , GAG ]
420
+ lib .runSubprocess (cmd , '.' , lib .log )
413
421
414
422
#fix the tbl file for tRNA genes
415
423
lib .log .info ("Fixing tRNA annotations in GenBank tbl file" )
@@ -432,7 +440,8 @@ def runIPRpython(Input):
432
440
shutil .copyfile (os .path .join (GAG , 'genome.fasta' ), os .path .join (GAG , 'genome.fsa' ))
433
441
discrep = 'discrepency.report.txt'
434
442
lib .log .info ("Converting to final Genbank format, good luck!....." )
435
- subprocess .call (['tbl2asn' , '-p' , GAG , '-t' , SBT , '-M' , 'n' , '-Z' , discrep , '-a' , 'r10u' , '-l' , 'paired-ends' , '-j' , ORGANISM , '-V' , 'b' , '-c' , 'fx' ], stdout = FNULL , stderr = FNULL )
443
+ cmd = ['tbl2asn' , '-p' , GAG , '-t' , SBT , '-M' , 'n' , '-Z' , discrep , '-a' , 'r10u' , '-l' , 'paired-ends' , '-j' , ORGANISM , '-V' , 'b' , '-c' , 'fx' ]
444
+ lib .runSubprocess (cmd , '.' , lib .log )
436
445
437
446
#collected output files and rename accordingly
438
447
ResultsFolder = os .path .join (outputdir , 'annotate_results' )
@@ -451,9 +460,8 @@ def runIPRpython(Input):
451
460
lib .log .info ("Creating AGP file and corresponding contigs file" )
452
461
agp2fasta = os .path .join (parentdir , 'util' , 'fasta2agp.pl' )
453
462
AGP = os .path .join (ResultsFolder , baseOUTPUT + '.agp' )
454
- with open (AGP , 'w' ) as output :
455
- subprocess .call (['perl' , agp2fasta , baseOUTPUT + '.scaffolds.fa' ], cwd = ResultsFolder , stdout = output , stderr = FNULL )
456
-
463
+ cmd = ['perl' , agp2fasta , baseOUTPUT + '.scaffolds.fa' ]
464
+ lib .runSubprocess2 (cmd , ResultsFolder , lib .log , AGP )
457
465
458
466
#write secondary metabolite clusters output using the final genome in gbk format
459
467
if args .antismash :
@@ -474,7 +482,8 @@ def runIPRpython(Input):
474
482
for record in SeqRecords :
475
483
if record .id in AllProts :
476
484
SeqIO .write (record , output , 'fasta' )
477
- subprocess .call (['blastp' , '-query' , mibig_fasta , '-db' , mibig_db , '-num_threads' , str (args .cpus ), '-max_target_seqs' , '1' , '-max_hsps' , '1' , '-evalue' , '0.001' , '-outfmt' , '6' , '-out' , mibig_blast ])
485
+ cmd = ['blastp' , '-query' , mibig_fasta , '-db' , mibig_db , '-num_threads' , str (args .cpus ), '-max_target_seqs' , '1' , '-max_hsps' , '1' , '-evalue' , '0.001' , '-outfmt' , '6' , '-out' , mibig_blast ]
486
+ lib .runSubprocess (cmd , '.' , lib .log )
478
487
#now parse blast results to get {qseqid: hit}
479
488
MIBiGBlast = {}
480
489
with open (mibig_blast , 'rU' ) as input :
0 commit comments