Conversation
Wrap PerformMethylationAwarePhasing in a lambda that accepts a read vector and forwards it to the existing span-based native function. This fixes TypeError failures when Python callers pass read lists. Add binding regression tests for empty inputs, preservation of initial phases without methylated sites, and NumPy candidate arrays, and register the test target in BUILD.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The methylation-aware phasing binding exposes
PerformMethylationAwarePhasingdirectly, including itsabsl::Span<const Read>argument. In the tested stock runtime, Python read lists cannot be converted to that argument. Evenphase([], [], [])raisesTypeErrorbefore the native function executes.This change accepts a read vector at the Python boundary and forwards it to the existing native function.
Problem and correction
The Python caller passes a list of read protobufs. The binding now exposes a lambda accepting
const std::vector<Read>&, which the existing pybind11 conversion machinery supports. C++ then converts that vector to a span for the native call. The vector remains alive throughout the call, and constructing the span does not introduce another copy of its contents.This follows the same vector-to-span adapter pattern as
DirectPhasing::PhaseReadsPython. That implementation uses a named wrapper; this change keeps the short forwarding adapter inline in the binding. A named wrapper would be an equivalent alternative if preferred.The native function signature, phasing algorithm, Python argument names, and default iteration count remain unchanged. The experimental feature remains disabled by default.
Regression coverage
Add four Python binding tests and register their test target in BUILD:
These tests check input conversion and returned values. The candidate-array test uses an already-phased read and a preset p-value; it does not test calculation of a new p-value or assignment of a new phase.
Validation
The adapters were compiled using pinned runtime dependencies and exercised against the same unchanged native implementation.
A separate local integration check ran paired ONT calling over a small real-data region with modification-tagged reads. Both runs used the same inputs and stock caller, inference, and postprocessing components, with only the binding changed. The first binding call had matching canonical input digests between runs.
The original binding raised
TypeErrorduring example generation. With the fixed binding, both native calls completed, returned one phase per read and one p-value per site, and the Python caller applied all 834 returned phases to HP tags. The pipeline completed inference and postprocessing and produced readable, indexed VCF and gVCF outputs.No reads changed phase in this fixture, and all returned p-values were zero. Positive MI annotation writes were therefore not exercised. These results establish successful data transfer and pipeline execution; no improvement in phasing or variant-calling accuracy is claimed.
These checks used compiled adapters and existing native dependencies from a pinned runtime, not a clean Bazel build. The new BUILD target remains unverified through Bazel.
Motivation and scope
When methylation-aware phasing is enabled and the caller reaches this binding, ordinary Python read lists should be accepted. The change is limited to that adapter and focused regression coverage. It does not add a new calling mode or change when methylation-aware phasing runs.