annotate query.py @ 16:ba9d0fc8657f draft

Uploaded 20190118
author fabio
date Fri, 18 Jan 2019 10:12:19 -0500
parents 9ec4acef30ed
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
1 #!/usr/bin/env python
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
2
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
3 # https://github.com/ross/requests-futures
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
4 # http://docs.python-requests.org/en/master/user/quickstart/#more-complicated-post-requests
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
5
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
6 import sys, os, uuid, optparse, requests, json, time
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
7 #from requests_futures.sessions import FuturesSession
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
8
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
9 #### NN14 ####
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
10 SERVICE_URL = "http://nn14.galaxyproject.org:8080/";
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
11 #service_url = "http://127.0.0.1:8082/";
4
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
12 QUERY_URL = SERVICE_URL+"tree/<tree_id>/query";
0
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
13 STATUS_URL = SERVICE_URL+"status/<query_id>";
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
14 ##############
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
15 # query delay in seconds
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
16 QUERY_DELAY = 30;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
17 ##############
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
18
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
19 __version__ = "1.0.0";
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
20 VALID_CHARS = '.-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
21 # in the case of collections, exitcodes equal to 0 and 1 are not considered errors
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
22 ERR_EXIT_CODE = 2;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
23 OK_EXIT_CODE = 0;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
24
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
25 def raiseException( exitcode, message, output_dir_path, errorfilename ):
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
26 errorfilepath = os.path.join(output_dir_path, errorfilename+"_txt");
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
27 with open(errorfilepath, 'w') as out:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
28 out.write(message);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
29 sys.exit(exitcode);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
30
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
31 def query_request( options, args, payload ):
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
32 output_dir_path = options.outputdir;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
33 # add additional parameters to the payload
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
34 #payload["tree_id"] = str(options.treeid);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
35 payload["search_mode"] = str(options.search);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
36 payload["exact_algorithm"] = int(options.exact);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
37 payload["search_threshold"] = float(options.sthreshold);
10
1af09c5ec0a1 Uploaded 20180413
fabio
parents: 8
diff changeset
38 payload["sort"] = int(options.sortcontrol);
0
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
39 # set the content type to application/json
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
40 headers = {'Content-type': 'application/json'};
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
41
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
42 # create a session
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
43 session = requests.Session();
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
44 # make a synchronous post request to the query route
4
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
45 req = session.post(QUERY_URL.replace("<tree_id>", str(options.treeid)), headers=headers, json=payload);
0
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
46 resp_code = req.status_code;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
47 #print(str(req.content)+"\n\n");
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
48 if resp_code == requests.codes.ok:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
49 resp_content = str(req.content);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
50 # convert out to json
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
51 json_content = json.loads(resp_content);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
52 # retrieve query id
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
53 query_id = json_content['query_id'];
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
54 query_processed = False;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
55 # results json content
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
56 json_status_content = None;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
57 while query_processed is False:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
58 # create a new session
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
59 session = requests.Session();
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
60 # make a synchronous get request to the status route
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
61 status_query_url = STATUS_URL.replace("<query_id>", query_id);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
62 status_req = session.get(status_query_url);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
63 status_resp_content = str(status_req.content);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
64 #print(status_resp_content+"\n\n");
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
65 # convert out to json
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
66 json_status_content = json.loads(status_resp_content);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
67 # take a look at the state
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
68 # state attribute is always available
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
69 if json_status_content['state'] == 'SUCCESS':
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
70 query_processed = True;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
71 break;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
72 elif json_status_content['state'] in ['FAILURE', 'REVOKED']:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
73 return raiseException( ERR_EXIT_CODE, "Query ID: "+str(query_id)+"\nQuery status: "+str(json_status_content['state']), output_dir_path, str(options.errorfile) );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
74 else:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
75 time.sleep(QUERY_DELAY); # in seconds
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
76
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
77 out_file_format = "tabular";
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
78 for block in json_status_content['results']:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
79 seq_id = block['sequence_id'];
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
80 # put response block in the output collection
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
81 output_file_path = os.path.join(output_dir_path, seq_id + "_" + out_file_format);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
82 accessions_list = "";
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
83 hits_block = block['hits'];
8
300e4932bad6 Uploaded 20180405
fabio
parents: 4
diff changeset
84 accessions_dict = { };
4
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
85 is_sabutan = False;
0
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
86 for hit in hits_block:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
87 if type(hit) is dict: # sabutan
4
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
88 #accessions_list = accessions_list + str(hit['accession_number']) + "\t" + str(hit['score']) + "\n";
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
89 accession_number = hit['accession_number'];
12
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
90 #------------
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
91 #score = hit['score'];
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
92 #score_split = score.split("/");
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
93 #accessions_dict[accession_number] = "{0:.6f}".format(float(score_split[0])/float(score_split[1]));
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
94 #------------
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
95 fraction = hit['fraction'];
4
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
96 score = hit['score'];
12
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
97 accession_scores = {
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
98 "fraction": str(fraction),
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
99 "score": float(score)
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
100 }
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
101 accessions_dict[accession_number] = accession_scores;
4
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
102 is_sabutan = True;
0
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
103 else: # all-some
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
104 accessions_list = accessions_list + str(hit) + "\n";
4
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
105 if is_sabutan:
12
19ac771cf32a Uploaded 20180414
fabio
parents: 10
diff changeset
106 sorted_accessions = sorted(accessions_dict, key=lambda i: float(accessions_dict[i]["score"]), reverse=True);
4
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
107 for acc in sorted_accessions:
14
9ec4acef30ed Uploaded 20180424
fabio
parents: 12
diff changeset
108 accessions_list = accessions_list + str(acc) + "\t" + str(accessions_dict[acc]["fraction"]) + "\t" + str(accessions_dict[acc]["score"]) + "\n";
0
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
109 with open(output_file_path, 'w') as out:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
110 out.write(accessions_list.strip());
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
111 return sys.exit(OK_EXIT_CODE);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
112 else:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
113 return raiseException( ERR_EXIT_CODE, "Unable to query the remote server. Please try again in a while.", output_dir_path, str(options.errorfile) );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
114
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
115 def query( options, args ):
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
116 output_dir_path = options.outputdir;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
117 multiple_data = {};
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
118 comma_sep_file_paths = options.files;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
119 #print("files: "+str(comma_sep_file_paths)+" - "+str(type(comma_sep_file_paths)));
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
120 # check if options.files contains at least one file path
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
121 if comma_sep_file_paths is not None:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
122 # split file paths
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
123 file_paths = comma_sep_file_paths.split(",");
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
124 # split file names
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
125 comma_sep_file_names = str(options.names);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
126 #print("names: "+str(comma_sep_file_names));
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
127 file_names = comma_sep_file_names.split(",");
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
128 for idx, file_path in enumerate(file_paths):
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
129 #file_name = file_names[idx];
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
130 with open(file_path, 'r') as content_file:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
131 for line in content_file:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
132 if line.strip() != "":
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
133 line_split = line.strip().split("\t"); # split on tab
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
134 if len(line_split) == 2: # 0:id , 1:seq , otherwise skip line
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
135 seq_id = line_split[0];
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
136 # fix seq_id using valid chars only
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
137 seq_id = ''.join(e for e in seq_id if e in VALID_CHARS)
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
138 seq_text = line_split[1];
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
139 if seq_id in multiple_data:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
140 return raiseException( ERR_EXIT_CODE, "Error: the id '"+seq_id+"' is duplicated", output_dir_path, str(options.errorfile) );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
141 multiple_data[seq_id] = seq_text;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
142 if len(multiple_data) > 0:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
143 return query_request( options, args, multiple_data );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
144 #return echo( options, args );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
145 else:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
146 return raiseException( ERR_EXIT_CODE, "An error has occurred. Please be sure that your input files are valid.", output_dir_path, str(options.errorfile) );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
147 else:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
148 # try with the sequence in --sequence
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
149 text_content = options.sequences;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
150 #print("sequences: "+text_content);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
151 # check if options.sequences contains a list of sequences (one for each row)
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
152 if text_content is not None:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
153 text_content = str(text_content);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
154 if text_content.strip():
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
155 # populate a dictionary with the files containing the sequences to query
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
156 text_content = text_content.strip().split("__cn__"); # split on new line
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
157 for line in text_content:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
158 if line.strip() != "":
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
159 line_split = line.strip().split("__tc__"); # split on tab
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
160 if len(line_split) == 2: # 0:id , 1:seq , otherwise skip line
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
161 seq_id = line_split[0];
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
162 # fix seq_id using valid chars only
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
163 seq_id = ''.join(e for e in seq_id if e in VALID_CHARS)
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
164 seq_text = line_split[1];
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
165 if seq_id in multiple_data:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
166 return raiseException( ERR_EXIT_CODE, "Error: the id '"+seq_id+"' is duplicated", output_dir_path, str(options.errorfile) );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
167 multiple_data[seq_id] = seq_text;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
168 if len(multiple_data) > 0:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
169 return query_request( options, args, multiple_data );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
170 #return echo( options, args );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
171 else:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
172 return raiseException( ERR_EXIT_CODE, "An error has occurred. Please be sure that your input files are valid.", output_dir_path, str(options.errorfile) );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
173 else:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
174 return raiseException( ERR_EXIT_CODE, "You have to insert at least one row formatted as a tab delimited (ID, SEQUENCE) couple", output_dir_path, str(options.errorfile) );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
175 return ERR_EXIT_CODE;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
176
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
177 def __main__():
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
178 # Parse the command line options
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
179 usage = "Usage: query.py --files comma_sep_file_paths --names comma_seq_file_names --sequences sequences_text --search search_mode --exact exact_alg --sthreshold threshold --outputdir output_dir_path";
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
180 parser = optparse.OptionParser(usage = usage);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
181 parser.add_option("-v", "--version", action="store_true", dest="version",
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
182 default=False, help="display version and exit")
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
183 parser.add_option("-f", "--files", type="string",
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
184 action="store", dest="files", help="comma separated files path");
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
185 parser.add_option("-n", "--names", type="string",
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
186 action="store", dest="names", help="comma separated names associated to the files specified in --files");
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
187 parser.add_option("-s", "--sequences", type="string",
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
188 action="store", dest="sequences", help="contains a list of sequences (one for each row)");
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
189 parser.add_option("-a", "--fasta", type="string",
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
190 action="store", dest="fasta", help="contains the content of a fasta file");
4
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
191 parser.add_option("-x", "--search", type="string", default="rrr",
0
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
192 action="store", dest="search", help="search mode");
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
193 parser.add_option("-e", "--exact", type="int", default=0,
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
194 action="store", dest="exact", help="exact algorithm (required if search is 1 only)");
16
ba9d0fc8657f Uploaded 20190118
fabio
parents: 14
diff changeset
195 parser.add_option("-k", "--tree", type="string", default=0,
4
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
196 action="store", dest="treeid", help="the id of the tree that will be queried");
0
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
197 parser.add_option("-t", "--sthreshold", type="float",
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
198 action="store", dest="sthreshold", help="threshold applied to the search algrithm");
10
1af09c5ec0a1 Uploaded 20180413
fabio
parents: 8
diff changeset
199 parser.add_option("-z", "--sort", type="int", default=1,
1af09c5ec0a1 Uploaded 20180413
fabio
parents: 8
diff changeset
200 action="store", dest="sortcontrol", help="boolean required to sort the result");
0
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
201 parser.add_option("-o", "--outputdir", type="string", default="output",
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
202 action="store", dest="outputdir", help="output directory (collection) path");
4
69a3505ac594 Uploaded 20180405
fabio
parents: 0
diff changeset
203 parser.add_option("-r", "--errorfile", type="string", default="error_txt",
0
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
204 action="store", dest="errorfile", help="error file name containing error messages");
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
205
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
206 # TEST
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
207 #sequences = 'NM_001169378.2__tc__atttcggatgctttggagggaggaactctagtgctgcattgattggggcgtgtgttaatgatattcccagttcgcatggcgagcatcgattcctggtacgtatgtgggccccttgactcccacttatcgcacttgtcgttcgcaatttgcatgaattccgcttcgtctgaaacgcacttgcgccagacttctccggctggtctgatctggtctgtgatccggtctggtggggcgccagttgcgtttcgagctcatcaccagtcactccgcagtcgcattctgccagaggtctccgatcaagagcgcttctccattcgagattcaaacgcagcgcggtctgacgccgccacatcgagtgaaatccatatcgatggccacattcacacaggacgagatcgacttcctgcgcagccatggcaacgagctgtgtgccaagacctggctgggattgtgggatccgaagcgggctgtgcaccagcaggagcagcgcgaactgatgatggacaagtatgagcggaagcgatactacctggagccggccagtcctcttaagtcgctggccaatgcggtcaacctgaagtcgtctgctccggcgacgaaccacactcagaatggccaccaaaatgggtatgccagcatccatttgacgcctcctgctgcccagcggacctcggccaatggattgcagaaggtggccaactcgtcgagtaactcttctggaaagacctcatcctcgatcagtaggccacactataatcaccagaacaacagccaaaacaacaatcacgatgcctttggcctgggtggcggattgagcagcctgaacagcgccggttccacatccactggagctctttccgacaccagcagttgtgctagcaatggcttcggtgcggactgcgactttgtggctgactttggctcggccaacattttcgacgccacatcggcgcgttccacaggatcgccggcggtgtcgtccgtgtcctcagtgggttccagcaatggctacgccaaggtgcagcccatccgggcagctcatctccagcagcaacagcagttgcagcagcagctgcatcagcagcagctcctcaatggcaatggtcatcagggcactgagaactttgccgacttcgatcacgctcccatctacaatgcagtggctccaccgacttttaacgattggatcagcgactggagcaggcggggcttccacgatcccttcgacgattgcgatgactcgccaccaggtgcccgccctccagcacctgcgccagctcctgctcaagttcccgcagtatcatcaccattgccaaccgtccgagaagaaccagagcttgcgtggaatttttgggaggacgagatgcgaatagaggcgcaggaaaaggagtcccaaactaaacagccggagttgggctactccttttcgattagtactactacgcccctttccccttcgaatcccttcctgccctaccttgtcagtgaggagcagcatcgaaatcatccagagaagccctccttttcgtattcgttgttcagctccatatcaaatagttcgcaagaagatcaggcggatgatcatgagatgaatgttttaaatgccaatttccatgatttctttacgtggagtgctcccttgcagaacggccatacgaccagtccgcccaagggcggaaatgcagcgatggcgcccagtgaggatcgatatgccgctcttaaggatctcgacgagcagctgcgagaactgaaggccagcgaaagcgccacagagacgcccacgcccaccagtggcaatgttcaggccacagatgcctttggtggagccctcaacaacaatccaaatcccttcaagggccagcaacagcagcagctcagcagccatgtggtgaatccattccagcagcagcaacagcagcagcaccagcagaatctctatggccagttgacgctcataccaaatgcctacggcagcagttcccagcagcagatggggcaccatctcctccagcagcagcagcagcaacagcagagcttcttcaacttcaacaacaacgggttcgccatctcgcagggtctgcccaacggctgcggcttcggcagcatgcaacccgctcctgtgatggccaacaatccctttgcagccagcggcgccatgaacaccaacaatccattcttatgagactcaacccgggagaatccgcctcgcgccacctggcagaggcgctgagccagcgaacaaagagcagacgcggaggaaccgaaccgaaattagtccattttactaacaatagcgttaatctatgtatacataatgcacgccggagagcactctttgtgtacatagcccaaatatgtacacccgaaaggctccacgctgacgctagtcctcgcggatggcggaggcggactggggcgttgatatattcttttacatggtaactctactctaacgtttacggatacggatatttgtatttgccgtttgccctagaactctatacttgtactaagcgcccatgaacacttcatccactaacatagctactaatcctcatcctagtggaggatgcagttggtccagacactctgttatttgttttatccatcctcgtacttgtctttgtcccatttagcactttcgttgcggataagaactttgtcagttattgattgtgtggccttaataagattataaaactaaatattataacgtacgactatacatatacggatacagatacagattcagacacagttagtacagatacagatatacatatacgcttttgtacctaatgaattgcttcttgtttccattgctaatcatctgcttttcgtgtgctaattttatacactagtacgtgcgatatcggccgtgcagatagattgctcagctcgcgagtcaagcctcttttggttgcacccacggcagacatttgtacatatactgtctgattgtaagcctcgtgtaatacctccattaacaccactcccccaccacccatccatcgaaccccgaatccatgactcaattcactgctcacatgtccatgcccatgccttaacgtgtcaaacattatcgaagccttaaagttatttaaaactacgaaatttcaataaaaacaaataagaacgctatc';
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
208 #(options, args) = parser.parse_args(['-x', 'rrr', '-t', 0.5, '-s', sequences, '-o', 'collection_content']);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
209
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
210 (options, args) = parser.parse_args();
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
211 if options.version:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
212 print __version__;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
213 else:
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
214 # create output dir (collection)
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
215 output_dir_path = options.outputdir;
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
216 if not os.path.exists(output_dir_path):
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
217 os.makedirs(output_dir_path);
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
218
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
219 return query( options, args );
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
220
315246810bfa Uploaded 20180404
fabio
parents:
diff changeset
221 if __name__ == "__main__": __main__()