Skip to content

Commit

Permalink
condense: Do not assign coverage to Root.
Browse files Browse the repository at this point in the history
  • Loading branch information
wwood committed Nov 20, 2023
1 parent df589f1 commit 4a6803d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions singlem/condense.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,13 @@ def _condense_domain_to_species(self, sample, sample_otus, markers, target_domai
if node.word != 'Root':
node.coverage = node.coverage - children_coverage

# Remove the very occasional situations that coverages are
# negative.
if node.coverage < 0:
node.coverage = 0
# Apply a general cutoff, which is somewhat arbitrary, but
# reduces noise. This cutoff also removes the very occasional
# situations that coverages are negative.
# if node.coverage < min_taxon_coverage:
if node.get_full_coverage() < min_taxon_coverage or node.coverage < 0:
# reduces noise. But don't lose that coverage.
elif node.get_full_coverage() < min_taxon_coverage:
# While this node's coverage is set to zero, its parent
# should be increased because we don't want to lose coverage.

Expand All @@ -340,9 +342,11 @@ def _condense_domain_to_species(self, sample, sample_otus, markers, target_domai
# coverage to the most immediate ancestor with non-zero
# coverage.
parent = node.parent
while parent is not None: # This should never be None since it runs into Root, but just in case
if parent.coverage > 0 or parent.word == 'Root':
parent.coverage += node.coverage
while parent is not None: # This should never be None since it runs into Root, but just in case
if parent.coverage != 0 or parent.word == 'Root':
if parent.word != 'Root':
# Never add coverage to the Root node
parent.coverage += node.coverage
break
parent = parent.parent
node.coverage = 0
Expand Down

0 comments on commit 4a6803d

Please sign in to comment.