Jayesh13 commited on
Commit
9410fc6
·
verified ·
1 Parent(s): b33eb44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -72,8 +72,11 @@ def find_new_boundary_repeats(fragments, final_repeats, overlap=50):
72
  return new_repeats
73
 
74
  def get_or_process_sequence(sequence, analysis_type, overlap=50):
75
- sequence_hash = hash_sequence(sequence)
76
- cached = results_collection.find_one({"_id": sequence_hash, "analysis_type": analysis_type})
 
 
 
77
  if cached:
78
  return cached["repeats"]
79
 
@@ -111,13 +114,17 @@ def get_or_process_sequence(sequence, analysis_type, overlap=50):
111
  for k, v in hetero_repeats.items():
112
  final_repeats[k] += v
113
 
 
114
  results_collection.insert_one({
115
  "_id": sequence_hash,
 
116
  "analysis_type": analysis_type,
117
  "repeats": dict(final_repeats)
118
  })
 
119
  return final_repeats
120
 
 
121
  def process_excel(excel_data, analysis_type):
122
  repeats = set()
123
  sequence_data = []
 
72
  return new_repeats
73
 
74
  def get_or_process_sequence(sequence, analysis_type, overlap=50):
75
+ # Combine sequence and analysis_type to generate a unique hash
76
+ hash_input = f"{sequence}_{analysis_type}"
77
+ sequence_hash = hash_sequence(hash_input)
78
+
79
+ cached = results_collection.find_one({"_id": sequence_hash})
80
  if cached:
81
  return cached["repeats"]
82
 
 
114
  for k, v in hetero_repeats.items():
115
  final_repeats[k] += v
116
 
117
+ # Store result in MongoDB using combined hash
118
  results_collection.insert_one({
119
  "_id": sequence_hash,
120
+ "sequence": sequence,
121
  "analysis_type": analysis_type,
122
  "repeats": dict(final_repeats)
123
  })
124
+
125
  return final_repeats
126
 
127
+
128
  def process_excel(excel_data, analysis_type):
129
  repeats = set()
130
  sequence_data = []