Mercurial > repos > peterjc > tmhmm_and_signalp
comparison tools/protein_analysis/signalp3.py @ 26:20139cb4c844 draft
planemo upload for repository https://github.com/peterjc/pico_galaxy/tools/protein_analysis commit 221d4187992cbb993e02dc3ea0ef0150c7916a4a-dirty
author | peterjc |
---|---|
date | Wed, 13 May 2015 06:14:42 -0400 |
parents | 391a142c1e60 |
children | 3cb02adf4326 |
comparison
equal
deleted
inserted
replaced
25:41a42022f815 | 26:20139cb4c844 |
---|---|
54 the predictors which gives a cleavage site). *WORK IN PROGRESS* | 54 the predictors which gives a cleavage site). *WORK IN PROGRESS* |
55 """ | 55 """ |
56 import sys | 56 import sys |
57 import os | 57 import os |
58 import tempfile | 58 import tempfile |
59 from seq_analysis_utils import stop_err, split_fasta, fasta_iterator | 59 from seq_analysis_utils import sys_exit, split_fasta, fasta_iterator |
60 from seq_analysis_utils import run_jobs, thread_count | 60 from seq_analysis_utils import run_jobs, thread_count |
61 | 61 |
62 FASTA_CHUNK = 500 | 62 FASTA_CHUNK = 500 |
63 MAX_LEN = 6000 #Found by trial and error | 63 MAX_LEN = 6000 #Found by trial and error |
64 | 64 |
65 if len(sys.argv) not in [6,8]: | 65 if len(sys.argv) not in [6,8]: |
66 stop_err("Require five (or 7) arguments, organism, truncate, threads, " | 66 sys_exit("Require five (or 7) arguments, organism, truncate, threads, " |
67 "input protein FASTA file & output tabular file (plus " | 67 "input protein FASTA file & output tabular file (plus " |
68 "optionally cut method and GFF3 output file). " | 68 "optionally cut method and GFF3 output file). " |
69 "Got %i arguments." % (len(sys.argv)-1)) | 69 "Got %i arguments." % (len(sys.argv)-1)) |
70 | 70 |
71 organism = sys.argv[1] | 71 organism = sys.argv[1] |
72 if organism not in ["euk", "gram+", "gram-"]: | 72 if organism not in ["euk", "gram+", "gram-"]: |
73 stop_err("Organism argument %s is not one of euk, gram+ or gram-" % organism) | 73 sys_exit("Organism argument %s is not one of euk, gram+ or gram-" % organism) |
74 | 74 |
75 try: | 75 try: |
76 truncate = int(sys.argv[2]) | 76 truncate = int(sys.argv[2]) |
77 except: | 77 except: |
78 truncate = 0 | 78 truncate = 0 |
79 if truncate < 0: | 79 if truncate < 0: |
80 stop_err("Truncate argument %s is not a positive integer (or zero)" % sys.argv[2]) | 80 sys_exit("Truncate argument %s is not a positive integer (or zero)" % sys.argv[2]) |
81 | 81 |
82 num_threads = thread_count(sys.argv[3], default=4) | 82 num_threads = thread_count(sys.argv[3], default=4) |
83 fasta_file = sys.argv[4] | 83 fasta_file = sys.argv[4] |
84 tabular_file = sys.argv[5] | 84 tabular_file = sys.argv[5] |
85 | 85 |
86 if len(sys.argv) == 8: | 86 if len(sys.argv) == 8: |
87 cut_method = sys.argv[6] | 87 cut_method = sys.argv[6] |
88 if cut_method not in ["NN_Cmax", "NN_Ymax", "NN_Smax", "HMM_Cmax"]: | 88 if cut_method not in ["NN_Cmax", "NN_Ymax", "NN_Smax", "HMM_Cmax"]: |
89 stop_err("Invalid cut method %r" % cut_method) | 89 sys_exit("Invalid cut method %r" % cut_method) |
90 gff3_file = sys.argv[7] | 90 gff3_file = sys.argv[7] |
91 else: | 91 else: |
92 cut_method = None | 92 cut_method = None |
93 gff3_file = None | 93 gff3_file = None |
94 | 94 |
195 output = open(temp).readline() | 195 output = open(temp).readline() |
196 except IOError: | 196 except IOError: |
197 output = "(no output)" | 197 output = "(no output)" |
198 if error_level or output.lower().startswith("error running"): | 198 if error_level or output.lower().startswith("error running"): |
199 clean_up(fasta_files + temp_files) | 199 clean_up(fasta_files + temp_files) |
200 stop_err("One or more tasks failed, e.g. %i from %r gave:\n%s" % (error_level, cmd, output), | 200 sys_exit("One or more tasks failed, e.g. %i from %r gave:\n%s" % (error_level, cmd, output), |
201 error_level) | 201 error_level) |
202 del results | 202 del results |
203 | 203 |
204 out_handle = open(tabular_file, "w") | 204 out_handle = open(tabular_file, "w") |
205 fields = ["ID"] | 205 fields = ["ID"] |