From 7b304189c4af5f6055703d12a3fd433fc73c21fe Mon Sep 17 00:00:00 2001 From: Heath O'Brien Date: Tue, 31 May 2016 16:32:30 +0100 Subject: [PATCH] Fixed warning about unphased SNPs 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. --- snp2h5/vcf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/snp2h5/vcf.c b/snp2h5/vcf.c index 22b9fa0..164718e 100644 --- a/snp2h5/vcf.c +++ b/snp2h5/vcf.c @@ -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);