2
|
1 #! /usr/bin/python
|
|
2 # -*- coding: utf8 -*-
|
|
3 """#Peak Motifs - developed by Jocelyn Brayet <jocelyn.brayet@curie.fr>
|
|
4 #Copyright (C) 2015 Institut Curie
|
|
5 #
|
|
6 #This program is free software: you can redistribute it and/or modify
|
|
7 #it under the terms of the GNU General Public License as published by
|
|
8 #the Free Software Foundation, either version 3 of the License, or
|
|
9 #(at your option) any later version.
|
|
10 #
|
|
11 #This program is distributed in the hope that it will be useful,
|
|
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 #GNU General Public License for more details.
|
|
15 #
|
|
16 #You should have received a copy of the GNU General Public License
|
|
17 #along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18 #
|
|
19 ###########################################################'
|
|
20 #
|
|
21 #Client to download peak-motifs results from RSAT server.
|
|
22 #
|
|
23 #
|
|
24 #usage: peak-motifs_soap.py [-h] -test <TEST_FILE> [-control <CONTROL_FILE>]
|
|
25 # [-max_seq_length <MAX_SEQ_LENGTH>]
|
|
26 # [-max_motif_number <MAX_MOTIF_NUMBER>]
|
|
27 # [-top_peaks <TOP_PEAKS>] [-min_length <MIN_LENGTH>]
|
|
28 # [-max_length <MAX_LENGTH>] [-markov <MARKOV_MODEL>]
|
|
29 # [-min_markov <MIN_MARKOV>]
|
|
30 # [-max_markov <MAX_MARKOV>] [-noov <NOOV_DETECTION>]
|
|
31 # [-class_int <CLASS_INT>] [-str <STR_SUMMED>]
|
|
32 # [-graph_title <GRAPH_TITLE>]
|
|
33 # [-image_format <IMAGE_FORMAT>]
|
|
34 # [-disco [<DISCO_ALGORITHM> [<DISCO_ALGORITHM> ...]]]
|
|
35 # [-source <SOURCE_FILE>] [-verb <VERBOSITY>]
|
|
36 # [-ref_motif <REF_MOTIF>] -server <SERVEUR>
|
|
37 #
|
|
38 #optional arguments:
|
|
39 # -h, --help show this help message and exit
|
|
40 # -test <TEST_FILE>, --test_file <TEST_FILE>
|
|
41 # Input test peak sequence in fasta format.
|
|
42 # -control <CONTROL_FILE>, --control_file <CONTROL_FILE>
|
|
43 # Input control peak sequence in fasta format.
|
|
44 # -max_seq_length <MAX_SEQ_LENGTH>, --maxSeqLength <MAX_SEQ_LENGTH>
|
|
45 # Maximal sequence length.
|
|
46 # -max_motif_number <MAX_MOTIF_NUMBER>, --maxMotifNumber <MAX_MOTIF_NUMBER>
|
|
47 # Maximal number of motifs (matrices) to return for
|
|
48 # pattern discovery algorithms.
|
|
49 # -top_peaks <TOP_PEAKS>, --topPeaks <TOP_PEAKS>
|
|
50 # Restrict the analysis to the N peaks at the top of the
|
|
51 # input sequence file.
|
|
52 # -min_length <MIN_LENGTH>, --minLength <MIN_LENGTH>
|
|
53 # Minimal oligonucleotide length.
|
|
54 # -max_length <MAX_LENGTH>, --maxLength <MAX_LENGTH>
|
|
55 # Maximal oligonucleotide length.
|
|
56 # -markov <MARKOV_MODEL>, --markovModel <MARKOV_MODEL>
|
|
57 # Order of the Markov model used to estimatd expected
|
|
58 # oligonucleotide frequencies for oligo-analysis and
|
|
59 # local-word-analysis.
|
|
60 # -min_markov <MIN_MARKOV>, --minMarkov <MIN_MARKOV>
|
|
61 # Minimal value for markov order. Use in combination
|
|
62 # with the next option (max_markov).
|
|
63 # -max_markov <MAX_MARKOV>, --maxMarkov <MAX_MARKOV>
|
|
64 # Maximal value for markov order. Use in combination
|
|
65 # with the previous option (min_markov).
|
|
66 # -noov <NOOV_DETECTION>, --noovDetection <NOOV_DETECTION>
|
|
67 # No overlapping of oligos allowed if value = 1.
|
|
68 # -class_int <CLASS_INT>, --classInt <CLASS_INT>
|
|
69 # Class interval for position-analysis. The width of the
|
|
70 # position classes, in number of bases (default: 20).
|
|
71 # -str <STR_SUMMED>, --strSummed <STR_SUMMED>
|
|
72 # Oligonucleotide occurrences found on both stands are
|
|
73 # summed (2) or not (1). Default is 2.
|
|
74 # -graph_title <GRAPH_TITLE>, --graphTitle <GRAPH_TITLE>
|
|
75 # Title displayed on top of the graphs.
|
|
76 # -image_format <IMAGE_FORMAT>, --imageFormat <IMAGE_FORMAT>
|
|
77 # Image format. All the formats supported by XYgraph can
|
|
78 # be used.
|
|
79 # -disco [<DISCO_ALGORITHM> [<DISCO_ALGORITHM> ...]], --discoAlgorithm [<DISCO_ALGORITHM> [<DISCO_ALGORITHM> ...]]
|
|
80 # Specify the software tool(s) that will be used for
|
|
81 # motif discovery
|
|
82 # (oligos|dyads|positions|local_words|merged_words).
|
|
83 # Several algorithms can be specified either by using a
|
|
84 # comma-separated list of algorithms: -disco
|
|
85 # oligos,dyads
|
|
86 # -source <SOURCE_FILE>, --sourceFile <SOURCE_FILE>
|
|
87 # Enter the source of the fasta sequence file. Supported
|
|
88 # source: galaxy
|
|
89 # -verb <VERBOSITY>, --verbosity <VERBOSITY>
|
|
90 # Verbosity.
|
|
91 # -ref_motif <REF_MOTIF>, --ref_motif <REF_MOTIF>
|
|
92 # Motif annotated in some transcription factor database
|
|
93 # (e.g. RegulonDB, Jaspar, TRANSFAC) for the
|
|
94 # transcription factor of interest.
|
|
95 # -server <SERVEUR>, --server <SERVEUR>
|
|
96 # RSAT server
|
|
97 # -outGalaxy <OUT_GALAXY>, --outGalaxy <OUT_GALAXY>
|
|
98 #
|
|
99 #Version 0.1 - 30/01/2015 - Adapted from Jocelyn Brayet, France Genomique team
|
|
100 #
|
|
101 ###########################################################"""
|
|
102 __author__ = 'Jocelyn Brayet'
|
|
103
|
|
104 ###########################################################'
|
|
105 ## Import
|
|
106
|
|
107 import argparse
|
|
108 import os
|
|
109 import urllib
|
|
110 import zipfile
|
|
111 import time
|
|
112 import platform
|
|
113 from suds.client import Client
|
|
114
|
|
115 ###########################################################'
|
|
116
|
|
117 ###########################################################'
|
|
118 ## Define log options for suds
|
|
119
|
|
120 # Import log package
|
|
121 #import logging
|
|
122
|
|
123 # Import log package
|
|
124 #import logging
|
|
125 # création de l'objet logger qui va nous servir à écrire dans les logs
|
|
126 #logger = logging.getLogger()
|
|
127 # on met le niveau du logger à DEBUG, comme ça il écrit tout
|
|
128 #logger.setLevel(logging.DEBUG)
|
|
129 # Configure log of suds clients to DEBUG for verbose output concerning Client request
|
|
130 #logging.getLogger('suds.client').setLevel(logging.ERROR)
|
|
131 #logging.getLogger('suds.transport').setLevel(logging.ERROR)
|
|
132 #logging.getLogger('suds.xsd.schema').setLevel(logging.ERROR)
|
|
133 #logging.getLogger('suds.wsdl').setLevel(logging.ERROR)
|
|
134
|
|
135
|
|
136 # création d'un second handler qui va rediriger chaque écriture de log
|
|
137 # sur la console
|
|
138 #steam_handler = logging.StreamHandler()
|
|
139 #steam_handler.setLevel(logging.DEBUG)
|
|
140 #logger.addHandler(steam_handler)
|
|
141
|
|
142 #logger.info('Hello')
|
|
143
|
|
144 #print(client.factory.create('peak_motifs'))
|
|
145
|
|
146 # (PeakMotifsRequest){
|
|
147 # output = None -> ok
|
|
148 # verbosity = None
|
|
149 # test = None -> ok
|
|
150 # tmp_test_infile = None
|
|
151 # control = None
|
|
152 # tmp_control_infile = None
|
|
153 # max_seq_length = None
|
|
154 # max_motif_number = None
|
|
155 # ref_motif = None
|
|
156 # top_peaks = None
|
|
157 # min_length = None
|
|
158 # max_length = None
|
|
159 # markov = None
|
|
160 # min_markov = None
|
|
161 # max_markov = None
|
|
162 # noov = None
|
|
163 # class_int = None
|
|
164 # str = None
|
|
165 # graph_title = None
|
|
166 # image_format = None
|
|
167 # disco = None
|
|
168 # source = None
|
|
169 # task = None
|
|
170 # }
|
|
171 # }
|
|
172
|
|
173
|
|
174 ################################ functions ############################################################
|
|
175 ## Define a function to make a service perform the desired request using provided arguments
|
|
176 def call_run_service(service, args):
|
|
177 """
|
|
178 Run job in RSAT server.
|
|
179 service -> RSAT web service
|
|
180 args -> web service request
|
|
181 """
|
|
182
|
|
183 result = rsat_service.peak_motifs(args)
|
|
184 return result
|
|
185
|
|
186 def testNone(argument):
|
|
187 """
|
|
188 Test if argument is None or not.
|
|
189 argument -> argument give by user
|
|
190 """
|
|
191
|
|
192 if not argument is None:
|
|
193 variable = argument[0]
|
|
194 else:
|
|
195 variable = ""
|
|
196 return variable
|
|
197
|
|
198
|
|
199 ###########################################################'
|
50
|
200 ## Functions to recup results
|
2
|
201
|
|
202 def buildZipUrl(algoResults):
|
|
203 """
|
|
204 Recup results give by RSAT server.
|
50
|
205 algoResults -> response gave by RSAT server
|
2
|
206 """
|
|
207
|
|
208 recupResult = str(algoResults)
|
|
209 tabResults=recupResult.split("\n")
|
|
210 urlZip = tabResults[4].replace("\t","")
|
|
211
|
|
212 return urlZip
|
|
213
|
50
|
214 def recupRSATResult(urlResult,nameFile):
|
|
215
|
|
216 """
|
|
217 Recup results give by RSAT server.
|
|
218 urlResult -> URL gave by RSAT server
|
|
219 nameFile -> name of zip file in Galaxy path
|
|
220 """
|
|
221
|
|
222 ###########################################################'
|
|
223 ## Download RSAT results
|
|
224 urllib.urlretrieve(urlResult, nameFile)
|
|
225 #except IOError:
|
|
226 #logFile.write("\nResult URL is false")
|
|
227 #Logger.error("Result URL is false")
|
|
228 #logFile.write("\n"+nameFile+"\n")
|
|
229
|
|
230 ###########################################################'
|
|
231 ## Decompress results
|
|
232 #try:
|
|
233 zfile = zipfile.ZipFile(nameFile, 'r')
|
|
234 #except IOError:
|
|
235 #logFile.write("No zip file")
|
|
236 #Logger.error("No zip file")
|
|
237
|
|
238 tempflag = 0
|
|
239 folderName =""
|
|
240
|
|
241 for i in zfile.namelist(): ## On parcourt l'ensemble des fichiers de l'archive
|
|
242
|
|
243 #logFile.write(i+"\n")
|
|
244 ###############################
|
|
245 if tempflag ==0:
|
|
246 folderName = i
|
|
247
|
|
248 tempflag = 1
|
|
249 ###############################
|
|
250
|
|
251 if i.endswith('/'): ## S'il s'agit d'un repertoire, on se contente de creer le dossier
|
|
252 os.makedirs(i)
|
|
253 else:
|
|
254 data = zfile.read(i) ## lecture du fichier compresse
|
|
255 fp = open(i, "wb") ## creation en local du nouveau fichier
|
|
256 fp.write(data) ## ajout des donnees du fichier compresse dans le fichier local
|
|
257 fp.close()
|
|
258 zfile.close()
|
|
259
|
|
260 return folderName
|
2
|
261
|
|
262 ## Tested with python 2.6.6
|
50
|
263 peakMotifsVersion = '2.0 - 30/01/2015'
|
2
|
264
|
|
265 ###########################################################'
|
|
266 # server dictionary
|
|
267 serverDict = {
|
|
268
|
|
269 "fr_ens":"http://rsat01.biologie.ens.fr/rsat/web_services/RSATWS.wsdl",
|
|
270 "fr_mrs":"http://rsat-tagc.univ-mrs.fr/rsat/web_services/RSATWS.wsdl",
|
|
271 "fr_ro":"http://rsat.sb-roscoff.fr/web_services/RSATWS.wsdl",
|
|
272 "fr_mrs_2":"http://pedagogix-tagc.univ-mrs.fr/rsat/web_services/RSATWS.wsdl",
|
|
273 "es":"http://floresta.eead.csic.es/rsat/web_services/RSATWS.wsdl",
|
|
274 "mx":"http://embnet.ccg.unam.mx/rsa-tools/web_services/RSATWS.wsdl"
|
|
275
|
|
276 }
|
|
277
|
|
278 """
|
|
279 serverDict = {
|
|
280
|
|
281 "fr_ens":"http://protists.rsat.eu/rsat/web_services/RSATWS.wsdl",
|
|
282 "fr_mrs":"http://fungi.rsat.eu/rsat/web_services/RSATWS.wsdl",
|
|
283 "fr_ro":"http://metazoa.rsat.eu/web_services/RSATWS.wsdl",
|
|
284 "fr_mrs_2":"http://teaching.rsat.eu/rsat/web_services/RSATWS.wsdl",
|
|
285 "es":"http://plants.rsat.eu/rsat/web_services/RSATWS.wsdl",
|
|
286 "mx":"http://prokaryotes.rsat.eu/rsa-tools/web_services/RSATWS.wsdl"
|
|
287
|
|
288 }
|
|
289 """
|
|
290
|
|
291 if __name__ == '__main__':
|
|
292
|
|
293 ########### peak motifs arguments ####################
|
|
294 parser = argparse.ArgumentParser(description='Client to download peak-motifs results from RSAT server.', epilog='Version '+peakMotifsVersion)
|
|
295
|
|
296 parser.add_argument('-test', '--test_file', metavar='<TEST_FILE>', type=argparse.FileType('r'), nargs=1, help='Input test peak sequence in fasta format.', required=True)
|
|
297 parser.add_argument('-control', '--control_file', metavar='<CONTROL_FILE>', type=argparse.FileType('r'), nargs=1, help='Input control peak sequence in fasta format.', required=False)
|
|
298 parser.add_argument('-max_seq_length', '--maxSeqLength', metavar='<MAX_SEQ_LENGTH>', type=int, nargs=1, help='Maximal sequence length.', required=False)
|
|
299 parser.add_argument('-max_motif_number', '--maxMotifNumber', metavar='<MAX_MOTIF_NUMBER>', type=int, nargs=1, help='Maximal number of motifs (matrices) to return for pattern discovery algorithms.', required=False)
|
|
300 parser.add_argument('-top_peaks', '--topPeaks', metavar='<TOP_PEAKS>', type=int, nargs=1, help='Restrict the analysis to the N peaks at the top of the input sequence file.', required=False)
|
|
301 parser.add_argument('-min_length', '--minLength', metavar='<MIN_LENGTH>', type=int, nargs=1, help='Minimal oligonucleotide length.', required=False)
|
|
302 parser.add_argument('-max_length', '--maxLength', metavar='<MAX_LENGTH>', type=int, nargs=1, help='Maximal oligonucleotide length.', required=False)
|
|
303 parser.add_argument('-markov', '--markovModel', metavar='<MARKOV_MODEL>', type=int, nargs=1, help='Order of the Markov model used to estimatd expected oligonucleotide frequencies for oligo-analysis and local-word-analysis.', required=False)
|
|
304 parser.add_argument('-min_markov', '--minMarkov', metavar='<MIN_MARKOV>', type=int, nargs=1, help='Minimal value for markov order. Use in combination with the next option (max_markov).', required=False)
|
|
305 parser.add_argument('-max_markov', '--maxMarkov', metavar='<MAX_MARKOV>', type=int, nargs=1, help='Maximal value for markov order. Use in combination with the previous option (min_markov).', required=False)
|
|
306 parser.add_argument('-noov', '--noovDetection', metavar='<NOOV_DETECTION>', type=int, nargs=1, help='No overlapping of oligos allowed if value = 1.', required=False)
|
|
307 parser.add_argument('-class_int', '--classInt', metavar='<CLASS_INT>', type=int, nargs=1, help='Class interval for position-analysis. The width of the position classes, in number of bases (default: 20).', required=False)
|
|
308 parser.add_argument('-str', '--strSummed', metavar='<STR_SUMMED>', type=int, nargs=1, help='Oligonucleotide occurrences found on both stands are summed (2) or not (1). Default is 2.', required=False)
|
|
309 parser.add_argument('-graph_title', '--graphTitle', metavar='<GRAPH_TITLE>', type=str, nargs=1, help='Title displayed on top of the graphs.', required=False)
|
|
310 parser.add_argument('-image_format', '--imageFormat', metavar='<IMAGE_FORMAT>', type=str, nargs=1, help='Image format. All the formats supported by XYgraph can be used.', required=False)
|
|
311 parser.add_argument('-disco', '--discoAlgorithm', metavar='<DISCO_ALGORITHM>', type=str, nargs='*', help='Specify the software tool(s) that will be used for motif discovery (oligos|dyads|positions|local_words|merged_words). Several algorithms can be specified either by using a comma-separated list of algorithms: -disco oligos,dyads', required=False)
|
|
312 parser.add_argument('-source', '--sourceFile', metavar='<SOURCE_FILE>', type=str, nargs=1, help='Enter the source of the fasta sequence file. Supported source: galaxy', required=False)
|
|
313 parser.add_argument('-verb', '--verbosity', metavar='<VERBOSITY>', type=int, nargs=1, help='Verbosity.', required=False)
|
|
314 parser.add_argument('-ref_motif', '--ref_motif', metavar='<REF_MOTIF>', type=argparse.FileType('r'), nargs=1, help='Motif annotated in some transcription factor database (e.g. RegulonDB, Jaspar, TRANSFAC) for the transcription factor of interest.', required=False)
|
|
315 parser.add_argument('-motif_db', '--motif_db', metavar='<MOTIF_DB>', type=str, nargs=1, help='Name of motif database.', required=False)
|
|
316
|
|
317 ################################ galaxy arguments ############################################################
|
|
318 parser.add_argument('-outGalaxy', '--outGalaxy', metavar='<OUT_GALAXY>', type=str, nargs=1, required=True)
|
|
319 parser.add_argument('-outGalaxy2', '--outGalaxy2', metavar='<OUT_GALAXY2>', type=str, nargs=1, required=False)
|
|
320 parser.add_argument('-server', '--server', metavar='<SERVEUR>', type=str, nargs=1, help='RSAT server', required=True)
|
|
321 ###########################################################'
|
|
322
|
|
323 args = parser.parse_args()
|
|
324
|
|
325 ###########################################################
|
|
326 ## Test arguments
|
|
327
|
|
328 fasta_test_file = args.test_file[0].read()
|
|
329
|
|
330 if not args.control_file is None :
|
|
331 fasta_control_file = args.control_file[0].read()
|
|
332 else :
|
|
333 fasta_control_file =""
|
|
334
|
|
335 if not args.ref_motif is None :
|
|
336 refMotifValue = args.ref_motif[0].read()
|
|
337 else :
|
|
338 refMotifValue =""
|
|
339
|
|
340 maxSeqLengthValue = testNone(args.maxSeqLength)
|
|
341 maxMotifNumberValue = testNone(args.maxMotifNumber)
|
|
342 topPeaksNumber = testNone(args.topPeaks)
|
|
343 minLengthNumber = testNone(args.minLength)
|
|
344 maxLengthNumber = testNone(args.maxLength)
|
|
345 markovModelValue = testNone(args.markovModel)
|
|
346 minMarkovValue = testNone(args.minMarkov)
|
|
347 maxMarkovValue = testNone(args.maxMarkov)
|
|
348 noovValue = testNone(args.noovDetection)
|
|
349 classIntValue = testNone(args.classInt)
|
|
350 strSummedValue = testNone(args.strSummed)
|
|
351 graphTitleValue = testNone(args.graphTitle)
|
|
352 imageFormatValue = testNone(args.imageFormat)
|
|
353 discoAlgorithmValue = testNone(args.discoAlgorithm)
|
|
354 sourceFileValue = testNone(args.sourceFile)
|
|
355 verbosityValue = testNone(args.verbosity)
|
|
356 motifdbValue = testNone(args.motif_db)
|
|
357 outGalaxyValue = testNone(args.outGalaxy)
|
|
358 outGalaxyValue2 = testNone(args.outGalaxy2)
|
|
359 serverValue = testNone(args.server)
|
|
360
|
|
361 ###########################################################'
|
|
362 ## Create the SOAP client to request the RSAT service
|
|
363
|
|
364 # Define URL for RSAT services
|
|
365 url = serverDict[serverValue]
|
|
366 print url
|
|
367
|
|
368 # Create the client
|
|
369 client = Client(url)
|
|
370
|
|
371 # Need service interface to perform requests
|
|
372 rsat_service = client.service
|
|
373
|
|
374 # Define client header
|
|
375 userAgent = 'RSAT-Client/v%s (%s; Python %s; %s)' % (
|
|
376 peakMotifsVersion,
|
|
377 os.path.basename( __file__ ),
|
|
378 platform.python_version(),
|
|
379 platform.system()
|
|
380 )
|
|
381
|
|
382 httpHeaders = {'User-agent': userAgent}
|
|
383 client.set_options(headers=httpHeaders)
|
|
384 client.set_options(timeout=300)
|
|
385
|
|
386
|
|
387 ###########################################################'
|
|
388 ## Create request
|
|
389 peakMotifsRequest = {
|
|
390
|
|
391 'test' : fasta_test_file,
|
|
392 'control' : fasta_control_file,
|
|
393 'max_seq_length' : maxSeqLengthValue,
|
|
394 'max_motif_number' : maxMotifNumberValue,
|
|
395 'top_peaks' : topPeaksNumber,
|
|
396 'min_length' : minLengthNumber,
|
|
397 'max_length' : maxLengthNumber,
|
|
398 'markov' : markovModelValue,
|
|
399 'min_markov' : minMarkovValue,
|
|
400 'max_markov' : maxMarkovValue,
|
|
401 'noov' : noovValue,
|
|
402 'class_int' : classIntValue,
|
|
403 'str' : strSummedValue,
|
|
404 'graph_title' : graphTitleValue,
|
|
405 'image_format' : imageFormatValue,
|
|
406 'disco' : discoAlgorithmValue,
|
|
407 'source' : sourceFileValue,
|
|
408 'ref_motif' : refMotifValue,
|
|
409 'verbosity' : verbosityValue,
|
|
410 'motif_db' : motifdbValue
|
|
411 #'output' : 'blablabla'
|
|
412
|
|
413 }
|
|
414
|
|
415
|
|
416 ###########################################################'
|
|
417 ## Run job in RSAT server
|
|
418 result = call_run_service(rsat_service, peakMotifsRequest)
|
|
419
|
|
420 #logFile = open("/bioinfo/users/jbrayet/Bureau/peak_motifs.log","w")
|
|
421
|
|
422 #logFile.write("###############################################\n")
|
|
423 #logFile.write("Command performed on server\n")
|
|
424 #logFile.write(result.command)
|
|
425 #logFile.write("\n")
|
|
426 #logFile.write("###############################################\n")
|
|
427 #logFile.write("Result\n")
|
|
428 #logFile.write(result.server)
|
|
429
|
|
430 print("###############################################\n")
|
|
431 print("Command performed on server\n")
|
|
432 print(result.command)
|
|
433 print("\n")
|
|
434 print("###############################################\n")
|
|
435 print("Result\n")
|
|
436 print(result.server)
|
|
437
|
|
438 ###########################################################'
|
|
439 ## Build result URL
|
|
440
|
|
441 """
|
|
442 zipFileDict = {
|
|
443
|
|
444 "fr_ens":"http://protists.rsat.eu/rsat/",
|
|
445 "fr_mrs":"http://fungi.rsat.eu/rsat/",
|
|
446 "fr_ro":"http://metazoa.rsat.eu/",
|
|
447 "fr_mrs_2":"http://teaching.rsat.eu/rsat/",
|
|
448 "es":"http://plants.rsat.eu/rsat/",
|
|
449 "mx":"http://prokaryotes.rsat.eu/rsa-tools/"
|
|
450
|
|
451 }
|
|
452 """
|
|
453
|
|
454 nameFile = "peak-motifs_results.zip"
|
|
455 urlResult=buildZipUrl(result.server)
|
|
456 print urlResult
|
|
457
|
|
458 #ogFile.write("\n"+urlResult)
|
|
459
|
|
460 ###########################################################'
|
|
461 ## Wait RSAT server
|
|
462 while urllib.urlopen(urlResult).getcode() != 200:
|
|
463 #logFile.write(str(urllib.urlopen(urlResult).getcode())+"\n")
|
|
464 time.sleep(5)
|
|
465
|
|
466 #logFile.write(str(nameFile)+"\n")
|
50
|
467 #time.sleep(5)
|
2
|
468 #while urllib.urlretrieve(urlResult, nameFile)
|
|
469 #try:
|
|
470
|
50
|
471 folderName=recupRSATResult(urlResult,nameFile)
|
2
|
472
|
50
|
473 while(not(os.path.exists(folderName+"peak-motifs_synthesis.html"))):
|
|
474 os.popen("rm -rf "+folderName)
|
|
475 recupRSATResult(urlResult,nameFile)
|
2
|
476
|
|
477 #logFile.write("\n"+folderName+"\n")
|
|
478 #logFile.write("\n"+outGalaxyValue+"\n")
|
|
479
|
|
480 os.popen("cp "+folderName+"peak-motifs_synthesis.html "+outGalaxyValue)
|
|
481 os.popen("cp "+nameFile+" "+folderName)
|
|
482 #logFile.close()
|
|
483 #os.popen("sed -i \"1iHHEELLLOOO\" "+outGalaxyValue)
|
|
484 #os.popen("sed -i \"1i<style type=\'text/css\'></style>\" "+outGalaxyValue)
|
|
485
|
|
486 ###########################################################'
|
|
487 ##Create results folder name
|
|
488 outGalaxyValueDir = outGalaxyValue.replace(".dat","_files")
|
|
489
|
|
490 #logFile.write("\noutGalaxyValueDir : " +outGalaxyValueDir)
|
|
491
|
|
492 #logFile.close()
|
|
493
|
|
494 # Create results folder
|
|
495 os.popen("mkdir "+outGalaxyValueDir)
|
|
496
|
|
497 # Copy results files in results folder
|
|
498 os.popen("cp -R "+folderName+"data " + outGalaxyValueDir+"/data")
|
|
499 os.popen("cp -R "+folderName+"reports " + outGalaxyValueDir+"/reports")
|
|
500 os.popen("cp -R "+folderName+"results " + outGalaxyValueDir+"/results")
|
|
501
|
|
502 if not outGalaxyValue2 =="":
|
|
503 os.popen("cp "+folderName+"results/sites/peak-motifs_all_motifs_seqcoord.bed "+outGalaxyValue2)
|
|
504
|
|
505
|
|
506
|
|
507
|
|
508
|
|
509
|
|
510
|