Beispiel #1
0
void agpHashFree(struct hash **pAgpHash)
/* Free up the hash created with agpLoadAll. */
{
struct hash *agpHash = *pAgpHash;
hashTraverseEls(agpHash, freeAgpHashEl);
freeHash(&agpHash);
*pAgpHash = NULL;
}
void dumpRbmTrees(struct hash *chromTrees, char *table, char *suffix)
/* Dump out chrom-hashed rbmTrees of non-overlapping ranges as bed 4 
 * for comparison with featureBits -bed output. */
{
char fname[512];
safef(fname, sizeof(fname), "%s.%s.%s.bed", hGetDb(), table, suffix);
dumpTreesF = mustOpen(fname, "w");
hashTraverseEls(chromTrees, dumpOneRbmTree);
carefulClose(&dumpTreesF);
}
Beispiel #3
0
void gfFileCacheFree(struct hash **pCache)
/* Free up resources in cache. */
{
struct hash *cache = *pCache;
if (cache != NULL)
    {
    hashTraverseEls(cache, gfFileCacheFreeEl);
    hashFree(pCache);
    }
}
void closeFiles()
/* If split, close each file pointer in chromFpHash.  Otherwise close the
 * single file pointer that we've been using. */
{
    if (split)
    {
        hashTraverseEls(chromFpHash, helCarefulClose);
    }
    else
        carefulClose(&theFile);
}
struct hash *getFreqHash(char *freqFile)
/* Read the frequency file in, and store it in a hash and return that. */
{
struct hash *freqHash = newHash(23);
struct lineFile *lf = lineFileOpen(freqFile, TRUE);
char *words[3];
/* Assume there's a header and skip it. */
lineFileSkip(lf, 1);
while (lineFileRowTab(lf, words))
    {
    int val;
    lineFileNeedFullNum(lf, words, 1);
    lineFileNeedFullNum(lf, words, 2);
    val = (int)sqlUnsigned(words[2]);
    addFreqToHash(freqHash, words[0], words[1], val);
    }
lineFileClose(&lf);
hashTraverseEls(freqHash, sortSlPairList);
return freqHash;
}
Beispiel #6
0
void netContigs(char *netFile, char *liftFile)
/* netContigs - get query-side contigs from a chrom-level net file */
{
struct lineFile *lf = lineFileOpen(netFile, TRUE);
struct chainNet *net;

struct liftSpec *lift, *prevLift, *lifts;
char *chrom;

/* read lift file and split into a hash of per-chrom lists */
lifts = readLifts(liftFile);
prevLift = NULL;
for (lift = lifts; lift != NULL; lift = lift->next)
    {
    //uglyf("reading lift: %s\n", lift->oldName);
    if (hashLookup(chromHash, lift->newName) == NULL)
        {
        /* new chrom */
        //uglyf("adding chrom: %s\n", lift->newName);
        hashAdd(chromHash, lift->newName, lift);
        /* terminate previous list */
        /* NOTE: expects input sorted by chrom */
        if (prevLift != NULL)
            prevLift->next = NULL;
        }
    prevLift = lift;
    }

/* read in nets and convert query side to contig coords */
//uglyf("reading in nets\n");
while ((net = chainNetRead(lf)) != NULL)
    {
    rLower(net->fillList);
    chainNetFree(&net);
    }
/* print accumulated contigs */
hashTraverseEls(contigNames, printContig);
}
void freeRbmTreeHash(struct hash **pTreeHash)
/* Free up a whole hash of rbmTrees of ranges. */
{
hashTraverseEls(*pTreeHash, hashElFreeRbmTree);
hashFree(pTreeHash);
}
void freeFreqHash(struct hash **pFreqHash)
/* Free up the hash we created. */
{
hashTraverseEls(*pFreqHash, hashElSlPairListFree);
hashFree(pFreqHash);
}
void doExpRatio(struct trackDb *tdb, char *item, struct customTrack *ct)
/* Generic expression ratio deatils using microarrayGroups.ra file */
/* and not the expRecord tables. */
{
char *expScale = trackDbRequiredSetting(tdb, "expScale");
char *expStep = trackDbRequiredSetting(tdb, "expStep");
double maxScore = atof(expScale);
double stepSize = atof(expStep);
struct bed *bedList;
char *itemName = cgiUsualString("i2","none");
char *expName = (item == NULL) ? itemName : item;
char *tdbSetting = trackDbSettingOrDefault(tdb, "expColor", "redGreen");
char *colorVal = NULL;
enum expColorType colorScheme;
char colorVarName[256];
safef(colorVarName, sizeof(colorVarName), "%s.color", tdb->track);
colorVal = cartUsualString(cart, colorVarName, tdbSetting);
colorScheme = getExpColorType(colorVal);

if (sameWord(tdb->grp, "cancerGenomics"))
    {
    /* set global flag */
    isCancerGenomicsTrack = TRUE;
    }

if (!ct)
    {
    genericHeader(tdb, itemName);
    bedList = loadMsBed(tdb, tdb->table, seqName, winStart, winEnd);
    }
else if (ct->dbTrack)
    {
    genericHeader(tdb, itemName);
    printCustomUrl(tdb, itemName, TRUE);
    bedList = ctLoadMultScoresBedDb(ct, seqName, winStart, winEnd);
    }
else
    bedList = bedFilterListInRange(ct->bedList, NULL, seqName, winStart, winEnd);
if (bedList == NULL)
    printf("<b>No Expression Data in this Range.</b>\n");
else if (expName && sameString(expName, "zoomInMore"))
    printf("<b>Too much data to display in detail in this range.</b>\n");
else
    {
    struct microarrayGroups *groupings = NULL;
    struct maGrouping *combineGroup;
    struct hash *erHash = newHash(6);
    int i;
    if (!ct)
	{
	groupings = maGetTrackGroupings(database, tdb);
	combineGroup = maCombineGroupingFromCart(groupings, cart, tdb->track);
	}
    else
	combineGroup = maGetGroupingFromCt(ct);
    maBedClumpGivenGrouping(bedList, combineGroup);
    for (i = 0; i < combineGroup->numGroups; i++)
	{
	/* make stupid exprecord hash.perhaps eventually this won't be needed */
	char id[16];
	struct expRecord *er = basicExpRecord(combineGroup->names[i], i, 2);
	safef(id, sizeof(id), "%d", i);
	hashAdd(erHash, id, er);
	}
    puts("<h2></h2><p>\n");
    msBedPrintTable(bedList, erHash, itemName, expName, -1*maxScore, maxScore,
	stepSize, 2, msBedDefaultPrintHeader, msBedExpressionPrintRow,
	printExprssnColorKey, getColorForExprBed, colorScheme);
    hashTraverseEls(erHash, erHashElFree);
    hashFree(&erHash);
    microarrayGroupsFree(&groupings);
    }
puts("<h2></h2><p>\n");
bedFreeList(&bedList);
}
Beispiel #10
0
void loadSplitTables(char *database, struct sqlConnection *conn)
/* For each chrom in chromHash, load its tempfile into table chrom_suffix. */
{
    theConn = conn;
    hashTraverseEls(chromFpHash, loadOneSplitTable);
}