Skip to content

Commit

Permalink
Fixed warning about unphased SNPs
Browse files Browse the repository at this point in the history
Code was checking if a SNP is unphased and if the warn_phase flag is
set in the same conditional.

After unsetting warn_phase, this test would fail, causing additional
unphased SNPs to be converted to missing data.

By creating two separate conditionals, a single warning is printed and
all additional unphased SNPs are parsed normally.
  • Loading branch information
hobrien committed May 31, 2016
1 parent 467651c commit 7b30418
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions snp2h5/vcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ void vcf_parse_haplotypes(VCFInfo *vcf_info, char *haplotypes,
/* try with '/' separator instead */
n = sscanf(inner_tok, "%d/%d", &hap1, &hap2);

if(n == 2 && warn_phase) {
my_warn("%s:%d: some genotypes are unphased (delimited "
"with '/' instead of '|')\n", __FILE__, __LINE__,
inner_tok);
warn_phase = FALSE;
if(n == 2) {
if(warn_phase) {
my_warn("%s:%d: some genotypes are unphased (delimited "
"with '/' instead of '|')\n", __FILE__, __LINE__,
inner_tok);
warn_phase = FALSE;
}
} else {
my_warn("%s:%d: could not parse genotype string '%s'\n",
__FILE__, __LINE__, inner_tok);
Expand Down

0 comments on commit 7b30418

Please sign in to comment.