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 3a3cc1d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 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) / min(1, len(exp_protein)))

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

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

0 comments on commit 3a3cc1d

Please sign in to comment.