Spaces:
Running
Running
supercat666
commited on
Commit
•
1d62c05
1
Parent(s):
2c449b4
fix bugs
Browse files
cas12.py
CHANGED
@@ -175,13 +175,23 @@ def generate_genbank_file_from_data(formatted_data, gene_sequence, gene_symbol,
|
|
175 |
record.annotations["molecule_type"] = "DNA"
|
176 |
SeqIO.write(record, output_path, "genbank")
|
177 |
|
|
|
178 |
def generate_bed_file_from_data(formatted_data, output_path):
|
179 |
with open(output_path, 'w') as bed_file:
|
180 |
for data in formatted_data:
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
record.annotations["molecule_type"] = "DNA"
|
176 |
SeqIO.write(record, output_path, "genbank")
|
177 |
|
178 |
+
|
179 |
def generate_bed_file_from_data(formatted_data, output_path):
|
180 |
with open(output_path, 'w') as bed_file:
|
181 |
for data in formatted_data:
|
182 |
+
try:
|
183 |
+
# Ensure data has the expected number of elements
|
184 |
+
if len(data) < 7:
|
185 |
+
raise ValueError("Incomplete data item")
|
186 |
+
|
187 |
+
chrom = data[0]
|
188 |
+
start = data[1]
|
189 |
+
end = data[2]
|
190 |
+
strand = '+' if data[3] == '+' else '-'
|
191 |
+
gRNA = data[5]
|
192 |
+
score = data[6] # Ensure this index exists
|
193 |
+
|
194 |
+
bed_file.write(f"{chrom}\t{start}\t{end}\t{gRNA}\t{score}\t{strand}\n")
|
195 |
+
except ValueError as e:
|
196 |
+
print(f"Skipping an item due to error: {e}")
|
197 |
+
continue
|