Skip to content

Commit

Permalink
fix error in ANIm coverage dataframe update
Browse files Browse the repository at this point in the history
When subject cover was zero, the dataframe containing coverage
values was not being updated because of a test for `if scover`
instead of `if scover is not None`.
  • Loading branch information
widdowquinn committed Sep 30, 2021
1 parent 3c6be11 commit 17128b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pyani/anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ def process_deltadir(delta_dir, org_lengths, logger=None):
logger.warning(
"Total alignment length reported in " + "%s is zero!" % deltafile
)
print(f"{tot_length=} {org_lengths[qname]=} {org_lengths[sname]=}")
query_cover = float(tot_length) / org_lengths[qname]
sbjct_cover = float(tot_length) / org_lengths[sname]
print(f"{query_cover=} {sbjct_cover=}")

# Calculate percentage ID of aligned length. This may fail if
# total length is zero.
Expand All @@ -240,5 +242,8 @@ def process_deltadir(delta_dir, org_lengths, logger=None):
results.add_tot_length(qname, sname, tot_length)
results.add_sim_errors(qname, sname, tot_sim_error)
results.add_pid(qname, sname, perc_id)

print(f"before adding coverage {results.alignment_coverage=}")
results.add_coverage(qname, sname, query_cover, sbjct_cover)
print(f"after adding coverage {results.alignment_coverage=}")
return results
2 changes: 1 addition & 1 deletion pyani/pyani_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def add_pid(self, qname, sname, value, sym=True):
def add_coverage(self, qname, sname, qcover, scover=None):
"""Add percentage coverage values to self.alignment_coverage."""
self.alignment_coverage.loc[qname, sname] = qcover
if scover:
if scover is not None: # need to account for coverage being zero
self.alignment_coverage.loc[sname, qname] = scover

@property
Expand Down

0 comments on commit 17128b2

Please sign in to comment.