annotate velvetg_wrapper.py @ 0:c170448acc8a draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
author devteam
date Mon, 09 Nov 2015 12:02:53 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
1 #!/usr/bin/env python
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
2
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
3 """
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
4 Classes encapsulating decypher tool.
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
5 James E Johnson - University of Minnesota
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
6 """
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
7 import os
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
8 import sys
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
9 import subprocess
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
10
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
11 assert sys.version_info[:2] >= ( 2, 4 )
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
12
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
13 def stop_err( msg ):
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
14 sys.stderr.write( "%s\n" % msg )
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
15 sys.exit()
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
16
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
17
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
18 def __main__():
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
19 #Parse Command Line
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
20 working_dir = sys.argv[1]
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
21 inputs = ' '.join(sys.argv[2:])
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
22 for _ in ('Roadmaps', 'Sequences'):
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
23 os.symlink(os.path.join(working_dir, _), _)
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
24 cmdline = 'velvetg . %s' % (inputs)
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
25 print "Command to be executed: %s" % cmdline
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
26 try:
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
27 proc = subprocess.Popen( args=cmdline, shell=True, stderr=subprocess.PIPE )
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
28 returncode = proc.wait()
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
29 # get stderr, allowing for case where it's very large
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
30 stderr = ''
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
31 buffsize = 1048576
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
32 try:
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
33 while True:
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
34 stderr += proc.stderr.read( buffsize )
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
35 if not stderr or len( stderr ) % buffsize != 0:
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
36 break
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
37 except OverflowError:
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
38 pass
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
39 if returncode != 0:
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
40 raise Exception, stderr
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
41 except Exception, e:
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
42 stop_err( 'Error running velvetg ' + str( e ) )
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
43
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
44
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
45 if __name__ == "__main__":
c170448acc8a planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/velvet commit 5a4e0ca9992af3a6e5ed2b533f04bb82ce761e0b
devteam
parents:
diff changeset
46 __main__()