Accelernate commited on
Commit
0c41fc3
·
verified ·
1 Parent(s): 8d7db0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
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[base] for base in seq if base in 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
- logprob, hidden_states = model.decode(encoded_seq.reshape(-1, 1))
 
 
 
 
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