-
Notifications
You must be signed in to change notification settings - Fork 260
Closed
Description
If you run bcftools gtcheck --no-HWE-prob the array args->nmatch is not initialized:
if ( args->calc_hwe_prob )
{
// prob of the observed sequence of matches given site AFs and HWE
args->hwe_prob = (double*) calloc(args->npairs,sizeof(*args->hwe_prob));
if ( !args->hwe_prob ) error("Error: failed to allocate %.1f Mb. Run with --no-HWE-prob to save some memory.\n", args->npairs*sizeof(*args->hwe_prob)/1e6);
args->nmatch = (uint32_t*) calloc(args->npairs,sizeof(*args->ncnt)); // number of matches, used only with calc_hwe_prob
if ( !args->nmatch ) error("Error: failed to allocate %.1f Mb.\n", args->npairs*sizeof(*args->ncnt)/1e6);
}
At the end of the run gtcheck writes the report with the following command:
if ( args->ndiff )
{
ksprintf(&args->kstr,"DCv2\t%s\t%s\t%u\t%e\t%u\t%u\n",
args->qry_hdr->samples[iqry],
args->gt_hdr?args->gt_hdr->samples[igt]:args->qry_hdr->samples[igt],
args->ndiff[idx],
(args->calc_hwe_prob && args->nmatch[idx]) ? args->hwe_prob[idx]/args->nmatch[idx] : 0,
args->ncnt[idx],
args->nmatch[idx]);
}
else
{
ksprintf(&args->kstr,"DCv2\t%s\t%s\t%e\t%e\t%u\t%u\n",
args->qry_hdr->samples[iqry],
args->gt_hdr?args->gt_hdr->samples[igt]:args->qry_hdr->samples[igt],
args->pdiff[idx],
(args->calc_hwe_prob && args->nmatch[idx]) ? args->hwe_prob[idx]/args->nmatch[idx] : 0,
args->ncnt[idx],
args->nmatch[idx]);
}
But there is no check for args->calc_hwe_prob when accessing args->nmatch[idx]. The two instances of args->nmatch[idx] should be replaced with args->calc_hwe_prob ? args->nmatch[idx] : 0 or something similar
Metadata
Metadata
Assignees
Labels
No labels