[Biopython] subprocess.Popen problem
Peter Cock
p.j.a.cock at googlemail.com
Wed Nov 2 08:52:19 UTC 2011
On Wed, Nov 2, 2011 at 4:39 AM, Mic <mictadlo at gmail.com> wrote:
> Hello,
> I have tried to write a SOAPaligner wrapper in oder to get the SOAP
> alignment statistics:
>
> Total Pairs: 1000 PE
> Paired: 35 ( 3.50%) PE
> Singled: 170 ( 8.50%) SE
> Total Elapsed Time: 24.00
> - Load Index Table: 23.22
> - Alignment: 0.78
>
> with the following code:
>
> import os, subprocess
> if __name__ == '__main__':
> try:
> cmd_soap = 'soap -p 1 -a test_A_clonesremoved-tiny.fastq -b
> test_B_clonesremoved-tiny.fastq -D all.m.fasta.index -r 0 -o
> test_clonesremoved-tiny_vs_all.m.paired.soap -2
> test_clonesremoved-tiny_vs_all.m.single.soap -m 100 -x 550'
> proc = subprocess.Popen(cmd_soap, shell=True)
> returncode = proc.wait()
> print returncode
> except Exception, e:
> sys.stderr.write( "%s\n" % str(e))
> sys.exit()
>
>
> However, when I started the script I just got 0 as an output:
>
> $ python soap_wrapper.py
>
> Begin Program SOAPaligner/soap2
> Wed Nov 2 14:23:33 2011
> Reference: all.m.fasta.index
> Query File a: test_A_clonesremoved-tiny.fastq
> Query File b: test_B_clonesremoved-tiny.fastq
> Output File: test_clonesremoved-tiny_vs_all.m.paired.soap
> test_clonesremoved-tiny_vs_all.m.single.soap
> Load Index Table ...
> Load Index Table OK
> Begin Alignment ...
> 2000 ok 0.76 sec
> Total Pairs: 1000 PE
> Paired: 35 ( 3.50%) PE
> Singled: 170 ( 8.50%) SE
> Total Elapsed Time: 24.00
> - Load Index Table: 23.22
> - Alignment: 0.78
>
> SOAPaligner/soap2 End
> Wed Nov 2 14:23:57 2011
>
> 0
>
> What did I wrong?
>
> Thank you in advance.
>
Command line tools typically return 0 for success, anything else
is usually an error code. You can double check the return code
from the command line outside Python - e.g. a quick shell script
to call the command and echo the return code to the terminal.
Peter
More information about the Biopython
mailing list