Showing
1 changed file
with
35 additions
and
250 deletions
... | @@ -25,6 +25,7 @@ modulespath = biorseoDir + "/data/modules" | ... | @@ -25,6 +25,7 @@ modulespath = biorseoDir + "/data/modules" |
25 | HLmotifDir = modulespath + "/BGSU/HL/3.2/lib" | 25 | HLmotifDir = modulespath + "/BGSU/HL/3.2/lib" |
26 | ILmotifDir = modulespath + "/BGSU/IL/3.2/lib" | 26 | ILmotifDir = modulespath + "/BGSU/IL/3.2/lib" |
27 | descfolder = modulespath + "/DESC" | 27 | descfolder = modulespath + "/DESC" |
28 | +tempDir = "temp/" | ||
28 | 29 | ||
29 | # Parse options | 30 | # Parse options |
30 | try: | 31 | try: |
... | @@ -84,12 +85,6 @@ class Loop: | ... | @@ -84,12 +85,6 @@ class Loop: |
84 | self.type = looptype | 85 | self.type = looptype |
85 | self.position = position | 86 | self.position = position |
86 | 87 | ||
87 | - def get_header(self): | ||
88 | - return self.header | ||
89 | - | ||
90 | - def subsequence(self): | ||
91 | - return self.seq | ||
92 | - | ||
93 | 88 | ||
94 | class InsertionSite: | 89 | class InsertionSite: |
95 | def __init__(self, loop, csv_line): | 90 | def __init__(self, loop, csv_line): |
... | @@ -151,177 +146,6 @@ class RNA: | ... | @@ -151,177 +146,6 @@ class RNA: |
151 | self.biorseoBGSUBayesPairD = [] | 146 | self.biorseoBGSUBayesPairD = [] |
152 | self.biorseoBGSUBayesPairB = [] | 147 | self.biorseoBGSUBayesPairB = [] |
153 | 148 | ||
154 | - def get_RNAsubopt_results(self): | ||
155 | - rna = open(self.outputf + self.basename + ".subopt", "r") | ||
156 | - lines = rna.readlines() | ||
157 | - rna.close() | ||
158 | - for i in range(2, len(lines)): | ||
159 | - ss = lines[i].split(' ')[0] | ||
160 | - if ss not in self.rnasubopt.predictions: | ||
161 | - self.rnasubopt.predictions.append(ss) | ||
162 | - | ||
163 | - def get_biorseoBayesPairA_results(self, targetdir): | ||
164 | - if path.isfile(targetdir+ self.basename + ".bypA"): | ||
165 | - rna = open(targetdir+ self.basename + ".bypA", "r") | ||
166 | - lines = rna.readlines() | ||
167 | - rna.close() | ||
168 | - for i in range(2, len(lines)): | ||
169 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
170 | - if ss not in self.biorseoBayesPairA.predictions: | ||
171 | - self.biorseoBayesPairA.predictions.append(ss) | ||
172 | - self.biorseoBayesPairA.ninsertions.append(lines[i].count('+')) | ||
173 | - | ||
174 | - def get_biorseoBayesPairB_results(self, targetdir): | ||
175 | - if path.isfile(targetdir+ self.basename + ".bypB"): | ||
176 | - rna = open(targetdir+ self.basename + ".bypB", "r") | ||
177 | - lines = rna.readlines() | ||
178 | - rna.close() | ||
179 | - for i in range(2, len(lines)): | ||
180 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
181 | - if ss not in self.biorseoBayesPairB.predictions: | ||
182 | - self.biorseoBayesPairB.predictions.append(ss) | ||
183 | - self.biorseoBayesPairB.ninsertions.append(lines[i].count('+')) | ||
184 | - | ||
185 | - def get_biorseoBayesPairC_results(self, targetdir): | ||
186 | - if path.isfile(targetdir+ self.basename + ".bypC"): | ||
187 | - rna = open(targetdir+ self.basename + ".bypC", "r") | ||
188 | - lines = rna.readlines() | ||
189 | - rna.close() | ||
190 | - for i in range(2, len(lines)): | ||
191 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
192 | - if ss not in self.biorseoBayesPairC.predictions: | ||
193 | - self.biorseoBayesPairC.predictions.append(ss) | ||
194 | - self.biorseoBayesPairC.ninsertions.append(lines[i].count('+')) | ||
195 | - | ||
196 | - def get_biorseoBayesPairD_results(self, targetdir): | ||
197 | - if path.isfile(targetdir+ self.basename + ".bypD"): | ||
198 | - rna = open(targetdir+ self.basename + ".bypD", "r") | ||
199 | - lines = rna.readlines() | ||
200 | - rna.close() | ||
201 | - for i in range(2, len(lines)): | ||
202 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
203 | - if ss not in self.biorseoBayesPairD.predictions: | ||
204 | - self.biorseoBayesPairD.predictions.append(ss) | ||
205 | - self.biorseoBayesPairD.ninsertions.append(lines[i].count('+')) | ||
206 | - | ||
207 | - def get_biorseoRawA_results(self, targetdir): | ||
208 | - if path.isfile(targetdir+ self.basename + ".rawA"): | ||
209 | - rna = open(targetdir+ self.basename + ".rawA", "r") | ||
210 | - lines = rna.readlines() | ||
211 | - rna.close() | ||
212 | - for i in range(2, len(lines)): | ||
213 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
214 | - if ss not in self.biorseoRawA.predictions: | ||
215 | - self.biorseoRawA.predictions.append(ss) | ||
216 | - self.biorseoRawA.ninsertions.append(lines[i].count('+')) | ||
217 | - | ||
218 | - def get_biorseoRawB_results(self, targetdir): | ||
219 | - if path.isfile(targetdir+ self.basename + ".rawB"): | ||
220 | - rna = open(targetdir+ self.basename + ".rawB", "r") | ||
221 | - lines = rna.readlines() | ||
222 | - rna.close() | ||
223 | - for i in range(2, len(lines)): | ||
224 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
225 | - if ss not in self.biorseoRawB.predictions: | ||
226 | - self.biorseoRawB.predictions.append(ss) | ||
227 | - self.biorseoRawB.ninsertions.append(lines[i].count('+')) | ||
228 | - | ||
229 | - def get_biorseoBGSUJAR3DA_results(self, targetdir): | ||
230 | - if path.isfile(targetdir+ self.basename + ".jar3dA"): | ||
231 | - rna = open(targetdir+ self.basename + ".jar3dA", "r") | ||
232 | - lines = rna.readlines() | ||
233 | - rna.close() | ||
234 | - for i in range(2, len(lines)): | ||
235 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
236 | - if ss not in self.biorseoBGSUJAR3DA.predictions: | ||
237 | - self.biorseoBGSUJAR3DA.predictions.append(ss) | ||
238 | - self.biorseoBGSUJAR3DA.ninsertions.append(lines[i].count('+')) | ||
239 | - | ||
240 | - def get_biorseoBGSUJAR3DB_results(self, targetdir): | ||
241 | - if path.isfile(targetdir+ self.basename + ".jar3dB"): | ||
242 | - rna = open(targetdir+ self.basename + ".jar3dB", "r") | ||
243 | - lines = rna.readlines() | ||
244 | - rna.close() | ||
245 | - for i in range(2, len(lines)): | ||
246 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
247 | - if ss not in self.biorseoBGSUJAR3DB.predictions: | ||
248 | - self.biorseoBGSUJAR3DB.predictions.append(ss) | ||
249 | - self.biorseoBGSUJAR3DB.ninsertions.append(lines[i].count('+')) | ||
250 | - | ||
251 | - def get_biorseoBGSUJAR3DC_results(self, targetdir): | ||
252 | - if path.isfile(targetdir+ self.basename + ".jar3dC"): | ||
253 | - rna = open(targetdir+ self.basename + ".jar3dC", "r") | ||
254 | - lines = rna.readlines() | ||
255 | - rna.close() | ||
256 | - for i in range(2, len(lines)): | ||
257 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
258 | - if ss not in self.biorseoBGSUJAR3DC.predictions: | ||
259 | - self.biorseoBGSUJAR3DC.predictions.append(ss) | ||
260 | - self.biorseoBGSUJAR3DC.ninsertions.append(lines[i].count('+')) | ||
261 | - | ||
262 | - def get_biorseoBGSUJAR3DD_results(self, targetdir): | ||
263 | - if path.isfile(targetdir+ self.basename + ".jar3dD"): | ||
264 | - rna = open(targetdir+ self.basename + ".jar3dD", "r") | ||
265 | - lines = rna.readlines() | ||
266 | - rna.close() | ||
267 | - for i in range(2, len(lines)): | ||
268 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
269 | - if ss not in self.biorseoBGSUJAR3DD.predictions: | ||
270 | - self.biorseoBGSUJAR3DD.predictions.append(ss) | ||
271 | - self.biorseoBGSUJAR3DD.ninsertions.append(lines[i].count('+')) | ||
272 | - | ||
273 | - def get_biorseoBGSUBayesPairA_results(self, targetdir): | ||
274 | - if path.isfile(targetdir+ self.basename + ".bgsubypA"): | ||
275 | - rna = open(targetdir+ self.basename + ".bgsubypA", "r") | ||
276 | - lines = rna.readlines() | ||
277 | - rna.close() | ||
278 | - for i in range(2, len(lines)): | ||
279 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
280 | - if ss not in self.biorseoBGSUBayesPairA.predictions: | ||
281 | - self.biorseoBGSUBayesPairA.predictions.append(ss) | ||
282 | - self.biorseoBGSUBayesPairA.ninsertions.append(lines[i].count('+')) | ||
283 | - # else: | ||
284 | - # print(targetdir+ self.basename + ".bgsubypA not found !") | ||
285 | - | ||
286 | - def get_biorseoBGSUBayesPairB_results(self, targetdir): | ||
287 | - if path.isfile(targetdir+ self.basename + ".bgsubypB"): | ||
288 | - rna = open(targetdir+ self.basename + ".bgsubypB", "r") | ||
289 | - lines = rna.readlines() | ||
290 | - rna.close() | ||
291 | - for i in range(2, len(lines)): | ||
292 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
293 | - if ss not in self.biorseoBGSUBayesPairB.predictions: | ||
294 | - self.biorseoBGSUBayesPairB.predictions.append(ss) | ||
295 | - self.biorseoBGSUBayesPairB.ninsertions.append(lines[i].count('+')) | ||
296 | - # else: | ||
297 | - # print(targetdir+ self.basename + ".bgsubypB not found !") | ||
298 | - | ||
299 | - def get_biorseoBGSUBayesPairC_results(self, targetdir): | ||
300 | - if path.isfile(targetdir+ self.basename + ".bgsubypC"): | ||
301 | - rna = open(targetdir+ self.basename + ".bgsubypC", "r") | ||
302 | - lines = rna.readlines() | ||
303 | - rna.close() | ||
304 | - for i in range(2, len(lines)): | ||
305 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
306 | - if ss not in self.biorseoBGSUBayesPairC.predictions: | ||
307 | - self.biorseoBGSUBayesPairC.predictions.append(ss) | ||
308 | - self.biorseoBGSUBayesPairC.ninsertions.append(lines[i].count('+')) | ||
309 | - # else: | ||
310 | - # print(targetdir+ self.basename + ".bgsubypC not found !") | ||
311 | - | ||
312 | - def get_biorseoBGSUBayesPairD_results(self, targetdir): | ||
313 | - if path.isfile(targetdir+ self.basename + ".bgsubypD"): | ||
314 | - rna = open(targetdir+ self.basename + ".bgsubypD", "r") | ||
315 | - lines = rna.readlines() | ||
316 | - rna.close() | ||
317 | - for i in range(2, len(lines)): | ||
318 | - ss = lines[i].split(' ')[0].split('\t')[0] | ||
319 | - if ss not in self.biorseoBGSUBayesPairD.predictions: | ||
320 | - self.biorseoBGSUBayesPairD.predictions.append(ss) | ||
321 | - self.biorseoBGSUBayesPairD.ninsertions.append(lines[i].count('+')) | ||
322 | - # else: | ||
323 | - # print(targetdir+ self.basename + ".bgsubypD not found !") | ||
324 | - | ||
325 | 149 | ||
326 | class BiorseoInstance: | 150 | class BiorseoInstance: |
327 | def __init__(self, opts): | 151 | def __init__(self, opts): |
... | @@ -420,7 +244,9 @@ class BiorseoInstance: | ... | @@ -420,7 +244,9 @@ class BiorseoInstance: |
420 | self.list_jobs() | 244 | self.list_jobs() |
421 | 245 | ||
422 | # run them | 246 | # run them |
423 | - self.execute_jobs() | 247 | + self.execute_jobs() |
248 | + | ||
249 | + # subprocess.call(["rm", "-rf", tempDir]) # empty the temp folder | ||
424 | 250 | ||
425 | def enumerate_loops(self, s): | 251 | def enumerate_loops(self, s): |
426 | def resort(unclosedLoops): | 252 | def resort(unclosedLoops): |
... | @@ -532,28 +358,29 @@ class BiorseoInstance: | ... | @@ -532,28 +358,29 @@ class BiorseoInstance: |
532 | 358 | ||
533 | def launch_JAR3D_worker(self, loop): | 359 | def launch_JAR3D_worker(self, loop): |
534 | # write motif to a file | 360 | # write motif to a file |
535 | - newpath = getcwd()+'/'+loop.header[1:] | 361 | + modulefolder = tempDir + loop.header[1:] + '/' |
536 | - if not path.exists(newpath): | 362 | + if not path.exists(modulefolder): |
537 | - makedirs(newpath) | 363 | + makedirs(modulefolder) |
538 | - chdir(newpath) | 364 | + filename = modulefolder + loop.header[1:]+".fasta" |
539 | - filename = loop.header[1:]+".fasta" | ||
540 | fasta = open(filename, 'w') | 365 | fasta = open(filename, 'w') |
541 | - fasta.write('>'+loop.get_header()+'\n'+loop.subsequence()+'\n') | 366 | + fasta.write('>'+loop.header+'\n'+loop.seq+'\n') |
542 | fasta.close() | 367 | fasta.close() |
543 | 368 | ||
544 | # Launch Jar3D on it | 369 | # Launch Jar3D on it |
545 | if loop.type == 'h': | 370 | if loop.type == 'h': |
546 | - cmd = ["java", "-jar", jar3dexec, filename, HLmotifDir+"/all.txt", | 371 | + cmd = ["java", "-jar", jar3dexec, loop.header[1:]+".fasta", HLmotifDir+"/all.txt", |
547 | loop.header[1:]+".HLloop.csv", loop.header[1:]+".HLseq.csv"] | 372 | loop.header[1:]+".HLloop.csv", loop.header[1:]+".HLseq.csv"] |
548 | else: | 373 | else: |
549 | - cmd = ["java", "-jar", jar3dexec, filename, ILmotifDir+"/all.txt", | 374 | + cmd = ["java", "-jar", jar3dexec, loop.header[1:]+".fasta", ILmotifDir+"/all.txt", |
550 | loop.header[1:]+".ILloop.csv", loop.header[1:]+".ILseq.csv"] | 375 | loop.header[1:]+".ILloop.csv", loop.header[1:]+".ILseq.csv"] |
551 | nowhere = open(devnull, 'w') | 376 | nowhere = open(devnull, 'w') |
552 | logfile = open(biorseoDir + "/log_of_the_run.sh", 'a') | 377 | logfile = open(biorseoDir + "/log_of_the_run.sh", 'a') |
553 | logfile.write(' '.join(cmd)) | 378 | logfile.write(' '.join(cmd)) |
554 | logfile.write("\n") | 379 | logfile.write("\n") |
555 | logfile.close() | 380 | logfile.close() |
381 | + chdir(modulefolder) | ||
556 | subprocess.call(cmd, stdout=nowhere) | 382 | subprocess.call(cmd, stdout=nowhere) |
383 | + chdir(biorseoDir) | ||
557 | nowhere.close() | 384 | nowhere.close() |
558 | 385 | ||
559 | # Retrieve results | 386 | # Retrieve results |
... | @@ -562,7 +389,7 @@ class BiorseoInstance: | ... | @@ -562,7 +389,7 @@ class BiorseoInstance: |
562 | capstype = "HL" | 389 | capstype = "HL" |
563 | else: | 390 | else: |
564 | capstype = "IL" | 391 | capstype = "IL" |
565 | - csv = open(loop.header[1:]+".%sseq.csv" % capstype, 'r') | 392 | + csv = open(modulefolder + loop.header[1:] +".%sseq.csv" % capstype, 'r') |
566 | l = csv.readline() | 393 | l = csv.readline() |
567 | while l: | 394 | while l: |
568 | if "true" in l: | 395 | if "true" in l: |
... | @@ -570,15 +397,12 @@ class BiorseoInstance: | ... | @@ -570,15 +397,12 @@ class BiorseoInstance: |
570 | l = csv.readline() | 397 | l = csv.readline() |
571 | csv.close() | 398 | csv.close() |
572 | 399 | ||
573 | - # Cleaning | ||
574 | - chdir("..") | ||
575 | - subprocess.call(["rm", "-r", loop.header[1:]]) | ||
576 | return insertion_sites | 400 | return insertion_sites |
577 | 401 | ||
578 | def launch_JAR3D(self, seq_, basename): | 402 | def launch_JAR3D(self, seq_, basename): |
579 | rnasubopt_preds = [] | 403 | rnasubopt_preds = [] |
580 | # Extracting probable loops from RNA-subopt structures | 404 | # Extracting probable loops from RNA-subopt structures |
581 | - rna = open(self.outputf + basename + ".subopt", "r") | 405 | + rna = open(tempDir + basename + ".subopt", "r") |
582 | lines = rna.readlines() | 406 | lines = rna.readlines() |
583 | rna.close() | 407 | rna.close() |
584 | for i in range(2, len(lines)): | 408 | for i in range(2, len(lines)): |
... | @@ -597,19 +421,16 @@ class BiorseoInstance: | ... | @@ -597,19 +421,16 @@ class BiorseoInstance: |
597 | # Retrieve subsequences corresponding to the possible loops | 421 | # Retrieve subsequences corresponding to the possible loops |
598 | loops = [] | 422 | loops = [] |
599 | for i, l in enumerate(HLs): | 423 | for i, l in enumerate(HLs): |
600 | - loops.append( | 424 | + loops.append(Loop(">HL%d" % (i+1), seq_[l[0][0]-1:l[0][1]], "h", l)) |
601 | - Loop(">HL%d" % (i+1), seq_[l[0][0]-1:l[0][1]], "h", l)) | ||
602 | for i, l in enumerate(ILs): | 425 | for i, l in enumerate(ILs): |
603 | - loops.append( | 426 | + loops.append(Loop(">IL%d" % (i+1), seq_[l[0][0]-1:l[0][1]]+'*'+seq_[l[1][0]-1:l[1][1]], "i", l)) |
604 | - Loop(">IL%d" % (i+1), seq_[l[0][0]-1:l[0][1]]+'*'+seq_[l[1][0]-1:l[1][1]], "i", l)) | ||
605 | # Scanning loop subsequences against motif database | 427 | # Scanning loop subsequences against motif database |
606 | pool = MyPool(processes=cpu_count()) | 428 | pool = MyPool(processes=cpu_count()) |
607 | - insertion_sites = [x for y in pool.map( | 429 | + insertion_sites = [x for y in pool.map(self.launch_JAR3D_worker, loops) for x in y] |
608 | - self.launch_JAR3D_worker, loops) for x in y] | ||
609 | insertion_sites.sort(reverse=True) | 430 | insertion_sites.sort(reverse=True) |
610 | # Writing results to CSV file | 431 | # Writing results to CSV file |
611 | c = 0 | 432 | c = 0 |
612 | - resultsfile = open(self.outputf+basename+".sites.csv", "w") | 433 | + resultsfile = open(biorseoDir + "/" + tempDir+basename+".sites.csv", "w") |
613 | resultsfile.write("Motif,Rotation,Score,Start1,End1,Start2,End2\n") | 434 | resultsfile.write("Motif,Rotation,Score,Start1,End1,Start2,End2\n") |
614 | for site in insertion_sites: | 435 | for site in insertion_sites: |
615 | if site.score > 10: | 436 | if site.score > 10: |
... | @@ -617,7 +438,7 @@ class BiorseoInstance: | ... | @@ -617,7 +438,7 @@ class BiorseoInstance: |
617 | string = "FOUND with score %d:\t\t possible insertion of motif " % site.score + site.atlas_id | 438 | string = "FOUND with score %d:\t\t possible insertion of motif " % site.score + site.atlas_id |
618 | if site.rotation: | 439 | if site.rotation: |
619 | string += " (reversed)" | 440 | string += " (reversed)" |
620 | - string += (" on " + site.loop.get_header() + " at positions") | 441 | + string += (" on " + site.loop.header + " at positions") |
621 | resultsfile.write(site.atlas_id+',' + | 442 | resultsfile.write(site.atlas_id+',' + |
622 | str(bool(site.rotation))+",%d" % site.score+',') | 443 | str(bool(site.rotation))+",%d" % site.score+',') |
623 | positions = [','.join([str(y) for y in x]) for x in site.position] | 444 | positions = [','.join([str(y) for y in x]) for x in site.position] |
... | @@ -629,10 +450,10 @@ class BiorseoInstance: | ... | @@ -629,10 +450,10 @@ class BiorseoInstance: |
629 | def launch_BayesPairing(self, module_type, seq_, header_): | 450 | def launch_BayesPairing(self, module_type, seq_, header_): |
630 | chdir(bypdir) | 451 | chdir(bypdir) |
631 | 452 | ||
632 | - cmd = ["python3", "parse_sequences.py", "-seq", self.outputf + | 453 | + cmd = ["python3", "parse_sequences.py", "-seq", biorseoDir + '/' + tempDir + |
633 | header_ + ".fa", "-d", module_type, "-interm", "1"] | 454 | header_ + ".fa", "-d", module_type, "-interm", "1"] |
634 | 455 | ||
635 | - logfile = open("log_of_the_run.sh", 'a') | 456 | + logfile = open(biorseoDir + "/log_of_the_run.sh", 'a') |
636 | logfile.write(" ".join(cmd)) | 457 | logfile.write(" ".join(cmd)) |
637 | logfile.write("\n") | 458 | logfile.write("\n") |
638 | logfile.close() | 459 | logfile.close() |
... | @@ -646,9 +467,9 @@ class BiorseoInstance: | ... | @@ -646,9 +467,9 @@ class BiorseoInstance: |
646 | l = BypLog[idx] | 467 | l = BypLog[idx] |
647 | insertion_sites = [x for x in ast.literal_eval(l.split(":")[1][1:])] | 468 | insertion_sites = [x for x in ast.literal_eval(l.split(":")[1][1:])] |
648 | if module_type == "rna3dmotif": | 469 | if module_type == "rna3dmotif": |
649 | - rna = open(self.outputf + header_ + ".byp.csv", "w") | 470 | + rna = open(biorseoDir + "/" + tempDir + header_ + ".byp.csv", "w") |
650 | else: | 471 | else: |
651 | - rna = open(self.outputf + header_ + ".bgsubyp.csv", "w") | 472 | + rna = open(biorseoDir + "/" + tempDir + header_ + ".bgsubyp.csv", "w") |
652 | rna.write("Motif,Score,Start1,End1,Start2,End2...\n") | 473 | rna.write("Motif,Score,Start1,End1,Start2,End2...\n") |
653 | for i, module in enumerate(insertion_sites): | 474 | for i, module in enumerate(insertion_sites): |
654 | if len(module): | 475 | if len(module): |
... | @@ -687,8 +508,8 @@ class BiorseoInstance: | ... | @@ -687,8 +508,8 @@ class BiorseoInstance: |
687 | except: | 508 | except: |
688 | r = 1 | 509 | r = 1 |
689 | pass | 510 | pass |
690 | - if r: | 511 | + # if r: |
691 | - fails.append(j) | 512 | + # fails.append(j) |
692 | running_stats[1] += 1 | 513 | running_stats[1] += 1 |
693 | return r | 514 | return r |
694 | 515 | ||
... | @@ -729,48 +550,12 @@ class BiorseoInstance: | ... | @@ -729,48 +550,12 @@ class BiorseoInstance: |
729 | print("Computations ran successfully.") | 550 | print("Computations ran successfully.") |
730 | print() | 551 | print() |
731 | 552 | ||
732 | - def check_result_existence(self, datatype, method, function, with_PK, basename): | ||
733 | - folder = self.outputf+"PK/" if with_PK else self.outputf+"noPK/" | ||
734 | - if datatype == "bgsu": | ||
735 | - if method == "jar3d": | ||
736 | - extension = ".jar3d" | ||
737 | - elif method == "byp": | ||
738 | - extension = ".bgsubyp" | ||
739 | - else: | ||
740 | - raise "Unknown method !" | ||
741 | - elif datatype == "desc": | ||
742 | - if method == "dpm": | ||
743 | - extension = ".raw" | ||
744 | - elif method == "byp": | ||
745 | - extension = ".byp" | ||
746 | - else: | ||
747 | - raise "Unknown method !" | ||
748 | - else: | ||
749 | - raise "Unknown data type !" | ||
750 | - return path.isfile(folder + basename + extension + function) | ||
751 | - | ||
752 | - def check_csv_existence(self, datatype, method, basename): | ||
753 | - if datatype == "bgsu": | ||
754 | - if method == "jar3d": | ||
755 | - extension = ".sites.csv" | ||
756 | - elif method == "byp": | ||
757 | - extension = ".bgsubyp.csv" | ||
758 | - else: | ||
759 | - raise "Unknown method !" | ||
760 | - elif datatype == "desc": | ||
761 | - if method == "byp": | ||
762 | - extension = ".byp.csv" | ||
763 | - else: | ||
764 | - raise "You cannot use " + method + " with " + datatype + " data !" | ||
765 | - else: | ||
766 | - raise "Unknown data type !" | ||
767 | - return path.isfile(self.outputf + basename + extension) | ||
768 | - | ||
769 | def list_jobs(self): | 553 | def list_jobs(self): |
770 | 554 | ||
771 | # Read fasta file, which can contain one or several RNAs | 555 | # Read fasta file, which can contain one or several RNAs |
772 | RNAcontainer = [] | 556 | RNAcontainer = [] |
773 | subprocess.call(["mkdir", "-p", self.outputf]) # Create the output folder | 557 | subprocess.call(["mkdir", "-p", self.outputf]) # Create the output folder |
558 | + subprocess.call(["mkdir", "-p", tempDir]) # Create the temp folder | ||
774 | print("loading file %s..." % self.inputfile) | 559 | print("loading file %s..." % self.inputfile) |
775 | db = open(self.inputfile, "r") | 560 | db = open(self.inputfile, "r") |
776 | c = 0 | 561 | c = 0 |
... | @@ -789,10 +574,10 @@ class BiorseoInstance: | ... | @@ -789,10 +574,10 @@ class BiorseoInstance: |
789 | if c == 0: | 574 | if c == 0: |
790 | seq = l[:-1].upper() | 575 | seq = l[:-1].upper() |
791 | if is_canonical_nts(seq): | 576 | if is_canonical_nts(seq): |
792 | - header = header.replace('/', '_').replace('\'','').replace('(','').replace(')','').replace(' ','_') | 577 | + header = header.replace('/', '_').replace('\'','').replace('(','').replace(')','').replace(' ','_').replace('>','') |
793 | RNAcontainer.append(RNA(header, seq)) | 578 | RNAcontainer.append(RNA(header, seq)) |
794 | - if not path.isfile(self.outputf + header + ".fa"): | 579 | + if not path.isfile(tempDir + header + ".fa"): |
795 | - rna = open(self.outputf + header + ".fa", "w") | 580 | + rna = open(tempDir + header + ".fa", "w") |
796 | rna.write(">" + header +'\n') | 581 | rna.write(">" + header +'\n') |
797 | rna.write(seq +'\n') | 582 | rna.write(seq +'\n') |
798 | rna.close() | 583 | rna.close() |
... | @@ -807,7 +592,7 @@ class BiorseoInstance: | ... | @@ -807,7 +592,7 @@ class BiorseoInstance: |
807 | for instance in RNAcontainer: | 592 | for instance in RNAcontainer: |
808 | 593 | ||
809 | executable = biorseoDir + "/bin/biorseo" | 594 | executable = biorseoDir + "/bin/biorseo" |
810 | - fastafile = self.outputf+instance.header+".fa" | 595 | + fastafile = tempDir+instance.header+".fa" |
811 | method_type = "" | 596 | method_type = "" |
812 | ext = ".raw" | 597 | ext = ".raw" |
813 | priority = 1 | 598 | priority = 1 |
... | @@ -815,11 +600,11 @@ class BiorseoInstance: | ... | @@ -815,11 +600,11 @@ class BiorseoInstance: |
815 | if self.type == "jar3d": | 600 | if self.type == "jar3d": |
816 | ext = ".jar3d" | 601 | ext = ".jar3d" |
817 | method_type = "--jar3dcsv" | 602 | method_type = "--jar3dcsv" |
818 | - csv = self.outputf + instance.header + ".sites.csv" | 603 | + csv = tempDir + instance.header + ".sites.csv" |
819 | 604 | ||
820 | # RNAsubopt | 605 | # RNAsubopt |
821 | self.joblist.append(Job(command=["RNAsubopt", "-i", fastafile, "--outfile="+ instance.header + ".subopt"], priority=1)) | 606 | self.joblist.append(Job(command=["RNAsubopt", "-i", fastafile, "--outfile="+ instance.header + ".subopt"], priority=1)) |
822 | - self.joblist.append(Job(command=["mv", instance.header + ".subopt", self.outputf], priority=2)) | 607 | + self.joblist.append(Job(command=["mv", instance.header + ".subopt", tempDir], priority=2)) |
823 | # JAR3D | 608 | # JAR3D |
824 | self.joblist.append(Job(function=self.launch_JAR3D, args=[instance.seq_, instance.header], priority=3, how_many_in_parallel=1)) | 609 | self.joblist.append(Job(function=self.launch_JAR3D, args=[instance.seq_, instance.header], priority=3, how_many_in_parallel=1)) |
825 | priority = 4 | 610 | priority = 4 |
... | @@ -827,11 +612,11 @@ class BiorseoInstance: | ... | @@ -827,11 +612,11 @@ class BiorseoInstance: |
827 | method_type = "--bayespaircsv" | 612 | method_type = "--bayespaircsv" |
828 | if self.modules == "desc": | 613 | if self.modules == "desc": |
829 | ext = ".byp" | 614 | ext = ".byp" |
830 | - csv = self.outputf + instance.header + ".byp.csv" | 615 | + csv = tempDir + instance.header + ".byp.csv" |
831 | self.joblist.append(Job(function=self.launch_BayesPairing, args=["rna3dmotif", instance.seq_, instance.header], how_many_in_parallel=-1, priority=1)) | 616 | self.joblist.append(Job(function=self.launch_BayesPairing, args=["rna3dmotif", instance.seq_, instance.header], how_many_in_parallel=-1, priority=1)) |
832 | elif self.modules == "bgsu": | 617 | elif self.modules == "bgsu": |
833 | ext = ".bgsubyp" | 618 | ext = ".bgsubyp" |
834 | - csv = self.outputf + instance.header + ".bgsubyp.csv" | 619 | + csv = tempDir + instance.header + ".bgsubyp.csv" |
835 | self.joblist.append(Job(function=self.launch_BayesPairing, args=["3dmotifatlas", instance.seq_, instance.header], how_many_in_parallel=-1, priority=1)) | 620 | self.joblist.append(Job(function=self.launch_BayesPairing, args=["3dmotifatlas", instance.seq_, instance.header], how_many_in_parallel=-1, priority=1)) |
836 | priority = 2 | 621 | priority = 2 |
837 | if self.type == "dpm": | 622 | if self.type == "dpm": | ... | ... |
-
Please register or login to post a comment