genetic-variant-interpreter / mutation_analysis.py
smartTranscend's picture
Update mutation_analysis.py
84c4480 verified
raw
history blame contribute delete
857 Bytes
# mutation_analysis.py
STOP_CODONS = {"UAA", "UAG", "UGA"}
def classify_mutation(wt_protein: str, mutant_protein: str) -> str:
"""
依照正確的分子生物學邏輯分類突變型態
"""
# 1️⃣ Nonsense mutation:出現提前終止
# (翻譯後蛋白中出現 STOP 或明顯提前終止)
if len(mutant_protein) < len(wt_protein):
# 若是「提前終止」但 reading frame 未被打亂 → nonsense
return "nonsense mutation"
# 2️⃣ Frameshift mutation:reading frame 改變
# (長度變化且非單一替換)
if len(mutant_protein) != len(wt_protein):
return "frameshift mutation"
# 3️⃣ Missense mutation:長度相同但胺基酸不同
if wt_protein != mutant_protein:
return "missense mutation"
# 4️⃣ 沒有變化
return "no mutation"