Mercurial > repos > peterjc > effectivet3
annotate tools/effectiveT3/effectiveT3.py @ 35:e2711662802b draft default tip
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
author | peterjc |
---|---|
date | Fri, 22 Feb 2019 10:13:22 -0500 |
parents | 011cfce866f1 |
children |
rev | line source |
---|---|
2 | 1 #!/usr/bin/env python |
2 """Wrapper for EffectiveT3 v1.0.1 for use in Galaxy. | |
3 | |
4 This script takes exactly five command line arguments: | |
5 * model name (e.g. TTSS_STD-1.0.1.jar) | |
6 * threshold (selective or sensitive) | |
7 * an input protein FASTA filename | |
8 * output tabular filename | |
9 | |
10 It then calls the standalone Effective T3 v1.0.1 program (not the | |
11 webservice), and reformats the semi-colon separated output into | |
12 tab separated output for use in Galaxy. | |
13 """ | |
14 import os | |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
15 |
32
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
16 # We want to be able to use shutil.which, but need Python 3.3+ |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
17 # import shutil |
2 | 18 import subprocess |
25
69ba0f4e91af
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit 5fb6ee31f33e8e24c1ae5d56c93ac3e0157dad72-dirty
peterjc
parents:
24
diff
changeset
|
19 import sys |
2 | 20 |
32
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
21 # The Galaxy auto-install via tool_dependencies.xml will set the |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
22 # environment variable $EFFECTIVET3 pointing at the folder with |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
23 # the JAR file. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
24 # |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
25 # The BioConda recipe will put a wrapper script on the $PATH, |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
26 # which we can use to find the JAR file. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
27 # |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
28 # We fall back on /opt/EffectiveT3/ |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
29 # |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
30 effective_t3_jarname = "TTSS_GUI-1.0.1.jar" |
2 | 31 |
32 if "-v" in sys.argv or "--version" in sys.argv: | |
15
17fbf8b8a554
Uploaded v0.0.13, embed citation, relax test for floating point differences
peterjc
parents:
9
diff
changeset
|
33 # TODO - Get version of the JAR file dynamically? |
32
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
34 print("Wrapper v0.0.20, for %s" % effective_t3_jarname) |
2 | 35 sys.exit(0) |
36 | |
37 if len(sys.argv) != 5: | |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
38 sys.exit( |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
39 "Require four arguments: model, threshold, input protein " |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
40 "FASTA file & output tabular file" |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
41 ) |
2 | 42 |
43 model, threshold, fasta_file, tabular_file = sys.argv[1:] | |
44 | |
45 if not os.path.isfile(fasta_file): | |
23 | 46 sys.exit("Input FASTA file not found: %s" % fasta_file) |
2 | 47 |
24
a3d660e900b1
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit 7a746d55f0e8456992ee11c49a507285f9f39383-dirty
peterjc
parents:
23
diff
changeset
|
48 if threshold not in ["selective", "sensitive"] and not threshold.startswith("cutoff="): |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
49 sys.exit( |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
50 "Threshold should be selective, sensitive, or cutoff=..., not %r" % threshold |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
51 ) |
23 | 52 |
2 | 53 |
54 def clean_tabular(raw_handle, out_handle): | |
55 """Clean up Effective T3 output to make it tabular.""" | |
56 count = 0 | |
57 positive = 0 | |
58 errors = 0 | |
59 for line in raw_handle: | |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
60 if ( |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
61 not line |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
62 or line.startswith("#") |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
63 or line.startswith("Id; Description; Score;") |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
64 ): |
2 | 65 continue |
66 assert line.count(";") >= 3, repr(line) | |
15
17fbf8b8a554
Uploaded v0.0.13, embed citation, relax test for floating point differences
peterjc
parents:
9
diff
changeset
|
67 # Normally there will just be three semi-colons, however the |
17fbf8b8a554
Uploaded v0.0.13, embed citation, relax test for floating point differences
peterjc
parents:
9
diff
changeset
|
68 # original FASTA file's ID or description might have had |
17fbf8b8a554
Uploaded v0.0.13, embed citation, relax test for floating point differences
peterjc
parents:
9
diff
changeset
|
69 # semi-colons in it as well, hence the following hackery: |
2 | 70 try: |
23 | 71 id_descr, score, effective = line.rstrip("\r\n").rsplit(";", 2) |
15
17fbf8b8a554
Uploaded v0.0.13, embed citation, relax test for floating point differences
peterjc
parents:
9
diff
changeset
|
72 # Cope when there was no FASTA description |
2 | 73 if "; " not in id_descr and id_descr.endswith(";"): |
74 id = id_descr[:-1] | |
75 descr = "" | |
76 else: | |
23 | 77 id, descr = id_descr.split("; ", 1) |
2 | 78 except ValueError: |
23 | 79 sys.exit("Problem parsing line:\n%s\n" % line) |
2 | 80 parts = [s.strip() for s in [id, descr, score, effective]] |
81 out_handle.write("\t".join(parts) + "\n") | |
82 count += 1 | |
83 if float(score) < 0: | |
23 | 84 errors += 1 |
2 | 85 if effective.lower() == "true": |
23 | 86 positive += 1 |
2 | 87 return count, positive, errors |
88 | |
23 | 89 |
2 | 90 def run(cmd): |
27
af14f755c05b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit 7496128ee9ef800fe780e545d2157da8a4f89d35-dirty
peterjc
parents:
25
diff
changeset
|
91 """Run the command line string via subprocess.""" |
15
17fbf8b8a554
Uploaded v0.0.13, embed citation, relax test for floating point differences
peterjc
parents:
9
diff
changeset
|
92 # Avoid using shell=True when we call subprocess to ensure if the Python |
17fbf8b8a554
Uploaded v0.0.13, embed citation, relax test for floating point differences
peterjc
parents:
9
diff
changeset
|
93 # script is killed, so too is the child process. |
2 | 94 try: |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
95 child = subprocess.Popen( |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
96 cmd, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
97 ) |
29
35c358aa7801
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit 37d5b47ec23e2cbaa453cc660bb1fcbb10dd34ee-dirty
peterjc
parents:
27
diff
changeset
|
98 except Exception as err: |
23 | 99 sys.exit("Error invoking command:\n%s\n\n%s\n" % (" ".join(cmd), err)) |
15
17fbf8b8a554
Uploaded v0.0.13, embed citation, relax test for floating point differences
peterjc
parents:
9
diff
changeset
|
100 # Use .communicate as can get deadlocks with .wait(), |
2 | 101 stdout, stderr = child.communicate() |
102 return_code = child.returncode | |
18 | 103 if return_code or stderr.startswith("Exception in thread"): |
23 | 104 cmd_str = " ".join(cmd) # doesn't quote spaces etc |
2 | 105 if stderr and stdout: |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
106 sys.exit( |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
107 "Return code %i from command:\n%s\n\n%s\n\n%s" |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
108 % (return_code, cmd_str, stdout, stderr) |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
109 ) |
2 | 110 else: |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
111 sys.exit( |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
112 "Return code %i from command:\n%s\n%s" % (return_code, cmd_str, stderr) |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
113 ) |
2 | 114 |
18 | 115 |
32
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
116 try: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
117 from shutil import which |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
118 except ImportError: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
119 # Likely running on Python 2, use backport: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
120 def which(cmd, mode=os.F_OK | os.X_OK, path=None): |
34
011cfce866f1
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit 3ab3d1a9650dec0533344d710ceb027e482d2b10-dirty
peterjc
parents:
32
diff
changeset
|
121 """Python implementation of command line tool which. |
011cfce866f1
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit 3ab3d1a9650dec0533344d710ceb027e482d2b10-dirty
peterjc
parents:
32
diff
changeset
|
122 |
011cfce866f1
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit 3ab3d1a9650dec0533344d710ceb027e482d2b10-dirty
peterjc
parents:
32
diff
changeset
|
123 Given a command, mode, and a PATH string, return the path which |
32
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
124 conforms to the given mode on the PATH, or None if there is no such |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
125 file. |
34
011cfce866f1
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit 3ab3d1a9650dec0533344d710ceb027e482d2b10-dirty
peterjc
parents:
32
diff
changeset
|
126 |
32
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
127 `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
128 of os.environ.get("PATH"), or can be overridden with a custom search |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
129 path. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
130 """ |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
131 # Check that a given file can be accessed with the correct mode. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
132 # Additionally check that `file` is not a directory, as on Windows |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
133 # directories pass the os.access check. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
134 def _access_check(fn, mode): |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
135 return os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn) |
32
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
136 |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
137 # Short circuit. If we're given a full path which matches the mode |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
138 # and it exists, we're done here. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
139 if _access_check(cmd, mode): |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
140 return cmd |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
141 |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
142 path = (path or os.environ.get("PATH", os.defpath)).split(os.pathsep) |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
143 |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
144 if sys.platform == "win32": |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
145 # The current directory takes precedence on Windows. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
146 if os.curdir not in path: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
147 path.insert(0, os.curdir) |
2 | 148 |
32
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
149 # PATHEXT is necessary to check on Windows. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
150 pathext = os.environ.get("PATHEXT", "").split(os.pathsep) |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
151 # See if the given file matches any of the expected path extensions. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
152 # This will allow us to short circuit when given "python.exe". |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
153 matches = [cmd for ext in pathext if cmd.lower().endswith(ext.lower())] |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
154 # If it does match, only test that one, otherwise we have to try |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
155 # others. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
156 files = [cmd] if matches else [cmd + ext.lower() for ext in pathext] |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
157 else: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
158 # On other platforms you don't have things like PATHEXT to tell you |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
159 # what file suffixes are executable, so just pass on cmd as-is. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
160 files = [cmd] |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
161 |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
162 seen = set() |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
163 for dir in path: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
164 dir = os.path.normcase(dir) |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
165 if dir not in seen: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
166 seen.add(dir) |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
167 for thefile in files: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
168 name = os.path.join(dir, thefile) |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
169 if _access_check(name, mode): |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
170 return name |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
171 return None |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
172 |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
173 |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
174 # Try in order the following to find the JAR file: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
175 # - Location of any wrapper script, e.g. from BioConda installation |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
176 # - The $EFFECTIVET3 env var, e.g. old-style Galaxy tool installation |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
177 # - The /opt/EffectiveT3/ folder. |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
178 effective_t3_jar = None |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
179 effective_t3_dir = None |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
180 dirs = ["/opt/EffectiveT3/"] |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
181 if "EFFECTIVET3" in os.environ: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
182 dirs.insert(0, os.environ.get("EFFECTIVET3")) |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
183 if which("effectivet3"): |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
184 # Assuming this is a BioConda installed wrapper for effective T3, |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
185 # this will get the directory of the wrapper script which is where |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
186 # the JAR file will be: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
187 dirs.insert(0, os.path.split(os.path.realpath(which("effectivet3")))[0]) |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
188 for effective_t3_dir in dirs: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
189 effective_t3_jar = os.path.join(effective_t3_dir, effective_t3_jarname) |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
190 if os.path.isfile(effective_t3_jar): |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
191 # Good |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
192 break |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
193 effective_t3_jar = None |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
194 if not effective_t3_dir or not effective_t3_jar: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
195 sys.exit("Effective T3 JAR file %r not found in %r" % (effective_t3_jarname, dirs)) |
2 | 196 |
23 | 197 if not os.path.isdir(os.path.join(effective_t3_dir, "module")): |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
198 sys.exit( |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
199 "Effective T3 module folder not found: %r" |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
200 % os.path.join(effective_t3_dir, "module") |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
201 ) |
9
b863c4bec840
Uploaded v0.0.11, take 10, debug output if module folder missing
peterjc
parents:
8
diff
changeset
|
202 |
23 | 203 effective_t3_model = os.path.join(effective_t3_dir, "module", model) |
204 if not os.path.isfile(effective_t3_model): | |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
205 sys.stderr.write( |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
206 "Contents of %r is %s\n" |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
207 % ( |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
208 os.path.join(effective_t3_dir, "module"), |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
209 ", ".join( |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
210 repr(p) for p in os.listdir(os.path.join(effective_t3_dir, "module")) |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
211 ), |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
212 ) |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
213 ) |
23 | 214 sys.stderr.write("Main JAR was found: %r\n" % effective_t3_jar) |
215 sys.exit("Effective T3 model JAR file not found: %r" % effective_t3_model) | |
2 | 216 |
30
007e86eff414
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit 7ea917a606c9226a0c902504f963577c8986d4a5-dirty
peterjc
parents:
29
diff
changeset
|
217 # We will have write access wherever the output should be, |
32
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
218 if tabular_file == "/dev/stdout": |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
219 temp_file = os.path.abspath("effectivet3_tabular_output.tmp") |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
220 else: |
1129cafdf0ae
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit b557cc18c85dcc5147b80c71f99c16a7015e12b2-dirty
peterjc
parents:
31
diff
changeset
|
221 temp_file = os.path.abspath(tabular_file + ".tmp") |
2 | 222 |
15
17fbf8b8a554
Uploaded v0.0.13, embed citation, relax test for floating point differences
peterjc
parents:
9
diff
changeset
|
223 # Use absolute paths since will change current directory... |
2 | 224 tabular_file = os.path.abspath(tabular_file) |
225 fasta_file = os.path.abspath(fasta_file) | |
226 | |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
227 cmd = [ |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
228 "java", |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
229 "-jar", |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
230 effective_t3_jar, |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
231 "-f", |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
232 fasta_file, |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
233 "-m", |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
234 model, |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
235 "-t", |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
236 threshold, |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
237 "-o", |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
238 temp_file, |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
239 "-q", |
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
240 ] |
2 | 241 |
242 try: | |
15
17fbf8b8a554
Uploaded v0.0.13, embed citation, relax test for floating point differences
peterjc
parents:
9
diff
changeset
|
243 # Must run from directory above the module subfolder: |
23 | 244 os.chdir(effective_t3_dir) |
245 except Exception: | |
246 sys.exit("Could not change to Effective T3 folder: %s" % effective_t3_dir) | |
2 | 247 |
248 run(cmd) | |
249 | |
250 if not os.path.isfile(temp_file): | |
23 | 251 sys.exit("ERROR - No output file from Effective T3") |
2 | 252 |
253 out_handle = open(tabular_file, "w") | |
254 out_handle.write("#ID\tDescription\tScore\tEffective\n") | |
255 data_handle = open(temp_file) | |
256 count, positive, errors = clean_tabular(data_handle, out_handle) | |
257 data_handle.close() | |
258 out_handle.close() | |
259 | |
260 os.remove(temp_file) | |
261 | |
262 if errors: | |
35
e2711662802b
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/effectiveT3 commit d67596914a7bbe183851437eaafe8c7305877e5a-dirty
peterjc
parents:
34
diff
changeset
|
263 print("%i sequences, %i positive, %i errors" % (count, positive, errors)) |
2 | 264 else: |
23 | 265 print("%i/%i sequences positive" % (positive, count)) |
2 | 266 |
23 | 267 if count and count == errors: |
268 # Galaxy will still allow them to see the output file | |
269 sys.exit("All your sequences gave an error code") |