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

Commit

Permalink
void direct use of AlignedSequence.map_index
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Sep 21, 2023
1 parent deb2d95 commit 59c576a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 8 additions & 8 deletions intact/intact.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def subtyped(aligned_sequence, name, start, end, deletion_tolerence):
start = start if start < vpr_defective_insertion_pos else start - 1
end = end if end < vpr_defective_insertion_pos else end - 1

start_s = aligned_sequence.map_index(start - 1) # decrement is needed because original "start" is 1-based.
end_s = aligned_sequence.map_index(end)
start_s = ReferenceIndex(start - 1).mapto(aligned_sequence) # decrement is needed because original "start" is 1-based.
end_s = ReferenceIndex(end).mapto(aligned_sequence)

nucleotides = str(aligned_sequence.this.seq[start_s:end_s])
aminoacids = translate(nucleotides)
Expand Down Expand Up @@ -537,8 +537,8 @@ def find_closest(aminoacids, start, direction, target):
return 0

def find_candidate_positions(e):
q_start = aligned_sequence.map_index(e.start)
q_end = aligned_sequence.map_index(e.end)
q_start = ReferenceIndex(e.start).mapto(aligned_sequence)
q_end = ReferenceIndex(e.end).mapto(aligned_sequence)
expected_aminoacids = e.aminoacids
expected_protein = expected_aminoacids.strip("*")
q_start_a = q_start // 3
Expand Down Expand Up @@ -834,8 +834,8 @@ def intact( working_dir,
]

# convert PSI locus and RRE locus to appropriate subtype
psi_locus = [aligned_subtype.map_index(x) for x in hxb2_psi_locus]
rre_locus = [aligned_subtype.map_index(x) for x in hxb2_rre_locus]
psi_locus = [ReferenceIndex(x).mapto(aligned_subtype) for x in hxb2_psi_locus]
rre_locus = [ReferenceIndex(x).mapto(aligned_subtype) for x in hxb2_rre_locus]

sequence_errors = []
holistic = HolisticInfo()
Expand Down Expand Up @@ -924,8 +924,8 @@ def intact( working_dir,
if check_major_splice_donor_site:
mutated_splice_donor_site = has_mutated_major_splice_donor_site(
alignment,
aligned_subtype.map_index(hxb2_msd_site_locus),
aligned_subtype.map_index(hxb2_msd_site_locus + 1),
ReferenceIndex(hxb2_msd_site_locus).mapto(aligned_subtype),
ReferenceIndex(hxb2_msd_site_locus + 1).mapto(aligned_subtype),
const.DEFAULT_MSD_SEQUENCE)
if mutated_splice_donor_site is not None:
sequence_errors.append(mutated_splice_donor_site)
Expand Down
2 changes: 2 additions & 0 deletions util/aligned_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class ReferenceIndex:
value: int

def mapto(self, aligned):
return aligned.map_index(self.value)

@dataclass
class AlignedSequence:
Expand Down

0 comments on commit 59c576a

Please sign in to comment.