diff --git a/micall/utils/cigar_tools.py b/micall/utils/cigar_tools.py index 36b829262..92a45e4d8 100644 --- a/micall/utils/cigar_tools.py +++ b/micall/utils/cigar_tools.py @@ -8,6 +8,7 @@ from dataclasses import dataclass from functools import cached_property from itertools import chain, dropwhile +from fractions import Fraction from micall.utils.consensus_aligner import CigarActions @@ -429,7 +430,7 @@ def __add__(self, other): @property def epsilon(self): - return 1 / (self.query_length + self.ref_length + 100) + return Fraction(1, self.query_length + self.ref_length + 100) def _slice(self, r_st, r_ei, q_st, q_ei) -> 'CigarHit': @@ -479,7 +480,8 @@ def cut_reference(self, cut_point: float) -> 'CigarHit': and that no element is lost. """ - if float(cut_point).is_integer(): + cut_point = Fraction(cut_point) + if cut_point.denominator == 1: raise ValueError("Cut accepts fractions, not integers") if self.ref_length == 0 or \