Update app.py
Browse files
app.py
CHANGED
|
@@ -50,8 +50,54 @@ def cpg_ratio(seq):
|
|
| 50 |
expected = (g * c) / length
|
| 51 |
return cg / expected if expected > 0 else 0
|
| 52 |
|
| 53 |
-
def tata_box_presence(seq):
|
| 54 |
-
return int("TATA" in seq.upper())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
def avg_bendability(seq):
|
| 57 |
seq = seq.upper()
|
|
|
|
| 50 |
expected = (g * c) / length
|
| 51 |
return cg / expected if expected > 0 else 0
|
| 52 |
|
| 53 |
+
#def tata_box_presence(seq):
|
| 54 |
+
# return int("TATA" in seq.upper())
|
| 55 |
+
def deltaG_stem_loop(seq):
|
| 56 |
+
"""
|
| 57 |
+
Identify the strongest stem-loop in a DNA sequence
|
| 58 |
+
and return ΔG of the stem only (kcal/mol).
|
| 59 |
+
"""
|
| 60 |
+
|
| 61 |
+
seq = seq.upper()
|
| 62 |
+
rna = seq.replace("T", "U")
|
| 63 |
+
|
| 64 |
+
# Nearest-neighbour ΔG values (kcal/mol)
|
| 65 |
+
nn = {
|
| 66 |
+
"AA": -0.9, "AU": -1.1, "UA": -1.3, "CA": -0.9,
|
| 67 |
+
"CU": -2.1, "GA": -1.3, "GU": -1.1, "UU": -0.9,
|
| 68 |
+
"AC": -0.9, "AG": -1.3, "UG": -1.5, "UC": -1.5,
|
| 69 |
+
"CC": -1.7, "CG": -2.4, "GC": -3.4, "GG": -1.5
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
# Reverse complement helper
|
| 73 |
+
def rc(s):
|
| 74 |
+
comp = str.maketrans("ATCG", "TAGC")
|
| 75 |
+
return s.translate(comp)[::-1]
|
| 76 |
+
|
| 77 |
+
best_stem = ""
|
| 78 |
+
deltaG = 0.0
|
| 79 |
+
|
| 80 |
+
# Search for inverted repeats (possible stems)
|
| 81 |
+
for i in range(len(seq)):
|
| 82 |
+
for j in range(i + 4, len(seq)): # minimum 4 nt stem
|
| 83 |
+
left = rna[i:j]
|
| 84 |
+
right = rna[j:]
|
| 85 |
+
left_rc = rc(left).replace("T", "U")
|
| 86 |
+
|
| 87 |
+
if left_rc in right:
|
| 88 |
+
# calculate ΔG of this stem
|
| 89 |
+
total_DeltaG = 0.0
|
| 90 |
+
for k in range(len(left) - 1):
|
| 91 |
+
pair = left[k:k+2]
|
| 92 |
+
if pair in nn:
|
| 93 |
+
total_DeltaG += nn[pair]
|
| 94 |
+
|
| 95 |
+
# Update if stronger (more negative) or first found
|
| 96 |
+
if total_DeltaG < deltaG or best_stem == "":
|
| 97 |
+
best_stem = left
|
| 98 |
+
deltaG = total_DeltaG
|
| 99 |
+
|
| 100 |
+
return deltaG
|
| 101 |
|
| 102 |
def avg_bendability(seq):
|
| 103 |
seq = seq.upper()
|