struct view *makeViewList(struct slRef *manRefList) /* Return a list of views with everything on manList */ { struct hash *hash = hashNew(0); struct view *view, *viewList = NULL; struct slRef *ref; for (ref = manRefList; ref != NULL; ref = ref->next) { struct encode2Manifest *man = ref->val; char *outputType = man->outputType; char *format = man->format; view = hashFindVal(hash, outputType); if (view == NULL) { AllocVar(view); view->name = cloneString(outputType); view->format = cloneString(format); char trackName[64]; safef(trackName, sizeof(trackName), "v%d", ++viewId); view->trackName = cloneString(trackName); hashAdd(hash, outputType, view); slAddTail(&viewList, view); } if (!sameString(format, view->format)) errAbort("Multiple formats (%s and %s) in output_type %s", format, view->format, view->name); struct slRef *newRef = slRefNew(man); slAddTail(&view->manRefList, newRef); } hashFree(&hash); return viewList; }
struct composite *makeCompositeList(struct encode2Manifest *manList, struct hash *metaHash) /* Return a list of composites with everything on manList */ { struct composite *comp, *compList = NULL; struct hash *compHash = hashNew(0); char compName[256]; struct encode2Manifest *man; for (man = manList; man != NULL; man = man->next) { char *realComp = tagVal(man, metaHash, "composite"); if (realComp != NULL) safef(compName, sizeof(compName), "%s", realComp); else { char *lab = emptyForNull(tagVal(man, metaHash, "lab")); char *dataType = emptyForNull(tagVal(man, metaHash, "dataType")); safef(compName, sizeof(compName), "comp%s%s", lab, dataType); } comp = hashFindVal(compHash, compName); if (comp == NULL) { AllocVar(comp); comp->name = cloneString(compName); hashAdd(compHash, compName, comp); slAddTail(&compList, comp); } struct slRef *manRef = slRefNew(man); slAddTail(&comp->manRefList, manRef); } hashFree(&compHash); return compList; }
static struct slRef *sortedAllTracks(struct trackDb *trackList) /* Return an slRef list containing all tdbs in track list, sorted by shortLabel. */ { struct slRef *trackRefList = NULL; struct trackDb *tdb; for (tdb = trackList; tdb != NULL; tdb = tdb->next) slAddHead(&trackRefList, slRefNew(tdb)); slSort(&trackRefList, trackDbRefCmpShortLabel); return trackRefList; }
struct hash *hashUpPositions(struct bed **pBedList) /* Add beds to a hash of lists. */ { struct bed *popped; struct hash *theHash = hashNew(22); while ((popped = slPopHead(pBedList)) != NULL) { struct slRef *ref = slRefNew(popped); struct slRef *list = (struct slRef *)hashFindVal(theHash, popped->name); ref->next = list; hashReplace(theHash, popped->name, ref); } return theHash; }
static struct hash *hashTracksByGroup(struct trackDb *trackList) /* Hash group names to lists of tracks in those groups; sort each list by trackDb priority. */ { struct hash *hash = hashNew(0); struct trackDb *tdb; for (tdb = trackList; tdb != NULL; tdb = tdb->next) { struct hashEl *hel = hashLookup(hash, tdb->grp); struct slRef *slr = slRefNew(tdb); if (hel) slAddHead(&(hel->val), slr); else hashAdd(hash, tdb->grp, slr); } struct hashCookie cookie = hashFirst(hash); struct hashEl *hel; while ((hel = hashNext(&cookie)) != NULL) slSort(&hel->val, trackDbRefCmp); return hash; }
/* add a component to the range map. */ void malnSet_addComp(struct malnSet *malnSet, struct malnComp *comp) { if (malnSet->compRangeMap != NULL) { genomeRangeTreeAddValList(malnSet->compRangeMap, comp->seq->orgSeqName, comp->chromStart, comp->chromEnd, slRefNew(comp)); } }