Skip to content

Commit

Permalink
fix to work prefixed phasing with <*> allele (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasudeva8 authored Dec 18, 2024
1 parent 85a04a0 commit 80d1ad8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/vcf/validate_optional_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,14 @@ namespace ebi
void ValidateOptionalPolicy::check_body_entry_alt_gvcf_gt_value(ParsingState & state, Record const & record) const
{
if (util::contains(record.alternate_alleles, GVCF_NON_VARIANT_ALLELE) && record.format[0] == vcf::GT) {
for (auto & sample : record.samples) {
//with v44, there can be optional leading phasing info, remove it and use
bool checkprefix = state.source->version < Version::v44? false : true;
for (auto sample : record.samples) {
if (checkprefix && !sample.empty()) {
if (sample.at(0) == '/' || sample.at(0) == '|') {
sample.erase(0,1);
}
}
if (sample_has_reference_in_all_alleles(sample)) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions test/input_files/v4.4/passed/passed_body_alt.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
1 1900 rs180734498 C AGT[1:100[ 100 PASS AN=2184;AC=249;AF=0.11;SVLEN=.;SVCLAIM=J GT:DS:GL 0|0:0.050:-0.13,-0.58,-3.62 0|1:1.000:-2.45,-0.00,-5.00
1 1900 rs180734498 C . 100 PASS AN=2184;AC=249;AF=0.11 GT:DS:GL 0|0:0.050:-0.13,-0.58,-3.62 0|1:1.000:-2.45,-0.00,-5.00
1 4370 . G <*> . . END=4383;SVLEN=. GT:DP:GQ:MIN:PL 0/0:25:60:23:0,60,900 0/0:25:45:25:0,42,630
1 4371 . G <*> . . END=4383;SVLEN=. GT:DP:GQ:MIN:PL /0/0:25:60:23:0,60,900 |0/1:25:45:25:0,42,630
1 4389 . T TC,<*> 213.73 . . GT:DP:GQ:PL 0/1:23:99:51,0,36,93,92,86 0/0:24:52:0,52,95,66,95,97
1 4389 . C <*>,<DEL> . . END=4388;SVLEN=.,1;SVCLAIM=.,D GT:DP:GQ 0/0:25:45 0/1:23:99
1 4390 . C *,<*> . . END=4390 GT:DP:GQ 0/0:26:0 0/0:25:60
Expand Down
29 changes: 29 additions & 0 deletions test/vcf/optional_policy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,20 @@ namespace ebi
{ "0/0" },
sources[1]})) );

CHECK_NOTHROW( (optional_policy.optional_check_body_entry(parsing_state2, vcf::Record{ //gvcf with prefixed phasing
1,
"chr1",
123456,
{ "id123" },
"A",
{ vcf::GVCF_NON_VARIANT_ALLELE },
1.0,
{ vcf::PASS },
{ { vcf::END, "0" } },
{ vcf::GT },
{ "|0/0" },
sources[1]})) );

CHECK_NOTHROW( (optional_policy.optional_check_body_entry(parsing_state2, vcf::Record{
1,
"chr1",
Expand Down Expand Up @@ -991,6 +1005,21 @@ namespace ebi
{ "0|1" },
sources[1]})),
vcf::AlternateAllelesBodyError*);

CHECK_THROWS_AS( (optional_policy.optional_check_body_entry(parsing_state2, vcf::Record{ //gvcf with prefixed phasing
1,
"chr1",
123456,
{ "id123" },
"A",
{ vcf::GVCF_NON_VARIANT_ALLELE },
1.0,
{ vcf::PASS },
{ { vcf::END, "0" } },
{ vcf::GT },
{ "/0|1" },
sources[1]})),
vcf::AlternateAllelesBodyError*);
}
}

Expand Down

0 comments on commit 80d1ad8

Please sign in to comment.