30ee8eb43a22ad344e07f8f86816914d6c3a5cf7 tdreszer Fri Mar 28 15:04:40 2014 -0700 Limit vcf filtering for a particular track evsEsp6500, which has slighltly non-conforming vcf fields. Really this code should be changed to not be track specific, but to only offer vcf filters that are requested in trackDb.ra. Redmine #9329. diff --git src/hg/hgTracks/vcfTrack.c src/hg/hgTracks/vcfTrack.c index 9621108..46932d6 100644 --- src/hg/hgTracks/vcfTrack.c +++ src/hg/hgTracks/vcfTrack.c @@ -121,30 +121,50 @@ anEl->missingData[0] == FALSE) { gotInfo = TRUE; int totalCount = anEl->values[0].datFloat; for (i = 0; i < acEl->count; i++) { if (acEl->missingData[i]) continue; int altCount = acEl->values[i].datFloat; double altFreq = (double)altCount / totalCount; refFreq -= altFreq; if (altFreq < maxAltFreq) maxAltFreq = altFreq; } } + else + // Use MAF for alternate allele freqs from MAF: + { + const struct vcfInfoElement *mafEl = vcfRecordFindInfo(record, "MAF"); + const struct vcfInfoDef *mafDef = vcfInfoDefForKey(vcff, "MAF"); + if (mafEl != NULL && mafDef != NULL && mafDef->type == vcfInfoString + && startsWith("Minor Allele Frequency",mafDef->description)) + { + // If INFO includes alt allele freqs, use them directly. + gotInfo = TRUE; + + if (mafEl->count >= 1 && !mafEl->missingData[mafEl->count-1]) + { + char data[64]; + safecpy(data,sizeof(data),mafEl->values[mafEl->count-1].datString); + maxAltFreq = atof(lastWordInLine(data)); + refFreq -= maxAltFreq; + } + } + } } if (gotInfo) { double majorAlFreq = max(refFreq, maxAltFreq); if (majorAlFreq > (1.0 - minFreq)) return TRUE; } return FALSE; } static void filterRecords(struct vcfFile *vcff, struct trackDb *tdb) /* If a filter is specified in the cart, remove any records that don't pass filter. */ { double minQual = VCF_DEFAULT_MIN_QUAL; struct slName *filterValues = NULL;