Skip to content

Commit

Permalink
Merge pull request #4497 from vgteam/deconstruct-bug
Browse files Browse the repository at this point in the history
fix deconstruct so empty GTs always have same ploidy as non-empty
  • Loading branch information
glennhickey authored Jan 17, 2025
2 parents c751f44 + 68feab8 commit a45d11e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/deconstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,13 @@ void Deconstructor::get_genotypes(vcflib::Variant& v, const vector<string>& name
} else {
string blank_gt = ".";
if (gbwt_sample_to_phase_range.count(sample_name)) {
auto& phase_range = gbwt_sample_to_phase_range.at(sample_name);
for (int phase = phase_range.first + 1; phase <= phase_range.second; ++phase) {
// note: this is the same logic used when filling in actual genotypes
int min_phase, max_phase;
std::tie(min_phase, max_phase) = gbwt_sample_to_phase_range.at(sample_name);
// shift left by 1 unless min phase is 0
int sample_ploidy = min_phase == 0 ? max_phase + 1 : max_phase;
assert(sample_ploidy > 0);
for (int phase = 1; phase < sample_ploidy; ++phase) {
blank_gt += "|.";
}
}
Expand Down Expand Up @@ -1132,6 +1137,10 @@ string Deconstructor::get_vcf_header() {
if (haplotype == PathMetadata::NO_HAPLOTYPE) {
haplotype = 0;
}
if (haplotype > 10) {
cerr << "Warning [vg deconstruct]: Suspiciously large haplotype, " << haplotype
<< ", parsed from path, " << path_name << ": This will leed to giant GT entries.";
}
sample_to_haps[sample_name].insert((int)haplotype);
sample_names.insert(sample_name);
}
Expand Down Expand Up @@ -1159,6 +1168,10 @@ string Deconstructor::get_vcf_header() {
// Default to 0.
phase = 0;
}
if (phase > 10) {
cerr << "Warning [vg deconstruct]: Suspiciously large haplotype, " << phase
<< ", parsed from GBWT thread, " << path_name << ": This will leed to giant GT entries.";
}
sample_to_haps[sample_name].insert((int)phase);
sample_names.insert(sample_name);
}
Expand Down

1 comment on commit a45d11e

@adamnovak
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vg CI tests complete for merge to master. View the full report here.

16 tests passed, 0 tests failed and 0 tests skipped in 17259 seconds

Please sign in to comment.