Drop WT leak from "_wt" rows in parse_stripped_hgvs#34
Merged
Conversation
run_rosace.R:62 (and the mirrored helper at tests/r/testthat/ helper-functions.R:28) ran: WT <- substr(hgvs_string, 1, 1) ABOVE the "_wt" short-circuit. For wildtype rows this set WT to "_" before the function returned, leaving variant metadata with WT = "_" (the underscore from the sentinel string, not an amino acid). finalize_variants_in_rosace then propagated that into rosace_obj@var.data$wildtype, where it sat alongside real amino acid codes like "A", "M", etc. Every downstream regex branch (synonymous, missense, nonsense, deletion, insertion) sets WT from its own str_match capture group, so the pre-branch substr() was a redundant initial guess that got overwritten in every successful parse. Removing it makes _wt return with WT = "" (matches the function's default initializer above), which finalize_variants_in_rosace happily passes through. Side effect for malformed inputs that match no regex branch: WT changes from substr(hgvs, 1, 1) to "". The malformed-return case already has variant="", pos=-1, len=-1, mutation_type="" — adding WT="" to that list is more honest about "we couldn't parse this" than echoing back a stray first character. Tighten the existing _wt test to assert WT = "" explicitly. The old test asserted variant/pos/mutation_type but skipped WT, which is how this lived for so long. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
run_rosace.R:62 (and the mirrored helper at tests/r/testthat/ helper-functions.R:28) ran:
WT <- substr(hgvs_string, 1, 1)
ABOVE the "wt" short-circuit. For wildtype rows this set WT to "" before the function returned, leaving variant metadata with WT = "_" (the underscore from the sentinel string, not an amino acid). finalize_variants_in_rosace then propagated that into rosace_obj@var.data$wildtype, where it sat alongside real amino acid codes like "A", "M", etc.
Every downstream regex branch (synonymous, missense, nonsense, deletion, insertion) sets WT from its own str_match capture group, so the pre-branch substr() was a redundant initial guess that got overwritten in every successful parse. Removing it makes _wt return with WT = "" (matches the function's default initializer above), which finalize_variants_in_rosace happily passes through.
Side effect for malformed inputs that match no regex branch: WT changes from substr(hgvs, 1, 1) to "". The malformed-return case already has variant="", pos=-1, len=-1, mutation_type="" — adding WT="" to that list is more honest about "we couldn't parse this" than echoing back a stray first character.
Tighten the existing _wt test to assert WT = "" explicitly. The old test asserted variant/pos/mutation_type but skipped WT, which is how this lived for so long.