comparison velvetg_wrapper.py @ 0:08256557922f draft

planemo upload commit 4720b3dfa114d790b597fef6ccf3c17e8c11e111
author devteam
date Tue, 13 Oct 2015 16:38:28 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:08256557922f
1 #!/usr/bin/env python
2
3 """
4 Classes encapsulating decypher tool.
5 James E Johnson - University of Minnesota
6 """
7 import os
8 import sys
9 import subprocess
10
11 assert sys.version_info[:2] >= ( 2, 4 )
12
13 def stop_err( msg ):
14 sys.stderr.write( "%s\n" % msg )
15 sys.exit()
16
17
18 def __main__():
19 #Parse Command Line
20 working_dir = sys.argv[1]
21 inputs = ' '.join(sys.argv[2:])
22 for _ in ('Roadmaps', 'Sequences'):
23 os.symlink(os.path.join(working_dir, _), _)
24 cmdline = 'velvetg . %s' % (inputs)
25 print "Command to be executed: %s" % cmdline
26 try:
27 proc = subprocess.Popen( args=cmdline, shell=True, stderr=subprocess.PIPE )
28 returncode = proc.wait()
29 # get stderr, allowing for case where it's very large
30 stderr = ''
31 buffsize = 1048576
32 try:
33 while True:
34 stderr += proc.stderr.read( buffsize )
35 if not stderr or len( stderr ) % buffsize != 0:
36 break
37 except OverflowError:
38 pass
39 if returncode != 0:
40 raise Exception, stderr
41 except Exception, e:
42 stop_err( 'Error running velvetg ' + str( e ) )
43
44
45 if __name__ == "__main__":
46 __main__()