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

Commit

Permalink
do not assume that expected orf is nonempty
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Sep 16, 2023
1 parent c49975d commit 4c11e3a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions intact/intact.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,12 +592,12 @@ def get_indel_impact(alignment):
deletions = max(0, len(exp_protein) - len(got_protein)) * 3
insertions = max(0, len(got_protein) - len(exp_protein)) * 3

if got_protein:
if got_protein and exp_protein:
orf_alignment = aligner.align(exp_protein, got_protein)[0]
best_match.distance = aligner.match_score - (orf_alignment.score / len(exp_protein))
else:
orf_alignment = (exp_protein, "-" * len(exp_protein))
best_match.distance = aligner.match_score - ((aligner.open_gap_score + len(exp_protein) * aligner.extend_gap_score) / len(exp_protein))
best_match.distance = aligner.match_score - ((aligner.open_gap_score + len(exp_protein) * aligner.extend_gap_score) / max(1, len(exp_protein)))

# Max deletion allowed in ORF exceeded
if deletions > e.deletion_tolerence:
Expand Down Expand Up @@ -642,8 +642,8 @@ def get_indel_impact(alignment):
continue

got_nucleotides = sequence.seq[best_match.start:best_match.start + len(got_protein) * 3].upper()
if got_nucleotides:
exp_nucleotides = reference.seq[e.start:e.end].upper()
exp_nucleotides = reference.seq[e.start:e.end].upper()
if got_nucleotides and exp_nucleotides:
orf_alignment = aligner.align(exp_nucleotides, got_nucleotides)[0]
impacted_by_indels = get_indel_impact(orf_alignment)

Expand Down

0 comments on commit 4c11e3a

Please sign in to comment.