Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to have correct phasing with other unphased alleles #269

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/vcf/record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,15 +1218,16 @@ namespace ebi
void Record::get_phased_alleles(std::string GT, std::vector<std::string>& alleles) const
{
std::string delims("|/");
bool anyphased = false;
bool anyunphased = false;
std::vector<std::string> values;

if (!GT.size()) {
return;
}

if (GT.find('|') != std::string::npos) {
anyphased = true;
//search for other unphased allele, other than 1st one
if (GT.find('/', 1) != std::string::npos) {
anyunphased = true;
}

util::string_split_ex(GT, delims.c_str(), values, true);
Expand All @@ -1235,7 +1236,7 @@ namespace ebi
if (allele != values.end()) {
if (allele->at(0) != '/' && allele->at(0) != '|') {
//infer phasing based on other alleles phasing
allele->insert(0, anyphased ? "|" : "/");
allele->insert(0, anyunphased ? "/" : "|");
}
alleles.swap(values);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
1 1700 rs180734498 C <DEL>,T,<DUP> 100 PASS SVLEN=1,.,2;SVCLAIM=D,.,D GT:PSL 0|0:.,.
1 1800 rs180734498 C <CNV>,T,<DEL> 100 PASS SVLEN=2,.,1;SVCLAIM=D,.,DJ GT:PSL 0/0:T1,T2
1 1900 rs180734498 C <CNV>,T,<DUP> 100 PASS SVLEN=1,.,21;SVCLAIM=D,.,J GT:PSL 0/0|1:T1,T2,T3
1 1901 rs180734498 C T 100 PASS SVCLAIM=. GT:PSL /0:T1
4 changes: 3 additions & 1 deletion test/input_files/v4.4/passed/passed_body_samples_1.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
1 900 rs180734498 C <CNV>,T,<DUP> 100 PASS SVLEN=1,.,21;SVCLAIM=D,.,J GT:PSL:PSO /0|0|1:.,T2,T3:.,1,2
1 1700 rs180734498 C <DEL>,T,<DUP> 100 PASS SVLEN=1,.,2;SVCLAIM=D,.,D GT:PSL:PSO 0/0:.,.:.,.
1 1800 rs180734498 C <CNV>,T,<DEL> 100 PASS SVLEN=2,.,1;SVCLAIM=D,.,DJ GT:PSL:PSQ 0|0:T1,T2:1,2
1 1900 rs180734498 C <CNV>,T,<DUP> 100 PASS SVLEN=1,.,21;SVCLAIM=D,.,J GT:PSL:PSQ 0/0|1:T1,.,T3:1,.,3
1 1900 rs180734498 C <CNV>,T,<DUP> 100 PASS SVLEN=1,.,21;SVCLAIM=D,.,J GT:PSL:PSQ 0/0|1:.,.,T3:.,.,3
1 1901 rs180734498 C T 100 PASS SVCLAIM=. GT:PSL:PSQ 0:T1:3
1 1902 rs180734498 C T 100 PASS SVCLAIM=. GT:PSL:PSQ /0:.:.
Loading