[Biopython] samtools does not return correct exit code
Mic
mictadlo at gmail.com
Thu Mar 1 01:40:02 UTC 2012
Hallo,
Samtools does not return correct the exit code:
import subprocess
import logging
import sys
def run_cmd(args):
if subprocess.call(args,shell=True) != 0:
print 'hello'
logging.error("Error copying sequence file args='%s'" %
str(args))
return 1
print 'e', sys.stderr
print 'o', sys.stdout
return 0
def runSamtools( cmd ):
'''run a samtools command'''
try:
retcode = subprocess.call(cmd, shell=True)
print retcode
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
except OSError, e:
print >>sys.stderr, "Execution failed:", e
print run_cmd("samtools faidx ex1.fa")
print runSamtools("samtools faidx ex1.fa")
print 'Hello still alive'
and as output I got:
$ python p3.py
open: No such file or directory
[_razf_open] fail to open ex1.fa
[fai_build] fail to open the FASTA file ex1.fa
e <open file '<stderr>', mode 'w' at 0x7ffa4658d270>
o <open file '<stdout>', mode 'w' at 0x7ffa4658d1e0>
0
open: No such file or directory
[_razf_open] fail to open ex1.fa
[fai_build] fail to open the FASTA file ex1.fa
0
None
Hello still alive
How can I get sure that all samtools commands were executed successfully?
Thank you in advance.
More information about the Biopython
mailing list