6dfdf2e6277b1815d40117b0f1ff1508e6f92058 angie Fri Mar 15 13:41:09 2024 -0700 Support for M. tuberculosis: at 4M bases, the genome is too large for arrays on the stack. Allocate & free instead. diff --git src/hg/hgPhyloPlace/writeCustomTracks.c src/hg/hgPhyloPlace/writeCustomTracks.c index 89b6571..b27841a 100644 --- src/hg/hgPhyloPlace/writeCustomTracks.c +++ src/hg/hgPhyloPlace/writeCustomTracks.c @@ -470,41 +470,43 @@ fprintf(f, ";AN=%d\tGT", sampleCount - noCallCount); int gtIx; for (gtIx = 0; gtIx < sampleCount; gtIx++) fprintf(f, "\t%c", genotypes[gtIx]); fputc('\n', f); } } } static void writeSubtreeVcf(FILE *f, struct hash *sampleToIx, char *chrom, int chromSize, struct vcfFile *userVcf, struct phyloTree *subtree) /* Write rows of VCF with genotypes for samples in sampleToIx (with order determined by sampleToIx) * with some samples found in userVcf and the rest found in subtree which has been annotated * with single-nucleotide variants. */ { -char refBases[chromSize]; -memset(refBases, 0, sizeof refBases); -char *sampleBases[chromSize]; -memset(sampleBases, 0, sizeof sampleBases); +char *refBases = NULL; +AllocArray(refBases, chromSize); +char **sampleBases = NULL; +AllocArray(sampleBases, chromSize); treeToBaseAlleles(subtree, refBases, sampleBases, sampleToIx, NULL); vcfToBaseAlleles(userVcf, refBases, sampleBases, sampleToIx); int sampleCount = sampleToIx->elCount; baseAllelesToVcf(refBases, sampleBases, chrom, chromSize, sampleCount, f); int i; for (i = 0; i < chromSize; i++) freeMem(sampleBases[i]); +freeMem(sampleBases); +freeMem(refBases); } static void addSubtreeCustomTracks(FILE *ctF, char *userVcfFile, struct subtreeInfo *subtreeInfoList, struct hash *samplePlacements, char *chrom, int chromSize, char *source, char *geneTrack, int fontHeight, int *pStartTime) /* For each subtree trashfile, write VCF+treeFile custom track text to ctF. */ { struct vcfFile *userVcf = parseUserVcf(userVcfFile, chromSize, pStartTime); if (! userVcf) { warn("Problem parsing VCF file with user variants '%s'; can't make subtree subtracks.", userVcfFile); return; } struct subtreeInfo *ti;