[Biopython] subprocess.Popen problem
Mic
mictadlo at gmail.com
Thu Nov 3 03:16:19 UTC 2011
Thank you, I wrote the following code and not sure whether it is what did
write me. Is try/except necassary?
import sys,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,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
returncode = proc.wait()
print returncode
stdout_value, stderr_value = proc.communicate()
print '\tcombined output:', stdout_value, stderr_value
if returncode == 1:
sys.exit(1)
except Exception, e:
sys.stderr.write( "%s\n" % str(e))
sys.exit()
Thank you in advance.
On Wed, Nov 2, 2011 at 7:42 PM, Peter Cock <p.j.a.cock at googlemail.com>wrote:
> On Wed, Nov 2, 2011 at 9:03 AM, Mic <mictadlo at gmail.com> wrote:
> > Thank you, but is it possible to store the SOAP output in the
> memory/file in
> > order to retrieve the following statistics lines?
> > 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
> > Thank you in advance.
>
> Assuming that is written to stdout, just collect it as a pipe (handle)
> via subprocess, or since it is short, use the .communicate method
> and get this as a string.
>
> http://docs.python.org/library/subprocess.html
>
> Peter
>
More information about the Biopython
mailing list