Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Catch invalid codon errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Sep 16, 2023
1 parent 2ab1a02 commit 0d132a3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions intact/intact.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
NONHIV_ERROR = "NonHIV"
INTERNALINVERSION_ERROR = "InternalInversion"
ALIGNMENT_FAILED = "AlignmentFailed" # Happens when mafft process fails
INVALID_CODON = "InvalidCodon" # Happens when there is an invalid codon in ORF

FRAMESHIFTINORF_ERROR = "FrameshiftInOrf"
MSDMUTATED_ERROR = "MajorSpliceDonorSiteMutated"
Expand Down Expand Up @@ -508,11 +509,16 @@ def has_reading_frames(
reference_aligned_mapping = coords.map_nonaligned_to_aligned_positions(reference, alignment[0].seq)
query_aligned_mapping = coords.map_nonaligned_to_aligned_positions(sequence, alignment[1].seq)

errors = []
matches = []

try:
query_aminoacids_table = [translate(sequence.seq, i) for i in range(3)]
except Bio.Data.CodonTable.TranslationError as e:
log.error(e)
return [], []
err = IntactnessError(INVALID_CODON, e.args[0])
errors.append(err)
return matches, errors

def find_closest(aminoacids, start, direction, target):
distance = 0
Expand Down Expand Up @@ -581,8 +587,6 @@ def get_indel_impact(alignment):
impacted += counter if counter > 30 else 0
return impacted

errors = []
matches = []
for e in expected:
best_match = find_real_correspondence(e)
matches.append(best_match)
Expand Down

0 comments on commit 0d132a3

Please sign in to comment.