89e6b5b4e3b7cef642d825fbfca09c6111f3f4cd angie Wed Jun 16 17:34:53 2021 -0700 Another case of too many VCF columns to keep an array of them on the stack. diff --git src/hg/utils/vcfRenameAndPrune/vcfRenameAndPrune.c src/hg/utils/vcfRenameAndPrune/vcfRenameAndPrune.c index 342b879..fd1d0fa 100644 --- src/hg/utils/vcfRenameAndPrune/vcfRenameAndPrune.c +++ src/hg/utils/vcfRenameAndPrune/vcfRenameAndPrune.c @@ -21,31 +21,32 @@ } /* Command line validation table. */ static struct optionSpec options[] = { {NULL, 0}, }; void vcfRenameAndPrune(char *vcfInFile, char *renamingFile, char *vcfOutFile) /* vcfRenameAndPrune - Rename or remove samples from VCF with genotypes. */ { struct hash *renaming = hashTwoColumnFile(renamingFile); struct lineFile *lf = lineFileOpen(vcfInFile, TRUE); FILE *outF = mustOpen(vcfOutFile, "w"); int headerColCount = 0; int keeperCountMax = hashNumEntries(renaming); -int keeperColumns[keeperCountMax]; +int *keeperColumns; +AllocArray(keeperColumns, keeperCountMax); int keeperCount = 0; int keeperIx = 0; // VCF with >1M samples (for SARS-CoV-2) causes stack problems / SEGV if we declare words on stack, // so allocate it once we know how many columns to expect: char **words = NULL; char *line; while (lineFileNext(lf, &line, NULL)) { if (startsWith("#CHROM", line)) { // Parse & replace sample names, build array of genotype columns that we're keeping headerColCount = chopString(line, "\t", NULL, 0); lineFileExpectAtLeast(lf, VCF_NUM_COLS_BEFORE_GENOTYPES+1, headerColCount); AllocArray(words, headerColCount+1); chopByChar(line, '\t', words, headerColCount+1);