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

Commit

Permalink
improve reverse decision logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Sep 27, 2023
1 parent 4cf554d commit 6e8983a
Show file tree
Hide file tree
Showing 6 changed files with 416 additions and 13 deletions.
13 changes: 8 additions & 5 deletions intact/intact.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,20 +770,23 @@ def analyse_single_sequence(writer, sequence, blast_rows):
else:
reference_name = sorted(subtype_choices.keys())[0]

blast_orientation_statistics = { "plus": 0, "minus": 0 }
for blast_row in blast_rows:
if blast_row.qseqid == reference_name:
blast_orientation_statistics[blast_row.sstrand] += abs(blast_row.qend - blast_row.qstart)

holistic.inferred_subtype = reference_name
reference = subtype_choices[reference_name]
aligned_subtype = AlignedSequence(this=reference, reference=st.HXB2())

forward_aligned_sequence = AlignedSequence(this=sequence, reference=aligned_subtype.this)
reverse_aligned_sequence = forward_aligned_sequence.reverse()

forward_score = forward_aligned_sequence.alignment_score()
reverse_score = reverse_aligned_sequence.alignment_score()
if forward_score >= reverse_score:
if blast_orientation_statistics["minus"] < blast_orientation_statistics["plus"] \
or reverse_aligned_sequence.alignment_score() <= forward_aligned_sequence.alignment_score():
aligned_sequence = forward_aligned_sequence
else:
log.info("Reversing sequence " + sequence.id + "; forward score "
+ str(forward_score) + "; reverse score " + str(reverse_score))
log.info("Reversing sequence " + sequence.id)
aligned_sequence = reverse_aligned_sequence
sequence = aligned_sequence.this

Expand Down
Loading

0 comments on commit 6e8983a

Please sign in to comment.