From 806420d64f022ca912111a9c28baf155eb5d00b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Balajti?= Date: Wed, 3 Jan 2024 15:24:25 +0100 Subject: [PATCH] refactor: helper function for getlibtype --- htsinfer/get_library_type.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htsinfer/get_library_type.py b/htsinfer/get_library_type.py index cc4bb1e..825a66a 100644 --- a/htsinfer/get_library_type.py +++ b/htsinfer/get_library_type.py @@ -135,7 +135,6 @@ def _evaluate_mate_relationship( self.mapping.evaluate() self._align_mates() - # pylint: disable=R0912 def _align_mates(self): """Decide mate relationship by alignment.""" @@ -187,6 +186,13 @@ def _align_mates(self): if self._compare_alignments(mate1[read_counter], reads2): concordant += 1 + self._update_relationship(concordant, read_counter) + + samfile1.close() + samfile2.close() + + def _update_relationship(self, concordant, read_counter): + """Helper function to update relationship based on alignment.""" try: if (concordant / read_counter) >= self.cutoff: self.results.relationship = ( @@ -205,9 +211,6 @@ def _align_mates(self): StatesTypeRelationship.not_available ) - samfile1.close() - samfile2.close() - class AlignedSegment: """Placeholder class for mypy "Missing attribute" error in _compare_alignments(), the actual object used