Skip to content

Commit

Permalink
refactor: update lib type and orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
balajtimate committed Jan 15, 2024
1 parent 70f4252 commit b5b80ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 7 additions & 5 deletions htsinfer/get_library_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _evaluate_mate_relationship(
ids_2: As `ids_1` but for the putative second mate file.
"""
self.results.relationship = StatesTypeRelationship.not_mates
if ids_1 == ids_2 and len(ids_1) > 0 and len(ids_2) > 0:
if ids_1 and ids_2 and ids_1 == ids_2:
if (
self.results.file_1 == StatesType.first_mate and
self.results.file_2 == StatesType.second_mate
Expand All @@ -140,8 +140,7 @@ def _evaluate_mate_relationship(
else:
self.results.relationship = StatesTypeRelationship.not_available
LOGGER.debug(
"Library source is not determined, "
"mate relationship cannot be inferred by alignment."
"Mate relationship cannot be determined."
)

def _align_mates(self):
Expand All @@ -165,6 +164,7 @@ def _align_mates(self):
concordant = 0

for read1 in samfile1:
# ensure that "unmapped" flag is not set and query name is set
if not read1.flag & (1 << 2) and isinstance(read1.query_name, str):
seq_id1 = read1.query_name
if (
Expand All @@ -180,6 +180,7 @@ def _align_mates(self):

read_counter = 0
for read2 in samfile2:
# ensure that "unmapped" flag is not set and query name is set
if not read2.flag & (1 << 2) and isinstance(read2.query_name, str):
seq_id2 = read2.query_name
if seq_id2 != previous_seq_id2 \
Expand Down Expand Up @@ -219,8 +220,9 @@ def _update_relationship(self, concordant, read_counter):
self.results.relationship = (
StatesTypeRelationship.split_mates
)
self.mapping.library_type.relationship \
= StatesTypeRelationship.split_mates
self.mapping.library_type.relationship = (
StatesTypeRelationship.split_mates
)
self.mapping.mapped = False
self.mapping.star_dirs = []
else:
Expand Down
3 changes: 1 addition & 2 deletions htsinfer/get_read_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def evaluate(self) -> ResultsOrientation:
self.mapping.evaluate()
else:
LOGGER.debug(
"Library source is not determined, "
"read orientation cannot be inferred by alignment."
"Read orientation cannot be determined."
)

return self.process_alignments(star_dirs=self.mapping.star_dirs)
Expand Down

0 comments on commit b5b80ca

Please sign in to comment.