Skip to content

Fix SMG exclusion in get_components: check whole component b4 scoring PHROGs - #67

Open
gbouras13 wants to merge 1 commit into
Vini2:developfrom
gbouras13:fix/smg-exclusion-order-dependence
Open

Fix SMG exclusion in get_components: check whole component b4 scoring PHROGs#67
gbouras13 wants to merge 1 commit into
Vini2:developfrom
gbouras13:fix/smg-exclusion-order-dependence

Conversation

@gbouras13

Copy link
Copy Markdown

component_utils.get_components had two related gaps in how it kept bacterial single-copy marker genes (SMGs) out of candidate phage components, despite the docstring saying "components with PHROGs and no SMGs":

  1. Multi-unitig components: the loop checked each unitig for an SMG and broke on the first one found, but a break only stops the loop -- it doesn't clear PHROG-category flags a unitig earlier in the same component already set. So whether a mixed bacterial/phage component got excluded depended on which unitig igraph happened to iterate first, not on whether an SMG was actually present. A component with a PHROG-bearing unitig visited before an SMG-bearing one survived with the marker gene intact; the same two unitigs in the opposite order got correctly excluded.

  2. Single-unitig components had no SMG check at all -- a lone unitig carrying both a marker gene and a PHROG hit was always kept.

Fixed by checking every unitig in a component for an SMG membership up front, in its own pass, before any PHROG scoring happens for either the multi- or single-unitig case. A component with any SMG is skipped outright; there's no point scoring PHROG evidence for one that's excluded either way.

Verified with a standalone test (four cases: PHROG-then-SMG order, SMG-then- PHROG order, a single unitig with both, and a clean SMG-free control) -- before the fix, the first case was incorrectly kept; after, all mixed cases are excluded and the clean case is unaffected. Also ran the real pipeline against phables' own bundled test_data/ fixture: component count is unchanged there (6), as expected -- that fixture has no marker-gene hits at all, so it doesn't exercise this path either way, but confirms nothing else regressed.

… scoring PHROGs

component_utils.get_components had two related gaps in how it kept bacterial
single-copy marker genes (SMGs) out of candidate phage components, despite the
docstring saying "components with PHROGs and no SMGs":

1. Multi-unitig components: the loop checked each unitig for an SMG and broke
   on the first one found, but a `break` only stops the loop -- it doesn't
   clear PHROG-category flags a unitig earlier in the same component already
   set. So whether a mixed bacterial/phage component got excluded depended on
   which unitig igraph happened to iterate first, not on whether an SMG was
   actually present. A component with a PHROG-bearing unitig visited before
   an SMG-bearing one survived with the marker gene intact; the same two
   unitigs in the opposite order got correctly excluded.

2. Single-unitig components had no SMG check at all -- a lone unitig carrying
   both a marker gene and a PHROG hit was always kept.

Fixed by checking every unitig in a component for an SMG membership up front,
in its own pass, before any PHROG scoring happens for either the multi- or
single-unitig case. A component with any SMG is skipped outright; there's no
point scoring PHROG evidence for one that's excluded either way.

Verified with a standalone test (four cases: PHROG-then-SMG order, SMG-then-
PHROG order, a single unitig with both, and a clean SMG-free control) --
before the fix, the first case was incorrectly kept; after, all mixed cases
are excluded and the clean case is unaffected. Also ran the real pipeline
against phables' own bundled test_data/ fixture: component count is unchanged
there (6), as expected -- that fixture has no marker-gene hits at all, so it
doesn't exercise this path either way, but confirms nothing else regressed.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant