smartTranscend commited on
Commit
84c4480
·
verified ·
1 Parent(s): f46534f

Update mutation_analysis.py

Browse files
Files changed (1) hide show
  1. mutation_analysis.py +18 -8
mutation_analysis.py CHANGED
@@ -1,16 +1,26 @@
1
  # mutation_analysis.py
2
 
3
- def classify_mutation(wt_protein: str, mut_protein: str) -> str:
 
 
4
  """
5
- Classify mutation based on protein sequences.
6
  """
7
- if wt_protein == mut_protein:
8
- return "synonymous mutation"
9
 
10
- if "*" in mut_protein:
11
- return "nonsense mutation (premature stop codon)"
 
 
 
12
 
13
- if len(mut_protein) != len(wt_protein):
 
 
14
  return "frameshift mutation"
15
 
16
- return "missense mutation"
 
 
 
 
 
 
1
  # mutation_analysis.py
2
 
3
+ STOP_CODONS = {"UAA", "UAG", "UGA"}
4
+
5
+ def classify_mutation(wt_protein: str, mutant_protein: str) -> str:
6
  """
7
+ 依照正確的分子生物學邏輯分類突變型態
8
  """
 
 
9
 
10
+ # 1️⃣ Nonsense mutation:出現提前終止
11
+ # (翻譯後蛋白中出現 STOP 或明顯提前終止)
12
+ if len(mutant_protein) < len(wt_protein):
13
+ # 若是「提前終止」但 reading frame 未被打亂 → nonsense
14
+ return "nonsense mutation"
15
 
16
+ # 2️⃣ Frameshift mutation:reading frame 改變
17
+ # (長度變化且非單一替換)
18
+ if len(mutant_protein) != len(wt_protein):
19
  return "frameshift mutation"
20
 
21
+ # 3️⃣ Missense mutation:長度相同但胺基酸不同
22
+ if wt_protein != mutant_protein:
23
+ return "missense mutation"
24
+
25
+ # 4️⃣ 沒有變化
26
+ return "no mutation"