annotate antaRNA.py @ 18:a9a0fb585968 draft default tip

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