Skip to content

feat: allow N alleles and missing ALT in VariantIdentifier - #101

Draft
dhaupt88 wants to merge 1 commit into
masterfrom
allow-n-and-missing-alt
Draft

dhaupt88 wants to merge 1 commit into
masterfrom
allow-n-and-missing-alt

Conversation

@dhaupt88

@dhaupt88 dhaupt88 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

VariantIdentifier::parse() and DnaSequence throw on alleles that VCF 4.2 explicitly permits: N in REF and ALT, and . as ALT when a site has no alternate allele.
Variant callers emit both, so consumers parsing real VCF data fail on valid lines.
This PR accepts them.

  • DnaSequence accepts N, the IUPAC code for any base. complement() already leaves it unchanged.
  • The new AlternateAllele extends DnaSequence additionally accepts exactly . and offers isMissing().
  • parseDash() and parseCanonical() accept N and an ALT of ., and build an AlternateAllele for ALT.
  • The type of VariantIdentifier::$alternate stays DnaSequence, so existing readers keep working.
`.` lives in AlternateAllele, not in DnaSequence, to keep primer and barcode validation strict

DnaSequence also validates primer and index barcode sequences.
. is not sequence content but the VCF missing value, so allowing it there would let . pass as a primer or barcode, with length() 1 and reverseComplement() ..
Only the ALT position of a variant may hold it, see section 1.4.1 of https://samtools.github.io/hts-specs/VCFv4.2.pdf.

For agents 🤖: draft, waiting for review
  • make test and make stan pass.
  • make rector already fails on master with Undefined constant PHPUnitSetList::PHPUNIT_40; not touched here.
  • length() of . stays 1 on purpose, matching what consumers computed with strlen before.

🤖 Generated with Claude Code

VCF 4.2 permits N in REF and ALT, and `.` as ALT when there is no alternate allele.
DnaSequence accepts N, and the new AlternateAllele additionally accepts `.`,
so barcode and primer sequences stay free of `.`.

🤖 Generated with Claude Code
@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: PHP

PHP / code-coverage/phpunit

master 2949ba3 allow-n-and-missing-... e013a22 +/-
89% 90% +1%
View coverage of the 7 most impacted files.
File master 2949ba3 allow-n-and-missing-... e013a22 +/-
IlluminaSampleS...ingsSection.php 100% 100% 0%
InterOp/RunResult.php 100% 100% 0%
CSVArray.php 90% 96% +6%
PHPStan/Rules/M...ypehintRule.php 0% 88% +88%
PHPStan/Rules/M...ypehintRule.php 0% 100% +100%
PHPStan/Rules/C...ypehintRule.php 0% 100% +100%
AlternateAllele.php 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant