ebc84c82794070f9999daf3bf8c5de7f407d5818 angie Fri Dec 2 15:35:06 2011 -0800 Feature #3707 (VCF+tabix support in hgTables): Brooke reported out-of-memconditions in notes 11 & 12. Fix: add an optional threshold on the number of records to retrieve in vcfTabixFileMayOpen. diff --git src/inc/vcf.h src/inc/vcf.h index 40d02b8..d11c0f6 100644 --- src/inc/vcf.h +++ src/inc/vcf.h @@ -167,42 +167,44 @@ case vcfInfoFlag: fprintf(f, "%s", datum.datString); // Flags could have values in older VCF break; case vcfInfoCharacter: fprintf(f, "%c", datum.datChar); break; case vcfInfoString: fprintf(f, "%s", datum.datString); break; default: errAbort("vcfPrintDatum: Unrecognized type %d", type); break; } } -struct vcfFile *vcfFileMayOpen(char *fileOrUrl, int maxErr); +struct vcfFile *vcfFileMayOpen(char *fileOrUrl, int maxErr, int maxRecords); /* Parse a VCF file into a vcfFile object; return NULL if unable. * If maxErr not zero, then continue to parse until this number of error have been reached. - * A maxErr less than zero does not stop and reports all errors. */ + * A maxErr less than zero does not stop and reports all errors. + * If maxRecords >= 0, then at most that many records will be parsed. */ struct vcfFile *vcfTabixFileMayOpen(char *fileOrUrl, char *chrom, int start, int end, - int maxErr); + int maxErr, int maxRecords); /* Parse header and rows within the given position range from a VCF file that has been * compressed and indexed by tabix into a vcfFile object; return NULL if or if file has * no items in range. * If maxErr not zero, then continue to parse until this number of error have been reached. - * A maxErr less than zero does not stop and reports all errors. */ + * A maxErr less than zero does not stop and reports all errors. + * If maxRecords >= 0, then at most that many records will be parsed. */ void vcfFileFree(struct vcfFile **vcffPtr); /* Free a vcfFile object. */ const struct vcfRecord *vcfFileFindVariant(struct vcfFile *vcff, char *variantId); /* Return all records with name=variantId, or NULL if not found. */ const struct vcfInfoElement *vcfRecordFindInfo(const struct vcfRecord *record, char *key); /* Find an INFO element, or NULL. */ struct vcfInfoDef *vcfInfoDefForKey(struct vcfFile *vcff, const char *key); /* Return infoDef for key, or NULL if it wasn't specified in the header or VCF spec. */ void vcfParseGenotypes(struct vcfRecord *record); /* Translate record->genotypesUnparsedStrings[] into proper struct vcfGenotype[].