Mercurial > repos > peterjc > blast2go
annotate blast2go/blast2go.py @ 6:872cf247c899 draft
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
author | peterjc |
---|---|
date | Mon, 23 Sep 2013 05:50:58 -0400 |
parents | |
children |
rev | line source |
---|---|
6
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
2 """Galaxy wrapper for Blast2GO for pipelines, b2g4pipe v2.5. |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
3 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
4 This script takes exactly three command line arguments: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
5 * Input BLAST XML filename |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
6 * Blast2GO properties filename (settings file) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
7 * Output tabular filename |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
8 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
9 The properties filename can be a fully qualified path, but if not |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
10 this will look next to the blast2go.jar file. |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
11 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
12 Sadly b2g4pipe (at least v2.3.5 to v2.5.0) cannot cope with current |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
13 style large BLAST XML files (e.g. from BLAST 2.2.25+), so we reformat |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
14 these to avoid it crashing with a Java heap space OutOfMemoryError. |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
15 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
16 As part of this reformatting, we check for BLASTP or BLASTX output |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
17 (otherwise raise an error), and print the query count. |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
18 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
19 It then calls the Java command line tool, and moves the output file to |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
20 the location Galaxy is expecting, and removes the tempory XML file. |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
21 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
22 This script is called from my Galaxy wrapper for Blast2GO for pipelines, |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
23 available from the Galaxy Tool Shed here: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
24 http://toolshed.g2.bx.psu.edu/view/peterjc/blast2go |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
25 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
26 This script is under version control here: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
27 https://github.com/peterjc/galaxy_blast/tree/master/blast2go |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
28 """ |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
29 import sys |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
30 import os |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
31 import subprocess |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
32 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
33 #You may need to edit this to match your local setup, |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
34 blast2go_dir = os.environ.get("B2G4PIPE", "/opt/b2g4pipe_v2.5/") |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
35 blast2go_jar = os.path.join(blast2go_dir, "blast2go.jar") |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
36 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
37 def stop_err(msg, error_level=1): |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
38 """Print error message to stdout and quit with given error level.""" |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
39 sys.stderr.write("%s\n" % msg) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
40 sys.exit(error_level) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
41 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
42 try: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
43 from massage_xml_for_blast2go import prepare_xml |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
44 except ImportError: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
45 stop_err("Missing sister file massage_xml_for_blast2go.py") |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
46 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
47 if len(sys.argv) != 4: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
48 stop_err("Require three arguments: XML filename, properties filename, output tabular filename") |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
49 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
50 xml_file, prop_file, tabular_file = sys.argv[1:] |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
51 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
52 #We should have write access here: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
53 tmp_xml_file = tabular_file + ".tmp.xml" |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
54 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
55 if not os.path.isfile(blast2go_jar): |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
56 stop_err("Blast2GO JAR file not found: %s" % blast2go_jar) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
57 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
58 if not os.path.isfile(xml_file): |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
59 stop_err("Input BLAST XML file not found: %s" % xml_file) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
60 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
61 if not os.path.isfile(prop_file): |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
62 tmp = os.path.join(os.path.split(blast2go_jar)[0], prop_file) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
63 if os.path.isfile(tmp): |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
64 #The properties file seems to have been given relative to the JAR |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
65 prop_file = tmp |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
66 else: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
67 stop_err("Blast2GO configuration file not found: %s" % prop_file) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
68 del tmp |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
69 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
70 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
71 def run(cmd): |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
72 #Avoid using shell=True when we call subprocess to ensure if the Python |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
73 #script is killed, so too is the child process. |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
74 try: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
75 child = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
76 except Exception, err: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
77 stop_err("Error invoking command:\n%s\n\n%s\n" % (" ".join(cmd), err)) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
78 #Use .communicate as can get deadlocks with .wait(), |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
79 stdout, stderr = child.communicate() |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
80 return_code = child.returncode |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
81 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
82 #keep stdout minimal as shown prominently in Galaxy |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
83 #Record it in case a silent error needs diagnosis |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
84 if stdout: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
85 sys.stderr.write("Standard out:\n%s\n\n" % stdout) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
86 if stderr: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
87 sys.stderr.write("Standard error:\n%s\n\n" % stderr) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
88 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
89 error_msg = None |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
90 if return_code: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
91 cmd_str = " ".join(cmd) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
92 error_msg = "Return code %i from command:\n%s" % (return_code, cmd_str) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
93 elif "Database or network connection (timeout) error" in stdout+stderr: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
94 error_msg = "Database or network connection (timeout) error" |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
95 elif "Annotation of 0 seqs with 0 annots finished." in stdout+stderr: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
96 error_msg = "No sequences processed!" |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
97 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
98 if error_msg: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
99 print error_msg |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
100 stop_err(error_msg) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
101 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
102 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
103 blast2go_classpath = os.path.split(blast2go_jar)[0] |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
104 assert os.path.isdir(blast2go_classpath) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
105 blast2go_classpath = "%s/*:%s/ext/*:" % (blast2go_classpath, blast2go_classpath) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
106 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
107 prepare_xml(xml_file, tmp_xml_file) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
108 #print "XML file prepared for Blast2GO" |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
109 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
110 #We will have write access wherever the output should be, |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
111 #so we'll ask Blast2GO to use that as the stem for its output |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
112 #(it will append .annot to the filename) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
113 cmd = ["java", "-cp", blast2go_classpath, "es.blast2go.prog.B2GAnnotPipe", |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
114 "-in", tmp_xml_file, |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
115 "-prop", prop_file, |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
116 "-out", tabular_file, #Used as base name for output files |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
117 "-annot", # Generate *.annot tabular file |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
118 #NOTE: For v2.3.5 must use -a, for v2.5 must use -annot instead |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
119 #"-img", # Generate images, feature not in v2.3.5 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
120 ] |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
121 #print " ".join(cmd) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
122 run(cmd) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
123 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
124 #Remove the temp XML file |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
125 os.remove(tmp_xml_file) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
126 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
127 out_file = tabular_file + ".annot" |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
128 if not os.path.isfile(out_file): |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
129 stop_err("ERROR - No output annotation file from Blast2GO") |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
130 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
131 #Move the output file where Galaxy expects it to be: |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
132 os.rename(out_file, tabular_file) |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
133 |
872cf247c899
Uploaded v0.0.8, auto-installation, RST README, MIT licence, citation information, development moved to GitHub, split out XML formatter into standalone script
peterjc
parents:
diff
changeset
|
134 print "Done" |