-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
69 lines (46 loc) · 1.82 KB
/
main.py
File metadata and controls
69 lines (46 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from utils import *
def main():
print("=== DNA Sequence Analyzer (CLI Version) ===")
seq1 = input("Enter original DNA sequence: ").upper()
seq2 = input("Enter mutated DNA sequence: ").upper()
if not seq1 or not seq2:
print("Error: Please enter valid sequences")
return
print("\n--- Basic Analysis ---")
print("Length:", len(seq1))
print("GC Content: {:.2f}%".format(gc_content(seq1)))
rna = transcribe(seq1)
print("RNA:", rna)
print("\n--- Alignment ---")
alignment = align_sequences(seq1, seq2)
print(alignment)
print("Score:", alignment.score)
print("\n--- ORF Detection ---")
orfs = find_orfs(seq1)
filtered_orfs = filter_orfs(orfs)
if not filtered_orfs:
print("No significant ORFs found.")
return
scored_orfs = []
for start, end in filtered_orfs:
score = score_orf(seq1, start, end)
scored_orfs.append((start, end, score))
scored_orfs.sort(key=lambda x: x[2], reverse=True)
for i, (start, end, score) in enumerate(scored_orfs[:3]):
print(f"ORF {i+1}: Start={start}, End={end}, Length={end-start}, Score={score:.2f}")
print("\n--- Protein Sequences ---")
proteins = translate_orfs(seq1, [(s, e) for s, e, _ in scored_orfs[:3]])
for i, (start, end, protein) in enumerate(proteins):
print(f"\nORF {i+1} Protein:")
print(protein)
print("\n--- Mutation Analysis ---")
mutations = detect_mutations(seq1, seq2)
orf_mutations = mutations_in_orfs(mutations, filtered_orfs)
if not orf_mutations:
print("No mutations inside ORFs.")
else:
for pos, a, b in orf_mutations:
mtype = classify_mutation(seq1, seq2, pos)
print(f"Position {pos}: {a} → {b} ({mtype})")
if __name__ == "__main__":
main()