@@ -6394,13 +6394,28 @@ def SystemInfo():
6394
6394
(system_os , multiprocessing .cpu_count (), MemoryCheck (), python_vers ))
6395
6395
6396
6396
6397
- def runtRNAscan (input , tmpdir , output , cpus = 1 ):
6397
+ def runtRNAscan (input , tmpdir , output , cpus = 1 , precalc = False ):
6398
6398
tRNAout = os .path .join (tmpdir , 'tRNAscan.out' )
6399
6399
tRNAlenOut = os .path .join (tmpdir , 'tRNAscan.len-filtered.out' )
6400
- if os .path .isfile (tRNAout ): # tRNAscan can't overwrite file, so check
6401
- os .remove (tRNAout )
6402
- cmd = ['tRNAscan-SE' , '-o' , tRNAout , '--thread' , str (cpus ), input ]
6403
- runSubprocess (cmd , '.' , log )
6400
+ if not precalc :
6401
+ if os .path .isfile (tRNAout ): # tRNAscan can't overwrite file, so check
6402
+ os .remove (tRNAout )
6403
+ cmd = ['tRNAscan-SE' , '-o' , tRNAout , '--thread' , str (cpus ), input ]
6404
+ log .debug (' ' .join (cmd ))
6405
+ proc = subprocess .Popen (cmd , stdout = subprocess .PIPE ,
6406
+ stderr = subprocess .PIPE )
6407
+ stdout , stderr = proc .communicate ()
6408
+ if proc .returncode != 0 :
6409
+ log .error ('CMD ERROR: {}' .format (' ' .join (cmd )))
6410
+ if stdout :
6411
+ log .debug (stdout .decode ("utf-8" ))
6412
+ if stderr :
6413
+ log .debug (stderr .decode ("utf-8" ))
6414
+ else :
6415
+ shutil .copyfile (precalc , tRNAout )
6416
+ if not checkannotations (tRNAout ):
6417
+ log .info ('tRNAscan-SE seems to have failed, check logfile for error. You can pass precalculated results to --trnascan' )
6418
+ return False
6404
6419
# enforce NCBI length rules
6405
6420
with open (tRNAlenOut , 'w' ) as lenOut :
6406
6421
with open (tRNAout , 'r' ) as infile :
@@ -6424,6 +6439,7 @@ def runtRNAscan(input, tmpdir, output, cpus=1):
6424
6439
trna2gff = os .path .join (parentdir , 'aux_scripts' , 'trnascan2gff3.pl' )
6425
6440
with open (output , 'w' ) as out :
6426
6441
subprocess .call (['perl' , trna2gff , '--input' , tRNAlenOut ], stdout = out )
6442
+ return True
6427
6443
6428
6444
6429
6445
def runtbl2asn (folder , template , discrepency , organism , isolate , strain , parameters , version ):
0 commit comments