Skip to content

Commit

Permalink
Cigar tools: rename "r_len" and "q_len"
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Nov 8, 2023
1 parent 24a0cbb commit 5789ee6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion micall/tests/test_cigar_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def test_cigar_hit_ref_cut_add_associativity(hit, cut_point):
a, x = hit.cut_reference(ax_cut - percentage)

for bc_cut in range(a.r_ei + 1, hit.r_ei + 2):
if x.r_len == 0: continue
if x.ref_length == 0: continue

b, c = x.cut_reference(bc_cut - percentage)

Expand Down
14 changes: 7 additions & 7 deletions micall/utils/cigar_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,22 +318,22 @@ class CigarHit:
def __post_init__(self):
self.cigar = Cigar.coerce(self.cigar)

if self.r_len != self.cigar.ref_length:
if self.ref_length != self.cigar.ref_length:
raise ValueError(f"CIGAR string maps {self.cigar.ref_length}"
f" reference positions, but CIGAR hit range is {self.r_len}")
f" reference positions, but CIGAR hit range is {self.ref_length}")

if self.q_len != self.cigar.query_length:
if self.query_length != self.cigar.query_length:
raise ValueError(f"CIGAR string maps {self.cigar.query_length}"
f" query positions, but CIGAR hit range is {self.q_len}")
f" query positions, but CIGAR hit range is {self.query_length}")


@property
def r_len(self):
def ref_length(self):
return self.r_ei + 1 - self.r_st


@property
def q_len(self):
def query_length(self):
return self.q_ei + 1 - self.q_st


Expand Down Expand Up @@ -424,7 +424,7 @@ def cut_reference(self, cut_point: float) -> 'CigarHit':
if float(cut_point).is_integer():
raise ValueError("Cut accepts fractions, not integers")

if self.r_len == 0 or \
if self.ref_length == 0 or \
not (self.r_st - 1 < cut_point < self.r_ei + 1):
raise IndexError("Cut point out of reference bounds")

Expand Down

0 comments on commit 5789ee6

Please sign in to comment.