Mercurial > repos > rnateam > antarna
annotate antaRNA.py @ 1:ebc371f3c6b5 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
author | rnateam |
---|---|
date | Wed, 13 May 2015 11:15:31 -0400 |
parents | fcf4719d3831 |
children |
rev | line source |
---|---|
0
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1 import numpy |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
2 import sys |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
3 import random |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
4 import subprocess |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
5 import re |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
6 import decimal |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
7 import math |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
8 import os |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
9 import shutil |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
10 import time |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
11 import types |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
12 import argparse |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
13 #from argparse import RawTextHelpFormatter |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
14 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
15 ############################# |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
16 # FUNCTIONS |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
17 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
18 def print2file(f, i, m): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
19 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
20 print content i to file f in mode m |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
21 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
22 line = str(i) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
23 if m == "a": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
24 call = "echo \"" + line + "\" >> " + f |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
25 elif m == "w": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
26 call = "echo \"" + line + "\" > " + f |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
27 os.system(call) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
28 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
29 # checking and correcting the alphabet of the constraint sequence |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
30 def checkSequenceConstraint(SC): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
31 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
32 Checks the Sequence constraint for illegal nucleotide characters |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
33 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
34 out = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
35 for c in SC: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
36 c = c.upper() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
37 if c not in "ACGURYSWKMBDHVN": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
38 # and c!= "R" and c != "Y" and c != "S" and c != "W" and c != "K" and c != "M" and c != "B" and c != "D" and c != "H" and c != "V": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
39 if c == "T": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
40 c = "U" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
41 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
42 print "\tIllegal Character in the constraint sequence!" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
43 print "\tPlease use the IUPAC nomenclature for defining nucleotides in the constraint sequence!" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
44 print "\tA Adenine" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
45 print "\tC Cytosine" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
46 print "\tG Guanine" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
47 print "\tT/U Thymine/Uracil" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
48 print "\tR A or G" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
49 print "\tY C or T/U" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
50 print "\tS G or C" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
51 print "\tW A or T/U" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
52 print "\tK G or T/U" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
53 print "\tM A or C" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
54 print "\tB C or G or T/U" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
55 print "\tD A or G or T/U" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
56 print "\tH A or C or T/U" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
57 print "\tV A or C or G" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
58 print "\tN any base" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
59 exit(0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
60 out += c |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
61 return (1, out) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
62 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
63 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
64 def transform(seq): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
65 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
66 Transforms "U" to "T" for the processing is done on DNA alphabet |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
67 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
68 S = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
69 for s in seq: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
70 if s == "T": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
71 S += "U" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
72 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
73 S += s |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
74 return S |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
75 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
76 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
77 def checkSimilarLength(s, SC): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
78 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
79 Compares sequence and structure constraint length |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
80 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
81 if len(s) == len(SC): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
82 return 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
83 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
84 return 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
85 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
86 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
87 def isStructure(s): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
88 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
89 Checks if the structure constraint only contains "(", ")", and "." and legal fuzzy structure constraint characters. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
90 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
91 returnvalue = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
92 for a in range(0,len(s)): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
93 if s[a] not in ".()[]{}<>": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
94 if s[a] not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
95 returnvalue = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
96 return returnvalue |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
97 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
98 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
99 def isBalanced(s): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
100 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
101 Check if the structure s is of a balanced nature |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
102 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
103 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
104 balance = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
105 for bracket in ["()", "[]", "{}", "<>"]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
106 counter = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
107 for a in xrange(len(s)): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
108 if s[a] in bracket[0]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
109 counter += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
110 elif s[a] in bracket[1]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
111 counter -= 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
112 if counter != 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
113 balance = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
114 return balance |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
115 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
116 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
117 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
118 def fulfillsHairpinRule(s): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
119 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
120 CHECKING FOR THE 3 nt LOOP INTERSPACE |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
121 for all kind of basepairs, even wihtin the pdeudoknots |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
122 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
123 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
124 fulfillsRules = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
125 for bracket in ["()", "[]", "{}", "<>"]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
126 last_opening_char = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
127 check = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
128 for a in xrange(len(s)): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
129 if s[a] == bracket[0]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
130 last_opening_char = a |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
131 check = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
132 elif s[a] == bracket[1] and check == 1: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
133 check = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
134 if a - last_opening_char < 4: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
135 return 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
136 return 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
137 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
138 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
139 def isValidStructure(s): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
140 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
141 Checks, if the structure s is a valid structure |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
142 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
143 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
144 Structure = isStructure(s) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
145 Balanced = isBalanced(s) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
146 HairpinRule = fulfillsHairpinRule(s) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
147 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
148 if Structure == 1 and Balanced == 1 and HairpinRule == 1: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
149 return 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
150 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
151 print Structure, Balanced, HairpinRule |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
152 return 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
153 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
154 def loadIUPACcompatibilities(IUPAC, useGU): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
155 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
156 Generating a hash containing all compatibilities of all IUPAC RNA NUCLEOTIDES |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
157 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
158 compatible = {} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
159 for nuc1 in IUPAC: # ITERATING OVER THE DIFFERENT GROUPS OF IUPAC CODE |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
160 sn1 = list(IUPAC[nuc1]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
161 for nuc2 in IUPAC: # ITERATING OVER THE DIFFERENT GROUPS OF IUPAC CODE |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
162 sn2 = list(IUPAC[nuc2]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
163 compatib = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
164 for c1 in sn1: # ITERATING OVER THE SINGLE NUCLEOTIDES WITHIN THE RESPECTIVE IUPAC CODE: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
165 for c2 in sn2: # ITERATING OVER THE SINGLE NUCLEOTIDES WITHIN THE RESPECTIVE IUPAC CODE: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
166 # CHECKING THEIR COMPATIBILITY |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
167 if useGU == True: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
168 if (c1 == "A" and c2 == "U") or (c1 == "U" and c2 == "A") or (c1 == "C" and c2 == "G") or (c1 == "G" and c2 == "C") or (c1 == "G" and c2 == "U") or (c1 == "U" and c2 == "G"): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
169 compatib = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
170 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
171 if (c1 == "A" and c2 == "U") or (c1 == "U" and c2 == "A") or (c1 == "C" and c2 == "G") or (c1 == "G" and c2 == "C"): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
172 compatib = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
173 compatible[nuc1 + "_" + nuc2] = compatib # SAVING THE RESPECTIVE GROUP COMPATIBILITY, REVERSE SAVING IS NOT REQUIRED, SINCE ITERATING OVER ALL AGAINST ALL |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
174 return compatible |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
175 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
176 def isCompatibleToSet(c1, c2, IUPAC_compatibles): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
177 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
178 Checks compatibility of c1 wihtin c2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
179 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
180 compatible = True |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
181 for setmember in c2: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
182 #print setmember |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
183 if isCompatible(c1, setmember, IUPAC_compatibles) == False: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
184 return False |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
185 return compatible |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
186 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
187 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
188 def isCompatible(c1, c2, IUPAC_compatibles): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
189 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
190 Checks compatibility between character c1 and c2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
191 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
192 if IUPAC_compatibles[c1 + "_" + c2] == 1: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
193 return True |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
194 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
195 return False |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
196 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
197 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
198 def isStructureCompatible(lp1, lp2 ,bp): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
199 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
200 Checks, if the region within lp1 and lp2 is structurally balanced |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
201 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
202 x = lp1 + 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
203 while (x < lp2): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
204 if (bp[x] <= lp1 or bp[x] > lp2): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
205 return False |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
206 if x == bp[x]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
207 x += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
208 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
209 x = bp[x] + 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
210 return x == lp2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
211 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
212 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
213 def checkConstaintCompatibility(basepairstack, sequenceconstraint, IUPAC_compatibles): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
214 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
215 Checks if the constraints are compatible to each other |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
216 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
217 returnstring = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
218 compatible = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
219 for id1 in basepairstack: # key = (constraint , (pos, constraint))) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
220 constr1 = basepairstack[id1][0] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
221 id2 = basepairstack[id1][1][0] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
222 constr2 = basepairstack[id1][1][1] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
223 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
224 if id1 != id2 and not isCompatible(constr1, constr2, IUPAC_compatibles): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
225 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
226 compatible = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
227 returnstring += "nucleotide constraint " + str(constr1) + " at position " + str(id1) + " is not compatible with nucleotide constraint " + str(constr2) + " at position " + str(id2) + "\n" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
228 #if not isCompatible(basepairstack[basepair][0], basepairstack[basepair][1][1]): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
229 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
230 #compatible = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
231 #else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
232 #returnstring += "nucleotide constraint " + str(basepairstack[basepair][0]) + " at position " + str(basepair) + " is compatible with nucleotide constraint " + str(basepairstack[basepair][1][1]) + " at position " + str(basepairstack[basepair][1][0]) + "\n" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
233 return (compatible, returnstring) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
234 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
235 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
236 def getLP(BPSTACK): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
237 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
238 Retreives valid lonley base pairs from a base pair stack |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
239 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
240 #20 ('N', (>BLOCK<, 'N')) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
241 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
242 # geting single base pairs |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
243 stack = {} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
244 LP = {} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
245 if type(BPSTACK[random.choice(BPSTACK.keys())]) == types.TupleType: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
246 for i in BPSTACK.keys(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
247 #if str(BPSTACK[i][1][0]) not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
248 stack[i] = int(BPSTACK[i][1][0]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
249 #print i , BPSTACK[i][1][0] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
250 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
251 for i in BPSTACK.keys(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
252 #if str(BPSTACK[i]) not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
253 stack[i] = BPSTACK[i] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
254 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
255 # removing redundant base pair indices |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
256 for i in stack.keys(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
257 if i >= stack[i]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
258 del stack[i] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
259 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
260 # actual checking for single lonley base pairs |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
261 for i in stack.keys(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
262 if not (i-1 in stack and stack[i-1] == stack[i] + 1) and not (i+1 in stack and stack[i+1] == stack[i] - 1): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
263 LP[i] = stack[i] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
264 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
265 ##actual removal of 2er lonley base pairs |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
266 for i in stack.keys(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
267 if not (i-1 in stack and stack[i-1] == stack[i] + 1) and (i+1 in stack and stack[i+1] == stack[i] - 1) and not (i+2 in stack and stack[i+2] == stack[i] - 2): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
268 LP[i] = stack[i] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
269 LP[i+1] = stack[i+1] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
270 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
271 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
272 #if type(BPSTACK[random.choice(BPSTACK.keys())]) == types.TupleType: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
273 #for i in BPSTACK.keys(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
274 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
275 ##if str(BPSTACK[i][1][0]) not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
276 #stack[i] = int(BPSTACK[i][1][0]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
277 ##print i , BPSTACK[i][1][0] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
278 #else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
279 #for i in BPSTACK.keys(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
280 ##if str(BPSTACK[i]) not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
281 #stack[i] = BPSTACK[i] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
282 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
283 #for i in stack.keys(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
284 #if i >= stack[i]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
285 #del stack[i] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
286 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
287 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
288 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
289 return LP |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
290 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
291 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
292 def getBPStack(s, seq): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
293 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
294 Returns a dictionary of the corresponding basepairs of the structure s and the sequence constraint seq. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
295 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
296 tmp_stack = {"()":[], "{}":[], "[]":[], "<>":[]} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
297 bpstack = {} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
298 for i in xrange(len(s)): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
299 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
300 # REGULAR SECONDARY STRUCTURE DETECTION |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
301 if s[i] in "(){}[]<>": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
302 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
303 no = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
304 ### opening |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
305 if s[i] in "([{<": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
306 if s[i] == "(": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
307 tmp_stack["()"].append((i, seq[i])) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
308 elif s[i] == "[": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
309 tmp_stack["[]"].append((i, seq[i])) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
310 elif s[i] == "{": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
311 tmp_stack["{}"].append((i, seq[i])) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
312 elif s[i] == "<": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
313 tmp_stack["<>"].append((i, seq[i])) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
314 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
315 #closing |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
316 elif s[i] in ")]}>": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
317 if s[i] == ")": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
318 no, constr = tmp_stack["()"].pop() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
319 elif s[i] == "]": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
320 no, constr = tmp_stack["[]"].pop() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
321 elif s[i] == "}": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
322 no, constr = tmp_stack["{}"].pop() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
323 elif s[i] == ">": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
324 no, constr = tmp_stack["<>"].pop() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
325 bpstack[no] = (constr, (i, seq[i])) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
326 bpstack[i] = (seq[i] ,(no, constr)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
327 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
328 elif s[i] == ".": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
329 bpstack[i] = (seq[i], (i, seq[i])) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
330 elif s[i] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
331 bpstack[i] = (seq[i], (i, seq[i])) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
332 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
333 return (bpstack, getLP(bpstack)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
334 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
335 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
336 def getbpStack(s): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
337 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
338 Returns a dictionary of the corresponding basepairs of the structure s and the sequence constraint seq. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
339 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
340 tmp_stack = {"()":[], "{}":[], "[]":[], "<>":[]} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
341 bpstack = {} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
342 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
343 for i in xrange(len(s)): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
344 if s[i] in "(){}[]<>": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
345 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
346 no = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
347 ### opening |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
348 if s[i] in "([{<": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
349 if s[i] == "(": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
350 tmp_stack["()"].append(i) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
351 elif s[i] == "[": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
352 tmp_stack["[]"].append(i) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
353 elif s[i] == "{": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
354 tmp_stack["{}"].append(i) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
355 elif s[i] == "<": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
356 tmp_stack["<>"].append(i) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
357 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
358 #closing |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
359 elif s[i] in ")]}>": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
360 if s[i] == ")": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
361 no = tmp_stack["()"].pop() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
362 elif s[i] == "]": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
363 no = tmp_stack["[]"].pop() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
364 elif s[i] == "}": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
365 no = tmp_stack["{}"].pop() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
366 elif s[i] == ">": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
367 no = tmp_stack["<>"].pop() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
368 bpstack[no] = i # save basepair in the format {opening base id (opening seq constr,(closing base id, closing seq constr))} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
369 bpstack[i] = no # save basepair in the format {closing base id (closing seq constr,(opening base id, opening seq constr))} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
370 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
371 elif s[i] == ".": # no structural constaint given: produce entry, which references itself as a base pair partner.... |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
372 bpstack[i] = i |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
373 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
374 elif s[i] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
375 bpstack[i] = i |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
376 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
377 #elif s[i] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
378 ## per position, assigned to a certain block, the target nucleotide, with whcih it should interact is marked with the specific |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
379 ## block character |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
380 #bpstack[i] = s[i] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
381 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
382 return (bpstack, getLP(bpstack)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
383 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
384 def maprange( a, b, s): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
385 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
386 Mapping function |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
387 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
388 (a1, a2), (b1, b2) = a, b |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
389 return b1 + ((s - a1) * (b2 - b1) / (a2 - a1)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
390 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
391 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
392 def applyGCcontributionPathAdjustment(pathlength, tmpGC, nt): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
393 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
394 GC path length contribution calculation. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
395 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
396 GCadjustment = 1.5 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
397 minimum = 0.5 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
398 upper = GCadjustment |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
399 lower = minimum |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
400 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
401 if nt == "A" or nt == "U": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
402 pathlength = pathlength * maprange( (0, 1) , (lower, upper), tmpGC) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
403 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
404 if nt == "G" or nt == "C": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
405 #pathlength = pathlength * (float(1-tmpGC)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
406 pathlength = pathlength * maprange( (1, 0) , (lower, upper), tmpGC) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
407 return pathlength |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
408 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
409 def getConstraint(TE, BPstack, IUPAC, IUPAC_compatibles, IUPAC_reverseComplements): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
410 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
411 Dependend on the situation in the constraint an the respective path section, setting wether a specific constraint can be given or not (for that path section) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
412 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
413 # TE :: transition element / path section under dispute |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
414 # id1 :: id of the position of the caharacter to which the transition is leading to |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
415 # id2 :: id of the position of the character, which is listed in the BPinformation, it can be id1 as well, when no bp is present |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
416 # val :: BPstack information of the specific position |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
417 # constr1 :: constraining character of pos id1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
418 # constr2 :: constraining character of pos id2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
419 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
420 id1 = int(TE.split(".")[0]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
421 val = BPstack[id1] # check out the value of the destination character in the basepair/constraint stack |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
422 constr1 = val[0] # getting the constraint character of position id1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
423 id2 = int(val[1][0]) # getting position id2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
424 constr2 = val[1][1] # getting the sequence constraint for position id2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
425 targetNucleotide = TE.split(".")[1][-1:] # where the edge is leading to |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
426 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
427 c1 = set(IUPAC[constr1]) # getting all explicit symbols of c1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
428 c2 = set(IUPAC_reverseComplements[constr2]) # getting the reverse complement explicit symbols of c2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
429 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
430 if targetNucleotide in c1: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
431 if id1 == id2: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
432 return 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
433 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
434 if targetNucleotide in c2: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
435 return 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
436 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
437 return 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
438 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
439 return 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
440 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
441 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
442 def getConstraint(TE, BPstack): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
443 # TE :: transition element / path section |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
444 # id1 :: id of the position of the caharacter to which the transition is leading to |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
445 # id2 :: id of the position of the character, which is listed in the BPinformation, it can be id1 as well, when no bp is present |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
446 # val :: BPstack information of the specific position |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
447 # constr1 :: constraining character of pos id1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
448 # constr2 :: constraining character of pos id2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
449 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
450 ### BPstack [id1] = (constr1, (id2, constr2)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
451 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
452 id1 = TE.split(".")[0] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
453 #print id1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
454 #id1 = TE.find(TE.strip("_")) # strip the path section and getting the position of the section |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
455 #if len(TE.strip("_")) == 2: # check if the path section is from an internal and not an initial transition |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
456 #id1 += 1 # increase position id1 by 1, since the last character of the section is the destination character |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
457 val = BPstack[int(id1)] # check out the value of the destination character in the basepair/constraint stack |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
458 constr1 = val[0] # getting the constraint character of position id1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
459 id2 = val[1][0] # getting position id2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
460 constr2 = val[1][1] # getting the sequence constraint for position id2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
461 #print TE, id1, constr1, id2, constr2, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
462 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
463 #TE.split(".")[1][-1:] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
464 if id1 == id2: # both ids were the same with either character, sequential or no sequential constraint -> no basepair constraint |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
465 if constr1 == TE.split(".")[1][-1:] and constr2 == TE.split(".")[1][-1:]: # case if the single base constraints on position id1 == id2 are the same as the destination character on id1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
466 #print 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
467 return 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
468 elif constr1 == constr2 == "N": # case if the single base constraints on position id1 == id2 has no constraint |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
469 #print 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
470 return 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
471 else: # single base sequence constraints differ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
472 #print 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
473 return 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
474 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
475 elif id1 != id2: # showing differentq ids, indicating a bp, (basepair structural constraint) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
476 if constr1 == "N" and constr2 == "N": # no sequence constraint |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
477 #print 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
478 return 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
479 if constr1 == "N" and constr2 != "N": # c1 has no constraint, c2 has character constraint (sequence constraint of closing bases) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
480 if TE.split(".")[1][-1:] == complementBase(constr2): # the current path section destination base is equal to the complement base of the mentioned sequence constraint in constr2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
481 #print 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
482 return 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
483 else: # case if the current path section destination base is not equeal to the mentioned complement sequence constraint in constr2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
484 #print 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
485 return 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
486 if constr1 != "N" and constr2 == "N": # c1 has character constraint, c2 has no character constraint (sequence constraint in the opening base) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
487 if TE.split(".")[1][-1:] == constr1: # the current path section destination base is as constrained with constr1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
488 #print 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
489 return 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
490 else: # the current path section destination base is not as constrained in constr1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
491 #print 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
492 return 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
493 if constr1 != "N" and constr2 != "N": # both positions have sequential constraint |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
494 if TE.split(".")[1][-1:] == constr1: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
495 #print 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
496 return 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
497 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
498 #print 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
499 return 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
500 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
501 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
502 def applyTerrainModification(terrain, s, tmpGC, SC, BPstack, IUPAC, IUPAC_compatibles, IUPAC_reverseComplements): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
503 #nucleotides = {'A': 0, 'C': 1,'G': 2,'T': 3} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
504 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
505 dels = [] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
506 for terrainelement in sorted(terrain): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
507 pheromone, pathlength = terrain[terrainelement] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
508 pheromone = getConstraint(terrainelement, BPstack, IUPAC, IUPAC_compatibles, IUPAC_reverseComplements) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
509 pathlength = getConstraint(terrainelement, BPstack, IUPAC, IUPAC_compatibles, IUPAC_reverseComplements) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
510 pathlength = applyGCcontributionPathAdjustment(pathlength, tmpGC,terrainelement.split(".")[1][-1:]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
511 if pheromone * pathlength == 0: dels.append(terrainelement) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
512 terrain[terrainelement] = (pheromone, pathlength,[]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
513 further_dels = {} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
514 for terrainelement in sorted(dels): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
515 pos, nucs = terrainelement.split(".") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
516 if int(pos) < len(s)-1: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
517 to_nt = nucs[-1:] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
518 successor_pos = int(pos) + 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
519 for i in ["A", "C", "G", "U"]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
520 del_element = str(successor_pos) + "." + to_nt + i |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
521 further_dels[del_element] = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
522 further_dels[terrainelement] = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
523 # deleting the inbound and outbound edges, which are forbidden |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
524 for terrainelement in further_dels: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
525 del terrain[terrainelement] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
526 # allocate the appropriate children of edges |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
527 for terrainelement in terrain: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
528 pheromone, pathlength, children = terrain[terrainelement] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
529 pos, nucs = terrainelement.split(".") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
530 if int(pos) < len(s): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
531 to_nt = nucs[-1:] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
532 successor_pos = int(pos) + 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
533 for i in ["A", "C", "G", "U"]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
534 if str(successor_pos) + "." + to_nt + i in terrain: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
535 children.append(str(successor_pos) + "." + to_nt + i) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
536 terrain[terrainelement] = (pheromone, pathlength,children) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
537 starts = [] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
538 for i in ["A", "C", "G", "U"]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
539 if str(0) + "." + i in terrain: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
540 starts.append(str(0) + "." + i) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
541 terrain["00.XY"] = (1, 1, starts) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
542 return (terrain, BPstack) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
543 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
544 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
545 def initTerrain(s): # THE CLASSIC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
546 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
547 Initialization of the terrain with graph like terrain... vertices are modeled implicitly |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
548 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
549 nt = ["A","C","G","U"] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
550 nt2 = ["AA","AC","AG","AU","CA","CC","CG","CU","GA","GC","GG","GU","UA","UC","UG","UU"] # Allowed dinucleotides |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
551 e = {} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
552 pathlength = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
553 pheromone = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
554 for p in xrange(len(s)): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
555 if p == 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
556 for i in nt: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
557 e["%s.%s"%(p,i)] = (pheromone, pathlength) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
558 elif p > 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
559 for n in nt2: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
560 e["%s.%s"%(p,n)] = (pheromone, pathlength) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
561 return e |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
562 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
563 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
564 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
565 def complementBase(c): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
566 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
567 Returns the complement RNA character of c (without GU base pairs) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
568 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
569 retChar = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
570 if c == "A" : |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
571 retChar = "U" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
572 elif c == "U": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
573 retChar = "A" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
574 elif c == "C": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
575 retChar = "G" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
576 elif c == "G": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
577 retChar = "C" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
578 return retChar |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
579 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
580 def printTerrain(terrain): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
581 #print sorted(terrain.keys()) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
582 tmp_i = "0" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
583 tmp_c = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
584 terrain = terrain[0] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
585 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
586 for a, i in enumerate(sorted(terrain.keys())): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
587 #print a |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
588 if i.split(".")[0] != tmp_i: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
589 print "\nElements:", tmp_c,"\n#########################\n", i, terrain[i] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
590 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
591 tmp_c = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
592 tmp_i = i.split(".")[0] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
593 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
594 print i, terrain[i] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
595 tmp_c += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
596 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
597 print "\nElements:", tmp_c |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
598 print "#########################" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
599 print len(terrain) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
600 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
601 def pickStep(tmp_steps, summe): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
602 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
603 Selects a step within the terrain |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
604 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
605 if len(tmp_steps) == 1: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
606 return tmp_steps[0][1] # returning the nucleotide of the only present step |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
607 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
608 rand = random.random() # draw random number |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
609 mainval = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
610 for choice in xrange(len(tmp_steps)): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
611 val, label = tmp_steps[choice] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
612 mainval += val/float(summe) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
613 if mainval > rand: # as soon, as the mainval gets larger than the random value the assignment is done |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
614 return label |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
615 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
616 def getPath(s, tmp_terrain, tmp_BPstack, alpha, beta, IUPAC, IUPAC_reverseComplements): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
617 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
618 Performs a walk through the terrain and assembles a sequence, while respecting the structure constraint and IUPAC base complementarity |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
619 of the base pairs GU, GC and AT |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
620 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
621 nt = ["A","C","G","U"] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
622 prev_edge = "00.XY" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
623 sequence = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
624 while len(sequence) < len(s): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
625 coming_from = sequence[-1:] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
626 summe = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
627 steps = [] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
628 i = len(sequence) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
629 allowed_nt = "ACGU" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
630 # base pair closing case check, with subsequent delivery of a reduced allowed nt set |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
631 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
632 if i > tmp_BPstack[i][1][0]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
633 jump = tmp_BPstack[i][1][0] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
634 nuc_at_jump = sequence[jump] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
635 allowed_nt = IUPAC_reverseComplements[nuc_at_jump] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
636 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
637 #allowed_nt = complementBase(nuc_at_jump) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
638 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
639 # Checking for every possible nt if it is suitable for the selection procedure |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
640 for edge in tmp_terrain[prev_edge][-1]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
641 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
642 if edge[-1:] in allowed_nt: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
643 pheromone, PL , children = tmp_terrain[edge] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
644 #if PL > 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
645 value = ((float(pheromone * alpha)) + ((1/float(PL)) * beta)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
646 summe += value |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
647 steps.append((value, edge)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
648 prev_edge = pickStep(steps, summe) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
649 sequence += prev_edge[-1:] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
650 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
651 return sequence |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
652 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
653 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
654 ### |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
655 # STRUCTURE PREDICTORS |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
656 ### |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
657 def getPKStructure(sequence, temperature, mode = "A"): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
658 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
659 Initialization pKiss mfe pseudoknot prediction |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
660 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
661 p2p = "pKiss" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
662 #p2p = "/usr/local/pkiss/2014-03-17/bin/pKiss_mfe" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
663 strategy = "--strategy " |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
664 t = "--temperature " + str(temperature) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
665 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
666 if mode == "A": strategy += "A" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
667 elif mode == "B": strategy += "B" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
668 elif mode == "C": strategy += "C" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
669 elif mode == "D": strategy += "D" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
670 elif mode == "P": strategy += "P" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
671 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
672 p = subprocess.Popen( ([p2p, "--mode mfe", strategy, t]), |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
673 #shell = True, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
674 stdin = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
675 stdout = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
676 stderr = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
677 close_fds = True) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
678 #print p.stderr.readline() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
679 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
680 p.stdin.write(sequence+'\n') |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
681 pks = p.communicate() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
682 structure = "".join(pks[0].split("\n")[2].split(" ")[-1:]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
683 return structure |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
684 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
685 def init_RNAfold(version, temperature, paramFile = ""): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
686 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
687 Initialization RNAfold listener |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
688 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
689 p2p = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
690 t = "-T " + str(temperature) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
691 P = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
692 if paramFile != "": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
693 P = "-P " + paramFile |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
694 if version == 185: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
695 p2p = "/home/rk/Software/ViennaRNA/ViennaRNA-1.8.5/Progs/RNAfold" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
696 p = subprocess.Popen( ([p2p, '--noPS', '-d 2', t, P]), |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
697 shell = True, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
698 stdin = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
699 stdout = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
700 stderr = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
701 close_fds = True) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
702 return p |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
703 elif version == 213: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
704 p2p = "RNAfold" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
705 p = subprocess.Popen( ([p2p, '--noPS', '-d 2', t, P]), |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
706 #shell = True, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
707 stdin = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
708 stdout = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
709 stderr = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
710 close_fds = True) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
711 return p |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
712 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
713 exit(0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
714 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
715 def consult_RNAfold(seq, p): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
716 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
717 Consults RNAfold listener |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
718 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
719 p.stdin.write(seq+'\n') |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
720 out = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
721 for i in xrange(2): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
722 out += p.stdout.readline() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
723 return out |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
724 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
725 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
726 def getRNAfoldStructure(struct2, process1): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
727 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
728 Retrieves folded structure of a RNAfold call |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
729 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
730 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
731 RNAfold_pattern = re.compile('.+\n([.()]+)\s.+') |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
732 #RNAdist_pattern = re.compile('.*\s([\d]+)') |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
733 RNAfold_match = RNAfold_pattern.match(consult_RNAfold(struct2, process1)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
734 current_structure = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
735 #if RNAfold_match: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
736 return RNAfold_match.group(1) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
737 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
738 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
739 def init_RNAdistance(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
740 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
741 Initialization of RNAdistance listener |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
742 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
743 #p2p = "/home/rk/Software/ViennaRNA/ViennaRNA-1.8.5/Progs/RNAdistance" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
744 p2p = "RNAdistance" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
745 p = subprocess.Popen( ([p2p]), |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
746 #shell = True, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
747 stdin = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
748 stdout = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
749 stderr = subprocess.PIPE, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
750 close_fds = True) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
751 return p |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
752 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
753 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
754 def consult_RNAdistance(s1, s2, p): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
755 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
756 Consulting the RNAdistance listener |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
757 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
758 p.stdin.write(s1+'\n') |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
759 p.stdin.write(s2+'\n') |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
760 out = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
761 out_tmp = p.stdout.readline().strip() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
762 if out_tmp != "": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
763 out += out_tmp |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
764 return out |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
765 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
766 def getInducingSequencePositions(Cseq, degreeOfSequenceInducement): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
767 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
768 Delimiting the degree of structure inducement by the supplied sequence constraint. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
769 0 : no sequence induced structure constraint |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
770 1 : "ACGT" induce structure (explicit nucleotide structure inducement level) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
771 2 : "MWKSYR" and "ACGT" (explicit and double instances) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
772 3 : "BDHV" , "MWKSYR" and "ACGT" (explicit, double, and triple instances) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
773 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
774 setOfNucleotides = "" # resembling the "0"-case |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
775 if degreeOfSequenceInducement == 1: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
776 setOfNucleotides = "ACGU" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
777 elif degreeOfSequenceInducement == 2: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
778 setOfNucleotides = "ACGUMWKSYR" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
779 elif degreeOfSequenceInducement == 3: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
780 setOfNucleotides = "ACGUMWKSYRBDHV" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
781 #elif degreeOfSequenceInducement == 4: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
782 #setOfNucleotides = "ACGTMWKSYRBDHVN" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
783 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
784 tmpSeq = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
785 listset = setOfNucleotides |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
786 for pos in Cseq: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
787 if pos not in listset: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
788 tmpSeq += "N" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
789 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
790 tmpSeq += pos |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
791 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
792 return setOfNucleotides, tmpSeq |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
793 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
794 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
795 def getBPDifferenceDistance(stack1, stack2): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
796 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
797 Based on the not identical amount of base pairs within both structure stacks |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
798 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
799 d = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
800 for i in stack1.keys(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
801 # check base pairs in stack 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
802 if i < stack1[i] and stack1[i] != stack2[i]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
803 d += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
804 # check base pairs in stack 2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
805 for i in stack2.keys(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
806 if i < stack2[i] and stack1[i] != stack2[i]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
807 d += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
808 return d |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
809 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
810 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
811 def getStructuralDistance(target_structure, Cseq, path, RNAfold, verbose, LP, BP, RNAfold_pattern, IUPAC_compatibles, degreeOfSequenceInducement, pseudoknots, strategy): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
812 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
813 Calculator for Structural Distance |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
814 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
815 # fold the current solution's sequence to obtain the structure |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
816 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
817 current_structure = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
818 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
819 if pseudoknots: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
820 current_structure = getPKStructure(path,strategy) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
821 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
822 RNAfold_match = RNAfold_pattern.match(consult_RNAfold(path, RNAfold)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
823 current_structure = RNAfold_match.group(1) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
824 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
825 # generate the current structure's base-pair stack |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
826 bp = getbpStack(current_structure)[0] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
827 # add case-dependend structural constraints in case of lonley basepairs formation |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
828 tmp_target_structure_bp = getbpStack(target_structure)[0] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
829 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
830 for lp in LP: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
831 if bp[lp] == LP[lp]: # if the base pair is within the current solution structure, re-add the basepair into the constraint structure. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
832 #tmp_target_structure[lp] = "(" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
833 #tmp_target_structure[LP[lp]] = ")" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
834 tmp_target_structure_bp[lp] = LP[lp] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
835 tmp_target_structure_bp[LP[lp]] = lp |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
836 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
837 # REMOVE BLOCK CONSTRAINT AND SUBSTITUTE IT WITH SINGLE STRAND INFORMATION repsective with brackets, if allowed base pairs occure |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
838 # check for all allowed implicit constraint block declarators |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
839 for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
840 occurances = [] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
841 for m in re.finditer(c, target_structure): # search for a declarator in the requested structure |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
842 occurances.append(m.start()) # save the corresponding index |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
843 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
844 # transform declarator into single stranded request |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
845 for i in occurances: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
846 #tmp_target_structure[i] = "." |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
847 tmp_target_structure_bp[i] = i |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
848 # infer a base pair within the block declarated positions, if the current structure provides it. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
849 for i in occurances: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
850 for j in occurances: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
851 if i < j: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
852 if bp[i] == j: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
853 #tmp_target_structure[i] = "(" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
854 #tmp_target_structure[bp[i]] = ")" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
855 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
856 tmp_target_structure_bp[i] = bp[i] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
857 tmp_target_structure_bp[bp[i]] = i |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
858 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
859 # CHECK FOR SEQUENCE CONSTRAINT WHICH INDUCES STRUCTURE CONSTRAINT IN THE MOMENTARY SITUATION |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
860 #print "Checking Cseq influence and it's induced basepairs..." |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
861 IUPACinducers, tmp_Cseq = getInducingSequencePositions(Cseq, degreeOfSequenceInducement) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
862 if len(Cseq.strip("N")) > 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
863 #print "Processing Cseq influence" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
864 # Iterate over all positions within the Base Pair stack |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
865 for i in BP: # Check for each base index i |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
866 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
867 if i < bp[i]: # if the current index is samller that the affiliated in the basepair stack of the current solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
868 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
869 bp_j = bp[i] # Actual j index of the current solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
870 BP_j = BP[i][1][0] # j index of the requested structure |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
871 if (i != bp_j and i == BP_j and BP[i][0] in IUPACinducers ): # if i pairs with some other base in the current structure, and i is requested single stranded and the Sequence constraint is allowed to induce... |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
872 if (BP[bp_j][1][0] == bp_j and BP[bp_j][0] in IUPACinducers):# If position j is requested singlestranded and position j nucleotide can induce base pairs |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
873 #if isCompatible(bp[i][0], bp[i][1][1], IUPAC_compatibles): # If both nucleotides, i and j are actually compatible |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
874 #tmp_target_structure[i] = "(" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
875 #tmp_target_structure[bp_j] = ")" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
876 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
877 tmp_target_structure_bp[i] = bp[i] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
878 tmp_target_structure_bp[bp_j] = i |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
879 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
880 #tts = "".join(tmp_target_structure) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
881 dsreg = getBPDifferenceDistance(tmp_target_structure_bp, bp) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
882 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
883 # CHECK FOR ALL DETERMINED LONELY BASE PAIRS (i<j), if they are formed |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
884 failLP = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
885 for lp in LP: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
886 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
887 if bp[lp] != LP[lp]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
888 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
889 isComp = isCompatible(path[lp],path[LP[lp]], IUPAC_compatibles) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
890 isStru = isStructureCompatible(lp, LP[lp] ,bp) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
891 if not ( isStru and isStru ): # check if the bases at the specific positions are compatible and check if the |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
892 # basepair can be formed according to pseudoknot free restriction. If one fails, a penalty distance is raised for that base pair |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
893 failLP += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
894 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
895 #print dsreg, failLP, float(len(tmp_target_structure_bp)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
896 dsLP = float(failLP) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
897 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
898 return (dsreg + dsLP) /float(len(tmp_target_structure_bp)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
899 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
900 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
901 def getGC(sequence): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
902 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
903 Calculate GC content of a sequence |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
904 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
905 GC = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
906 for nt in sequence: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
907 if nt == "G" or nt == "C": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
908 GC = GC + 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
909 GC = GC/float(len(sequence)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
910 return GC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
911 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
912 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
913 def getGCDistance(tGC, gc2, L): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
914 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
915 Calculate the pseudo GC content distance |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
916 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
917 nt_coeff = L * tGC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
918 pc_nt = (1/float(L))*100 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
919 # |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
920 d = gc2 - tGC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
921 d = d * 100 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
922 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
923 f = math.floor(nt_coeff) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
924 c = math.ceil(nt_coeff) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
925 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
926 if d < 0: # |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
927 #print "case x",(abs(nt_coeff - f)), pc_nt, (abs(nt_coeff - f)) * pc_nt, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
928 d = d + (abs(nt_coeff - f)) * pc_nt |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
929 elif d > 0: # case y |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
930 #print "case y", abs(nt_coeff - c), pc_nt, abs(nt_coeff - c) * pc_nt, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
931 d = d - abs(nt_coeff - c) * pc_nt |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
932 elif d == 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
933 pass |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
934 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
935 d = round(d, 7) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
936 #d = max(0, abs(d)- ( max ( abs( math.ceil(nt_coeff)-(nt_coeff)) , abs(math.floor(nt_coeff)-(nt_coeff)) )/L)*100 ) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
937 return abs(d) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
938 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
939 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
940 def getSequenceEditDistance(SC, path): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
941 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
942 Calculate sequence edit distance of a solution to the constraint |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
943 """# |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
944 IUPAC = {"A":"A", "C":"C", "G":"G", "U":"U", "R":"AG", "Y":"CU", "S":"GC", "W":"AU","K":"GU", "M":"AC", "B":"CGU", "D":"AGU", "H":"ACU", "V":"ACG", "N":"ACGU"} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
945 edit = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
946 for i in xrange(len(SC)): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
947 if path[i] not in IUPAC[SC[i]]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
948 edit += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
949 return edit/float(len(path)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
950 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
951 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
952 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
953 def getTransitions(p): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
954 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
955 Retreive transitions of a specific path/sequence |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
956 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
957 transitions = [] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
958 for pos in xrange(len(p)): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
959 if pos == 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
960 transitions.append(str(pos) + "." + p[pos]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
961 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
962 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
963 insert = p[pos-1] + p[pos] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
964 transitions.append(str(pos) + "." + insert) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
965 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
966 return transitions |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
967 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
968 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
969 def evaporate(t, er): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
970 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
971 Evaporate the terrain's pheromone trails |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
972 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
973 terr, BP = t |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
974 c = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
975 for key in terr: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
976 p,l,c = terr[key] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
977 p *= (1-er) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
978 terr[key] = (p, l, c) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
979 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
980 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
981 def updateValue(distance, correction_term, omega): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
982 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
983 Retrieves a distance dependend pheromone value |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
984 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
985 if correction_term == 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
986 return 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
987 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
988 if distance == 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
989 return omega * correction_term |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
990 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
991 return (1/float(distance)) * correction_term |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
992 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
993 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
994 def trailBlaze(p, c_s, s, ds, dgc, dseq, dn, t, correction_terms, BPstack, verbose): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
995 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
996 Pheromone Update function accorinding to the quality of the solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
997 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
998 terr, BP = t |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
999 bpstack, LP = getbpStack(c_s) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1001 struct_correction_term , GC_correction_term, seq_correction_term = correction_terms |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1002 omega = 2.23 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1003 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1004 bs = updateValue(ds, struct_correction_term, omega) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1005 bGC = updateValue(dgc, GC_correction_term, omega) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1006 if dseq != "n.a.": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1007 bSeq = updateValue(dseq, seq_correction_term, omega) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1008 d = bs + bGC + bSeq |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1009 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1010 d = bs + bGC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1011 transitions = getTransitions(p) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1012 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1013 for trans in xrange(len(transitions)): # for each transition in the path |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1014 id1 = int(transitions[trans].split(".")[0]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1015 tar_id2 = int(BPstack[id1][1][0]) # getting requested position id2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1016 curr_id2 = int(bpstack[id1]) # getting the current situation |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1017 multiplicator = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1018 if tar_id2 == curr_id2 and id1 != tar_id2 and id1 != curr_id2: # case of a base pair, having both brackets on the correct position |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1019 multiplicator = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1020 elif tar_id2 == curr_id2 and id1 == tar_id2 and id1 == curr_id2: # case of a single stranded base in both structures |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1021 multiplicator = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1022 p, l, c = terr[transitions[trans]] # getting the pheromone and the length value of the single path transition |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1023 p += d * multiplicator |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1024 terr[transitions[trans]] = (p, l, c) # updating the values wihtin the terrain's |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1025 t = (terr, BP) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1026 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1027 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1028 def updateTerrain(p, c_s, s, ds, dgc, dseq, dn, t, er, correction_terms, BPstack, verbose, ant_count): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1029 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1030 General updating function |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1031 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1032 evaporate(t,er) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1033 trailBlaze(p, c_s, s, ds, dgc, dseq, dn, t, correction_terms, BPstack, verbose) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1034 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1035 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1036 def getUsedTime(start_time): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1037 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1038 Return the used time between -start time- and now. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1039 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1040 end_time = time.time() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1041 return end_time - start_time |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1042 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1043 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1044 def good2Go(SC, L, CC, STR): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1045 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1046 Check, if all input is correct and runnable |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1047 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1048 if (SC == 1 and L == 1 and CC == 1 and STR == 1): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1049 return True |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1050 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1051 print SC,L,CC,STR |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1052 return False |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1053 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1054 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1055 def getPathFromSelection( aps, s, terrain, alpha, beta, RNAfold, RNAfold_pattern, GC, SC, LP, verbose, IUPAC_compatibles, degreeOfSequenceInducement, IUPAC_reverseComplements, IUPAC, pseudoknots, strategy): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1056 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1057 Returns the winning path from a selection of pathes... |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1058 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1059 terr, BPs = terrain |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1060 win_path = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1061 for i in xrange(aps): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1062 # Generate Sequence |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1063 path = getPath(s, terr, BPs, alpha, beta, IUPAC, IUPAC_reverseComplements) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1064 # Measure sequence features and transform them into singular distances |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1065 distance_structural = float(getStructuralDistance(s, SC , path, RNAfold, verbose, LP, BPs, RNAfold_pattern, IUPAC_compatibles, degreeOfSequenceInducement, pseudoknots, strategy)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1066 distance_GC = float(getGCDistance(GC,getGC(path), len(path))) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1067 distance_seq = float(getSequenceEditDistance(SC, path)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1068 # Calculate Distance Score |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1069 D = distance_structural + distance_GC + distance_seq |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1070 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1071 # SELECT THE BEST-OUT-OF-k-SOLUTIONS according to distance score |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1072 if i == 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1073 win_path = (path, D, distance_structural, distance_GC, distance_seq) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1074 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1075 if D < win_path[1]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1076 win_path = (path, D, distance_structural, distance_GC, distance_seq) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1077 return win_path |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1078 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1079 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1080 def substr(x, string, subst): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1081 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1082 Classical substring function |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1083 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1084 s1 = string[:x-1] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1085 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1086 s2 = string[x-1:x] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1087 s3 = string[x:] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1088 #s2 = s[x+len(string)-x-1:] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1089 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1090 return s1 + subst + s3 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1091 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1092 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1093 def inConvergenceCorridor(d_struct, d_gc, BS_d_struct, BS_d_gc): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1094 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1095 Check if a solutions qualities are within the convergence corridor |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1096 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1097 struct_var = ((BS_d_struct/float(4)) + 3 ) * 4 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1098 gc_var = (BS_d_gc + 1/float(100) * 5) + BS_d_gc + 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1099 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1100 if d_struct <= struct_var and d_gc <= gc_var: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1101 return True |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1102 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1103 return False |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1104 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1105 def getGCSamplingValue(GC, tGCmax, tGCvar): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1106 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1107 Returns a suitable GC value, dependend on the user input: Either returning the single GC value, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1108 which the user entered, or a smpled GC value |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1109 from a designated distribution in it's interavals |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1110 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1111 returnval = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1112 if tGCmax == -1.0 and tGCvar == -1.0: # regular plain tGC value as requested |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1113 return GC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1114 elif tGCmax != -1.0 and tGCvar == -1.0: # uniform distribution tGC value sampling |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1115 if GC < tGCmax: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1116 tmp_GC = tGCmax |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1117 tGCmax = GC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1118 GC = tmp_GC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1119 while returnval <= 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1120 returnval = float(numpy.random.uniform(low=GC, high=tGCmax, size=1)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1121 return returnval |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1122 elif tGCmax == -1.0 and tGCvar != -1.0: # normal distribution tGC value sampling |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1123 while returnval <= 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1124 returnval = float(numpy.random.normal(GC, tGCvar, 1)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1125 return returnval |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1126 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1127 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1128 def reachableGC(C_struct): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1129 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1130 Checks if a demanded GC target content is reachable in dependence with the given sequence constraint. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1131 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1132 AU = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1133 for i in C_struct: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1134 if i == "A" or i == "U": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1135 AU += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1136 maxGC = 1 - (AU / float(len(C_struct))) # 1 - min_GC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1137 return maxGC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1138 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1139 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1140 def runColony(s, SC, objective_to_target_distance, GC, alpha, beta, evaporation_rate, correction_terms, verbose, IUPAC, IUPAC_compatibles, degreeOfSequenceInducement, IUPAC_reverseComplements, termination_convergence, convergence_count, reset_limit, improve, temperature, paramFile, pseudoknots, strategy): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1141 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1142 Execution function of a single ant colony finding one solution sequence |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1143 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1144 retString = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1145 retString2 = [] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1146 BPstack, LP = getBPStack(s, SC) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1147 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1148 rGC = reachableGC(SC) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1149 GC_message = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1150 if GC > rGC: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1151 print >> sys.stderr, "WARNING: Chosen target GC %s content is not reachable due to sequence constraint! Sequence Constraint GC-content is: %s" % (GC, rGC) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1152 GC = rGC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1153 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1154 # Initial Constraint Checks prior to execution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1155 STR = isValidStructure(s) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1156 START_SC , SC = checkSequenceConstraint(str(SC)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1157 START_LENGTH = checkSimilarLength(str(s), str(SC)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1158 START_constraint_compatibility , CompReport = checkConstaintCompatibility(BPstack, SC, IUPAC_compatibles) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1159 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1160 g2g = good2Go(START_SC, START_LENGTH, START_constraint_compatibility, STR) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1161 if (g2g == 1): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1162 start_time = time.time() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1163 max_time = 600 # seconds |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1164 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1165 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1166 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1167 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1168 #### |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1169 # INITIALIZATION OF THE RNA TOOLs |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1170 # |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1171 RNAfold = init_RNAfold(213, temperature, paramFile) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1172 #RNAdistance = init_RNAdistance() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1173 RNAfold_pattern = re.compile('.+\n([.()]+)\s.+') |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1174 #RNAdist_pattern = re.compile('.*\s([\d]+)') |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1175 # |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1176 #### |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1177 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1178 terrain = initTerrain(s) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1179 #print len(terrain), |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1180 terrain = applyTerrainModification(terrain, s, GC, SC, BPstack, IUPAC, IUPAC_compatibles, IUPAC_reverseComplements) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1181 #print len(terrain[0]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1182 #printTerrain(terrain) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1183 #exit(0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1184 global_ant_count = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1185 global_best_ants = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1186 criterion = False |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1187 met = True |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1188 ant_no = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1189 prev_res = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1190 seq = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1191 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1192 counter = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1193 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1194 dstruct_log = [] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1195 dGC_log = [] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1196 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1197 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1198 distance_structural = 1000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1199 distance_GC = 1000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1200 distance_seq = 1000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1201 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1202 convergence = convergence_count |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1203 convergence_counter = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1204 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1205 resets = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1206 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1207 path = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1208 curr_structure = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1209 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1210 Dscore = 100000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1211 distance_structural = 10000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1212 distance_GC = 10000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1213 distance_seq = 10000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1214 best_solution = (path, curr_structure, Dscore, distance_structural, distance_GC, distance_seq) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1215 best_solution_local = (path, curr_structure, Dscore, distance_structural, distance_GC, distance_seq) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1216 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1217 best_solution_since = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1218 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1219 ants_per_selection = 10 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1220 if len(LP) > 0 : |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1221 for lp in LP: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1222 s = substr(lp + 1, s, ".") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1223 s = substr(LP[lp] + 1, s, ".") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1224 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1225 init = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1226 while criterion != met and getUsedTime(start_time) < max_time: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1227 iteration_start = time.time() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1228 global_ant_count += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1229 global_best_ants += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1230 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1231 path_info = getPathFromSelection(ants_per_selection, s, terrain, alpha, beta, RNAfold, RNAfold_pattern, GC, SC, LP, verbose, IUPAC_compatibles, degreeOfSequenceInducement, IUPAC_reverseComplements, IUPAC, pseudoknots, strategy) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1232 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1233 distance_structural_prev = distance_structural |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1234 distance_GC_prev = distance_GC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1235 distance_seq_prev = distance_seq |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1236 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1237 path, Dscore , distance_structural, distance_GC, distance_seq = path_info |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1238 curr_structure = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1239 if pseudoknots: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1240 curr_structure = getPKStructure(path, strategy) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1241 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1242 curr_structure = getRNAfoldStructure(path, RNAfold) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1243 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1244 curr_solution = (path,curr_structure, Dscore, distance_structural, distance_GC, distance_seq) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1245 # BEST SOLUTION PICKING |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1246 if improve == "h": # hierarchical check |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1247 # for the global best solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1248 if distance_structural < best_solution[3] or (distance_structural == best_solution[3] and distance_GC < best_solution[4]): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1249 best_solution = curr_solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1250 ant_no = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1251 # for the local (reset) best solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1252 if distance_structural < best_solution_local[3] or (distance_structural == best_solution_local[3] and distance_GC < best_solution_local[4]): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1253 best_solution_local = curr_solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1254 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1255 elif improve == "s": #score based check |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1256 # store best global solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1257 if Dscore < best_solution[2]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1258 best_solution = curr_solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1259 ant_no = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1260 # store best local solution for this reset |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1261 if Dscore < best_solution_local[2]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1262 best_solution_local = curr_solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1263 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1264 # OLD ' BEST SOLUTION ' PICKING |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1265 # if Dscore < best_solution[2]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1266 # best_solution = (path,curr_structure, Dscore, distance_structural, distance_GC, distance_seq) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1267 # |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1268 # if Dscore < best_solution_local[2]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1269 # best_solution_local = (path,curr_structure, Dscore, distance_structural, distance_GC, distance_seq) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1270 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1271 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1272 distance_DN = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1273 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1274 if verbose: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1275 print "SCORE " + str(Dscore) + " Resets " + str(resets) + " #Ant " + str(global_ant_count) + " out of " + str(ants_per_selection) + " cc " + str(convergence_counter) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1276 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1277 print s, " <- target struct" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1278 print best_solution[0] , " <- BS since ", str(best_solution_since), "Size of Terrrain:", len(terrain[0]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1279 print best_solution[1] , " <- BS Dscore " + str(best_solution[2]) + " ds " + str(best_solution[3]) + " dGC " + str(best_solution[4]) + " dseq " + str(best_solution[5])+ " LP " + str(len(LP)) + " <- best solution stats" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1280 print curr_structure, " <- CS" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1281 print path, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1282 print " <- CS", "Dscore", str(Dscore), "ds", distance_structural, "dGC", distance_GC, "GC", getGC(path)*100, "Dseq", distance_seq |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1283 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1284 #### UPDATING THE TERRAIN ACCORDING TO THE QUALITY OF THE CURRENT BESTO-OUT-OF-k SOLUTION |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1285 updateTerrain(path, curr_structure, s, distance_structural,distance_GC, distance_seq, distance_DN, terrain, evaporation_rate, correction_terms, BPstack, verbose, global_ant_count) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1286 #### |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1287 if verbose: print "Used time for one iteration", time.time() - iteration_start |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1288 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1289 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1290 # CONVERGENCE AND TERMINATION CRITERION MANAGEMENT |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1291 #print distance_structural, distance_GC, best_solution_local[3], best_solution_local[4] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1292 if inConvergenceCorridor(curr_solution[3], curr_solution[4], best_solution_local[3], best_solution_local[4]): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1293 convergence_counter += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1294 if distance_structural_prev == distance_structural and distance_GC_prev == distance_GC: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1295 convergence_counter += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1296 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1297 if best_solution[3] == objective_to_target_distance: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1298 if best_solution[4] == 0.0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1299 break |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1300 ant_no = ant_no + 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1301 convergence_counter -= 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1302 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1303 ant_no = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1304 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1305 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1306 if ant_no == termination_convergence or resets >= reset_limit or global_ant_count >= 100000 or best_solution_since == 5: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1307 break |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1308 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1309 # RESET |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1310 if ant_no < termination_convergence and convergence_counter >= convergence: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1311 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1312 terrain = initTerrain(s) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1313 terrain = applyTerrainModification(terrain, s, GC, SC, BPstack, IUPAC, IUPAC_compatibles, IUPAC_reverseComplements) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1314 criterion = False |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1315 met = True |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1316 ant_no = 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1317 prev_res = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1318 pre_path = "_" * len(s) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1319 path = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1320 curr_structure = "" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1321 counter = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1322 Dscore = 100000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1323 distance_structural = 1000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1324 distance_GC = 1000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1325 distance_seq = 1000 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1326 best_solution_local = (path, curr_structure, Dscore, distance_structural, distance_GC, distance_seq) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1327 convergence = convergence_count |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1328 convergence_counter = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1329 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1330 if resets == 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1331 sentinel_solution = best_solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1332 best_solution_since += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1333 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1334 if best_solution[2] < sentinel_solution[2]: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1335 sentinel_solution = best_solution |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1336 best_solution_since = 0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1337 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1338 best_solution_since += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1339 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1340 resets += 1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1341 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1342 duration = getUsedTime(start_time) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1343 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1344 retString += "|Ants:" + str(global_ant_count) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1345 retString += "|Resets:" + str(resets) + "/" + str(reset_limit) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1346 retString += "|AntsTC:" + str(termination_convergence) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1347 retString += "|CC:" + str(convergence_count) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1348 retString += "|IP:" + str(improve) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1349 retString += "|BSS:" + str(best_solution_since) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1350 #if GC_message != "": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1351 # retString += GC_message + "\n" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1352 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1353 sequence = best_solution[0] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1354 struct = best_solution[1] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1355 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1356 retString += "|LP:" + str(len(LP)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1357 retString += "|ds:" + str(getStructuralDistance(s,SC, sequence, RNAfold, verbose, LP, BPstack, RNAfold_pattern, IUPAC_compatibles, degreeOfSequenceInducement, pseudoknots, strategy)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1358 retString += "|dGC:" + str(best_solution[4]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1359 retString += "|GC:" + str(getGC(sequence)*100) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1360 retString += "|dseq:" + str(getSequenceEditDistance(SC, sequence)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1361 retString += "|L:" + str(len(sequence)) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1362 retString += "|Time:" + str(duration) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1363 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1364 retString2.append(struct) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1365 retString2.append(sequence) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1366 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1367 # CLOSING THE PIPES TO THE PROGRAMS |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1368 RNAfold.communicate() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1369 #RNAdistance.communicate() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1370 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1371 else: # Structural premisses are not met, htherefore the program will halt with a failure message |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1372 retString += "\nSome mistake detected\n" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1373 retString += "SequenceConstraintCheck: " + str(START_SC) + "\nSequenceConstraint: " + str(SC) + "\nLengthCheck: " + str(START_LENGTH) + "\nConstraintCompatibility: " + str(START_constraint_compatibility)+ "\n" + CompReport + "\n" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1374 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1375 return (retString, retString2) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1376 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1377 def findSequence(structure, Cseq, tGC, colonies, name, alpha, beta, evaporation_rate, struct_correction_term, GC_correction_term, seq_correction_term, degreeOfSequenceInducement, file_id, verbose, output_verbose, tGCmax, tGCvar, termination_convergence, convergence_count, reset_limit, improve, seed, temperature, paramFile, pseudoknots, strategy, useGU, return_mod = False): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1378 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1379 MAIN antaRNA - ant assembled RNA |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1380 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1381 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1382 if seed != "none": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1383 random.seed(seed) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1384 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1385 if Cseq == "": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1386 sequenceconstraint = "N" * len(structure) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1387 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1388 sequenceconstraint = str(Cseq) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1389 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1390 alpha = float(alpha) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1391 beta = float(beta) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1392 tGC = float(tGC) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1393 evaporation_rate = float(evaporation_rate) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1394 struct_correction_term = float(struct_correction_term) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1395 GC_correction_term = float(GC_correction_term) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1396 seq_correction_term = float(seq_correction_term) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1397 colonies = int(colonies) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1398 file_id = str(file_id) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1399 tmp_verbose = verbose |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1400 tmp_output_verbose = output_verbose |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1401 verbose = tmp_output_verbose # Due to later change, this is a twistaround and a switching of purpose |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1402 output_verbose = tmp_verbose # Due to later change, this is a twistaround and a switching of purpose |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1403 correction_terms = struct_correction_term, GC_correction_term, seq_correction_term |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1404 temperature = float(temperature) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1405 print_to_STDOUT = (file_id == "STDOUT") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1406 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1407 useGU = useGU |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1408 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1409 if return_mod == False: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1410 if print_to_STDOUT == False: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1411 outfolder = '/'.join(file_id.strip().split("/")[:-1]) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1412 curr_dir = os.getcwd() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1413 if not os.path.exists(outfolder): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1414 os.makedirs(outfolder) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1415 os.chdir(outfolder) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1416 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1417 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1418 sequenceconstraint = transform(sequenceconstraint) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1419 ############################################### |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1420 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1421 # Allowed deviation from the structural target: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1422 objective_to_target_distance = 0.0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1423 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1424 # Loading the IUPAC copatibilities of nuleotides and their abstract representing symbols |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1425 IUPAC = {"A":"A", "C":"C", "G":"G", "U":"U", "R":"AG", "Y":"CU", "S":"GC", "W":"AU","K":"GU", "M":"AC", "B":"CGU", "D":"AGU", "H":"ACU", "V":"ACG", "N":"ACGU"} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1426 IUPAC_compatibles = loadIUPACcompatibilities(IUPAC, useGU) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1427 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1428 IUPAC_reverseComplements = {} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1429 if useGU == False: ## Without the GU basepair |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1430 IUPAC_reverseComplements = {"A":"U", "C":"G", "G":"C", "U":"A", "R":"UC", "Y":"AG", "S":"GC", "W":"UA","K":"CA", "M":"UG", "B":"AGC", "D":"ACU", "H":"UGA", "V":"UGC", "N":"ACGU"} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1431 else: ## allowing the GU basepair |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1432 IUPAC_reverseComplements = {"A":"U", "C":"G", "G":"UC", "U":"AG", "R":"UC", "Y":"AG", "S":"UGC", "W":"UAG","K":"UCAG", "M":"UG", "B":"AGCU", "D":"AGCU", "H":"UGA", "V":"UGC", "N":"ACGU"} |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1433 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1434 result = [] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1435 for col in xrange(colonies): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1436 # Checking the kind of taget GC value should be used |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1437 GC = getGCSamplingValue(tGC, tGCmax, tGCvar) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1438 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1439 # Actual execution of a ant colony procesdure |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1440 output_v, output_w = runColony(structure, sequenceconstraint, objective_to_target_distance, GC, alpha, beta, evaporation_rate, correction_terms, verbose, IUPAC, IUPAC_compatibles, degreeOfSequenceInducement, IUPAC_reverseComplements, termination_convergence, convergence_count, reset_limit, improve, temperature, paramFile, pseudoknots, strategy) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1441 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1442 # Post-Processing the output of a ant colony procedure |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1443 line = ">" + name + str(col) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1444 if output_verbose: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1445 line += "|Cstr:" + structure + "|Cseq:" + sequenceconstraint + "|Alpha:" + str(alpha) + "|Beta:" + str(beta) + "|tGC:" + str(GC) + "|ER:" + str(evaporation_rate) + "|Struct_CT:" + str(struct_correction_term) + "|GC_CT:" + str(GC_correction_term) + "|Seq_CT:" + str(seq_correction_term) + output_v + "\n" + "\n".join(output_w) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1446 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1447 line += "\n" + output_w[1] |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1448 if return_mod == False: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1449 if print_to_STDOUT: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1450 print line |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1451 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1452 if col == 0: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1453 print2file(file_id, line, 'w') |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1454 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1455 print2file(file_id, line, 'a') |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1456 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1457 result.append(line) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1458 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1459 if return_mod == True: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1460 return result |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1461 if print_to_STDOUT == False: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1462 os.chdir(curr_dir) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1463 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1464 def execute(args): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1465 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1466 CHECK AND PARSE THE COMMAND LINE STUFF |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1467 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1468 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1469 # Checking the arguments, parsed from the shell |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1470 ############################################### |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1471 name = args.name |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1472 structure = args.Cstr |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1473 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1474 if args.Cseq == "": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1475 sequenceconstraint = "N" * len(structure) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1476 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1477 sequenceconstraint = args.Cseq |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1478 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1479 seed = args.seed |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1480 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1481 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1482 alpha = args.alpha |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1483 beta = args.beta |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1484 tGC = args.tGC |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1485 if tGC < 0 or tGC > 1: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1486 print "Error: Chosen tGC not in range [0,1]" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1487 exit(1) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1488 evaporation_rate = args.ER |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1489 struct_correction_term = args.Cstrweight |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1490 GC_correction_term = args.Cgcweight |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1491 seq_correction_term = args.Cseqweight |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1492 colonies = args.noOfColonies |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1493 degreeOfSequenceInducement = args.level |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1494 file_id = args.output_file |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1495 verbose = args.verbose |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1496 output_verbose = args.output_verbose |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1497 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1498 tGCmax = args.tGCmax |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1499 tGCvar = args.tGCvar |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1500 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1501 termination_convergence = args.antsTerConv |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1502 convergence_count = args.ConvergenceCount |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1503 temperature = args.temperature |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1504 reset_limit = args.Resets |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1505 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1506 improve = args.improve_procedure |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1507 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1508 ### RNAfold parameterfile |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1509 paramFile = args.paramFile |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1510 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1511 # Using the pkiss program under user changeable parameters |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1512 pseudoknots = args.pseudoknots |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1513 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1514 # Loading the optimized parameters for pseudoknots and ignore user input |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1515 if args.pseudoknot_parameters: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1516 alpha = 1.0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1517 beta = 0.1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1518 evaporation_rate = 0.2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1519 struct_correction_term = 0.1 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1520 GC_correction_term = 1.0 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1521 seq_correction_term = 0.5 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1522 termination_convergence = 50 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1523 convergence_count = 100 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1524 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1525 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1526 strategy = args.strategy |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1527 useGU = args.useGUBasePair |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1528 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1529 checkForViennaTools() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1530 if pseudoknots: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1531 checkForpKiss() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1532 findSequence(structure, sequenceconstraint, tGC, colonies, name, alpha, beta, evaporation_rate, struct_correction_term, GC_correction_term, seq_correction_term, degreeOfSequenceInducement, file_id, verbose, output_verbose, tGCmax, tGCvar, termination_convergence, convergence_count, reset_limit, improve, seed, temperature, paramFile, pseudoknots, strategy, useGU) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1533 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1534 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1535 def exe(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1536 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1537 MAIN EXECUTABLE WHICH PARSES THE INPUT LINE |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1538 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1539 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1540 argument_parser = argparse.ArgumentParser( |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1541 description = """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1542 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1543 ######################################################################### |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1544 # antaRNA - ant assembled RNA # |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1545 # -> Ant Colony Optimized RNA Sequence Design # |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1546 # ------------------------------------------------------------ # |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1547 # Robert Kleinkauf (c) 2015 # |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1548 # Bioinformatics, Albert-Ludwigs University Freiburg, Germany # |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1549 ######################################################################### |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1550 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1551 - For antaRNA only the VIENNNA RNA Package must be installed on your linux system. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1552 antaRNA will only check, if the executables of RNAfold and RNAdistance of the ViennaRNA package can be found. If those programs are |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1553 not installed correctly, no output will be generated, an also no warning will be prompted. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1554 So the binary path of the Vienna Tools must be set up correctly in your system's PATH variable in order to run antaRNA correctly! |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1555 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1556 - antaRNA was only tested under Linux. |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1557 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1558 - For questions and remarks please feel free to contact us at http://www.bioinf.uni-freiburg.de/ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1559 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1560 """, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1561 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1562 epilog = """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1563 Example calls: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1564 python antaRNA.py --Cstr "...(((...)))..." --tGC 0.5 -n 2 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1565 python antaRNA.py --Cstr ".........AAA(((...)))AAA........." --tGC 0.5 -n 10 --output_file /path/to/antaRNA_TESTRUN -ov |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1566 python antaRNA.py --Cstr "BBBBB....AAA(((...)))AAA....BBBBB" --Cseq "NNNNANNNNNCNNNNNNNNNNNGNNNNNNUNNN" --tGC 0.5 -n 10 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1567 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1568 ######################################################################### |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1569 # --- Hail to the Queen!!! All power to the swarm!!! --- # |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1570 ######################################################################### |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1571 """, |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1572 #formatter_class=RawTextHelpFormatter |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1573 ) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1574 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1575 # mandatorys |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1576 argument_parser.add_argument("-Cstr", "--Cstr", help="Structure constraint using RNA dotbracket notation with fuzzy block constraint. \n(TYPE: %(type)s)\n\n", type=str, required=True) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1577 argument_parser.add_argument("-tGC", "--tGC", help="Objective target GC content in [0,1].\n(TYPE: %(type)s)\n\n", type=float, required=True) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1578 argument_parser.add_argument("-n", "--noOfColonies", help="Number of sequences which shall be produced. \n(TYPE: %(type)s)\n\n\n\n", type=int, default=1) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1579 argument_parser.add_argument("-GU", "--useGUBasePair", help="Allowing GU base pairs. \n\n", action="store_true") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1580 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1581 argument_parser.add_argument("-s", "--seed", help = "Provides a seed value for the used pseudo random number generator.\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=str, default="none") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1582 argument_parser.add_argument("-ip", "--improve_procedure", help = "Select the improving method. h=hierarchical, s=score_based.\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=str, default="s") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1583 argument_parser.add_argument("-r", "--Resets", help = "Amount of maximal terrain resets, until the best solution is retuned as solution.\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=int, default=5) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1584 argument_parser.add_argument("-CC", "--ConvergenceCount", help = "Delimits the convergence count criterion for a reset.\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=int, default=130) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1585 argument_parser.add_argument("-aTC", "--antsTerConv", help = "Delimits the amount of internal ants for termination convergence criterion for a reset.\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=int, default=50) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1586 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1587 argument_parser.add_argument("-p", "--pseudoknots", help = "Switch to pseudoknot based prediction using pKiss. Check the pseudoknot parameter usage!!!\n\n", action="store_true") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1588 argument_parser.add_argument("-pkPar", "--pseudoknot_parameters", help = "Enable optimized parameters for the usage of pseudo knots (Further parameter input ignored).\n\n", action="store_true") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1589 argument_parser.add_argument("--strategy", help = "Defining the pKiss folding strategy.\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=str, default="A") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1590 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1591 # Mutual Exclusiv target GC distribution variables |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1592 #tGCgroup = argument_parser.add_mutually_exclusive_group() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1593 argument_parser.add_argument("-tGCmax", "--tGCmax", help = "Provides a maximum tGC value [0,1] for the case of uniform distribution sampling. The regular tGC value serves as minimum value.\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=float, default=-1.0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1594 argument_parser.add_argument("-tGCvar", "--tGCvar", help = "Provides a tGC variance (sigma square) for the case of normal distribution sampling. The regular tGC value serves as expectation value (mu).\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=float, default=-1.0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1595 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1596 argument_parser.add_argument("-t", "--temperature", help = "Provides a temperature for the folding algorithms.\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=float, default=37.0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1597 argument_parser.add_argument("-P", "--paramFile", help = "Changes the energy parameterfile of RNAfold. If using this explicitly, please provide a suitable energy file delivered by RNAfold. \n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=str, default="") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1598 argument_parser.add_argument("-of","--output_file", help="Provide a path and an output file, e.g. \"/path/to/the/target_file\". \n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=str, default="STDOUT") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1599 argument_parser.add_argument("-Cseq", "--Cseq", help="Sequence constraint using RNA nucleotide alphabet {A,C,G,U} and wild-card \"N\". \n(TYPE: %(type)s)\n\n", type=str, default = "") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1600 argument_parser.add_argument("-l", "--level", help="Sets the level of allowed influence of sequence constraint on the structure constraint [0:no influence; 3:extensive influence].\n(TYPE: %(type)s)\n\n", type=int, default = 1) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1601 argument_parser.add_argument("--name", help="Defines a name which is used in the sequence output. \n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=str, default="antaRNA_") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1602 argument_parser.add_argument("-a", "--alpha", help="Sets alpha, probability weight for terrain pheromone influence. [0,1] \n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=float, default=1.0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1603 argument_parser.add_argument("-b", "--beta", help="Sets beta, probability weight for terrain path influence. [0,1]\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=float, default=1.0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1604 argument_parser.add_argument("-er", "--ER", help="Pheromone evaporation rate. \n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=float, default=0.2) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1605 argument_parser.add_argument("-Cstrw", "--Cstrweight", help="Structure constraint quality weighting factor. [0,1]\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=float, default=0.5) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1606 argument_parser.add_argument("-Cgcw", "--Cgcweight", help="GC content constraint quality weighting factor. [0,1]\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n", type=float, default=5.0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1607 argument_parser.add_argument("-Cseqw", "--Cseqweight", help="Sequence constraint quality weighting factor. [0,1]\n(DEFAULT: %(default)s, TYPE: %(type)s)\n\n\n", type=float, default=1.0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1608 argument_parser.add_argument("-ov", "--output_verbose", help="Displayes intermediate output.\n\n", action="store_true") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1609 argument_parser.add_argument("-v", "--verbose", help="Prints additional features and stats to the headers of the produced sequences. Also adds the structure of the sequence.\n\n", action="store_true") |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1610 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1611 args = argument_parser.parse_args() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1612 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1613 execute(args) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1614 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1615 def checkForViennaTools(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1616 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1617 Checking for the presence of the Vienna tools in the system by which'ing for RNAfold and RNAdistance |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1618 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1619 RNAfold_output = subprocess.Popen(["which", "RNAfold"], stdout=subprocess.PIPE).communicate()[0].strip() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1620 if len(RNAfold_output) > 0 and RNAfold_output.find("found") == -1 and RNAfold_output.find(" no ") == -1: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1621 return True |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1622 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1623 print "It seems the Vienna RNA Package is not installed on your machine. Please do so!" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1624 print "You can get it at http://www.tbi.univie.ac.at/" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1625 exit(0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1626 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1627 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1628 def checkForpKiss(): |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1629 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1630 Checking for the presence of pKiss |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1631 """ |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1632 pKiss_output = subprocess.Popen(["which", "pKiss"], stdout=subprocess.PIPE).communicate()[0].strip() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1633 if len(pKiss_output) > 0 and pKiss_output.find("found") == -1 and pKiss_output.find(" no ") == -1: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1634 return True |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1635 else: |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1636 print "It seems that pKiss is not installed on your machine. Please do so!" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1637 print "You can get it at http://bibiserv2.cebitec.uni-bielefeld.de/pkiss" |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1638 exit(0) |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1639 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1640 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1641 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1642 if __name__ == "__main__": |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1643 |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1644 exe() |
fcf4719d3831
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/antarna/ commit 71414cf7f040d610afc3f02be31446efc3a82a40-dirty
rnateam
parents:
diff
changeset
|
1645 |