Mercurial > repos > bgruening > upload_testing
comparison reverse.py @ 110:fa6ef7619bbd draft default tip
Uploaded
author | bgruening |
---|---|
date | Mon, 26 Jan 2015 13:10:16 -0500 |
parents | 89dd3b812906 |
children |
comparison
equal
deleted
inserted
replaced
109:89dd3b812906 | 110:fa6ef7619bbd |
---|---|
1 #!/usr/bin/env python | |
2 from os.path import join | |
3 import sys | |
4 from optparse import OptionParser | |
5 from ConfigParser import SafeConfigParser | |
6 import subprocess | |
7 | |
8 DEBUG = False | |
9 | |
10 def main(): | |
11 (options, args) = _parse_args() | |
12 _run_shell("cat '%s' > '%s'" % (options.input, options.output)) | |
13 _run_dbtoolkit("com.compomics.dbtoolkit.toolkit.ReverseFASTADB", "'%s' | head --lines -4 >> '%s'" % (options.input, options.output), options) | |
14 | |
15 | |
16 def _run_shell(command): | |
17 if DEBUG: | |
18 print "Running shell command %s" % command | |
19 _exec(command) | |
20 | |
21 | |
22 def _run_dbtoolkit(java_class, command, args): | |
23 command_prefix = "java -cp %s" % _dbtoolkit_jar_path( args.script_path ) | |
24 _exec("%s %s %s" % (command_prefix, java_class, command)) | |
25 | |
26 | |
27 def _dbtoolkit_jar_path( script_path ): | |
28 jar_path = join(script_path, "dbtoolkit-4.2", "dbtoolkit-4.2.jar") | |
29 return jar_path | |
30 | |
31 def _exec(command): | |
32 proc = subprocess.Popen(args=command, shell=True) | |
33 return_code = proc.wait() | |
34 if return_code != 0: | |
35 print "Error executing command [%s], return code is %d" % (command, return_code) | |
36 sys.exit(return_code) | |
37 | |
38 | |
39 def _parse_args(): | |
40 parser = OptionParser() | |
41 parser.add_option("-i", "--input") | |
42 parser.add_option("-o", "--output") | |
43 parser.add_option("-s", "--script_path") | |
44 return parser.parse_args() | |
45 | |
46 | |
47 if __name__ == "__main__": | |
48 main() |