Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ from hmmlearn import hmm
|
|
6 |
# Function to encode DNA sequence
|
7 |
def encode_sequence(seq):
|
8 |
encoding = {'A': 0, 'C': 1, 'G': 2, 'T': 3}
|
9 |
-
return np.array([encoding
|
10 |
|
11 |
# Function to calculate GC content
|
12 |
def calculate_gc_content(seq):
|
@@ -35,7 +35,11 @@ def analyze_dark_matter(sequence):
|
|
35 |
|
36 |
# HMM analysis
|
37 |
encoded_seq = encode_sequence(str(seq))
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
|
40 |
regulatory_regions = []
|
41 |
current_start = None
|
|
|
6 |
# Function to encode DNA sequence
|
7 |
def encode_sequence(seq):
|
8 |
encoding = {'A': 0, 'C': 1, 'G': 2, 'T': 3}
|
9 |
+
return np.array([encoding.get(base.upper(), -1) for base in seq])
|
10 |
|
11 |
# Function to calculate GC content
|
12 |
def calculate_gc_content(seq):
|
|
|
35 |
|
36 |
# HMM analysis
|
37 |
encoded_seq = encode_sequence(str(seq))
|
38 |
+
valid_indices = encoded_seq != -1
|
39 |
+
if np.any(valid_indices):
|
40 |
+
logprob, hidden_states = model.decode(encoded_seq[valid_indices].reshape(-1, 1))
|
41 |
+
else:
|
42 |
+
hidden_states = []
|
43 |
|
44 |
regulatory_regions = []
|
45 |
current_start = None
|