@@ -121,7 +121,8 @@ def runIPRpython(Input):
121121 sys .exit (1 )
122122if not os .path .isfile (os .path .join (parentdir , 'DB' , args .eggnog_db + '_4.5.hmm' )):
123123 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 )
125126 if not os .path .isfile (os .path .join (parentdir , 'DB' , args .eggnog_db + '_4.5.hmm' )):
126127 lib .log .error ("Downloading failed, exiting" )
127128 sys .exit (1 )
@@ -133,6 +134,11 @@ def runIPRpython(Input):
133134 lib .download_buscos (args .busco_db )
134135
135136#need to do some checks here of the input
137+ genbank = ''
138+ Scaffolds = ''
139+ Proteins = ''
140+ Transcripts = ''
141+ GFF = ''
136142if not args .input :
137143 #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
138144 if not args .out :
@@ -226,7 +232,7 @@ def runIPRpython(Input):
226232
227233#get organism and isolate from GBK file
228234if not args .species :
229- if args . genbank :
235+ if genbank != '' :
230236 with open (genbank , 'rU' ) as gbk :
231237 SeqRecords = SeqIO .parse (gbk , 'genbank' )
232238 for record in SeqRecords :
@@ -239,8 +245,8 @@ def runIPRpython(Input):
239245 isolate = args .isolate
240246 break
241247 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 )
244250else :
245251 organism = args .species
246252 if not args .isolate :
@@ -355,21 +361,22 @@ def runIPRpython(Input):
355361 os .makedirs (IPROUT )
356362 #now split XML file
357363 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 )
359366
360367 #now collect the results from InterProscan, then start to reformat results
361368 lib .log .info ("InterProScan has finished, now pulling out annotations from results" )
362369 IPR_terms = os .path .join (outputdir , 'annotate_misc' , 'annotations.iprscan.txt' )
363370 if not os .path .isfile (IPR_terms ):
364371 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 )
367374 GO_terms = os .path .join (outputdir , 'annotate_misc' , 'annotations.GO.txt' )
368375 if not os .path .isfile (GO_terms ):
369376 IPR2GO = os .path .join (parentdir , 'util' , 'ipr2go.py' )
370377 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 )
373380
374381
375382#check if antiSMASH data is given, if so parse and reformat for annotations and cluster textual output
@@ -409,7 +416,8 @@ def runIPRpython(Input):
409416#launch gag
410417GAG = os .path .join (outputdir , 'annotate_misc' , 'gag' )
411418lib .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 )
413421
414422#fix the tbl file for tRNA genes
415423lib .log .info ("Fixing tRNA annotations in GenBank tbl file" )
@@ -432,7 +440,8 @@ def runIPRpython(Input):
432440shutil .copyfile (os .path .join (GAG , 'genome.fasta' ), os .path .join (GAG , 'genome.fsa' ))
433441discrep = 'discrepency.report.txt'
434442lib .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 )
436445
437446#collected output files and rename accordingly
438447ResultsFolder = os .path .join (outputdir , 'annotate_results' )
@@ -451,9 +460,8 @@ def runIPRpython(Input):
451460lib .log .info ("Creating AGP file and corresponding contigs file" )
452461agp2fasta = os .path .join (parentdir , 'util' , 'fasta2agp.pl' )
453462AGP = 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 )
457465
458466#write secondary metabolite clusters output using the final genome in gbk format
459467if args .antismash :
@@ -474,7 +482,8 @@ def runIPRpython(Input):
474482 for record in SeqRecords :
475483 if record .id in AllProts :
476484 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 )
478487 #now parse blast results to get {qseqid: hit}
479488 MIBiGBlast = {}
480489 with open (mibig_blast , 'rU' ) as input :
0 commit comments