struct hash *buildMultiAlignHash() /* Return a hash table filled with names of cDNAs that align more * than once. */ { FILE *aliFile; struct cdaAli *cda; struct hash *dupeHash; char lastName[128]; char *name; int dupeCount = 0; lastName[0] = 0; dupeHash = newHash(12); aliFile = wormOpenGoodAli(); while (cda = cdaLoadOne(aliFile)) { name = cda->name; if (sameString(name, lastName)) { if (!hashLookup(dupeHash, name)) { hashAdd(dupeHash, name, NULL); ++dupeCount; } } strcpy(lastName, name); cdaFreeAli(cda); } fclose(aliFile); printf("Found %d multiple alignments\n", dupeCount); return dupeHash; }
struct cdaAli *wormCdaAli(char *name) /* Return named cDNA alignment or NULL if it doesn't exist. */ { long offset; wormOpenAliSnof(); if (!snofFindOffset(aliSnof, name, &offset)) return NULL; fseek(aliFile, offset, SEEK_SET); return cdaLoadOne(aliFile); }
struct cdaAli *readAllCda() /* Read in all worm Cda (cDNA alignments medium detail level) and return them. */ { struct cdaAli *list = NULL, *el; FILE *f = anyOpenGoodAli(); while ((el = cdaLoadOne(f)) != NULL) { // if (el->chromIx == 0 && el->chromStart < 1000000) /* uglyf */ slAddHead(&list, el); } slReverse(&list); return list; }
struct cdaAli *wormCdaAlisInRange(char *chromId, int start, int end) /* Return list of cdna alignments that overlap range. */ { struct cdaAli *list = NULL, *el; char fileName[512]; FILE *ixFile, *aliFile; bits32 sig; int s, e; long fpos; aliFile = wormOpenGoodAli(); sprintf(fileName, "%s%s.alx", cdnaDir, chromId); ixFile = mustOpen(fileName, "rb"); mustReadOne(ixFile, sig); if (sig != alxSig) errAbort("Bad signature on %s", fileName); for (;;) { if (!readOne(ixFile, s)) break; mustReadOne(ixFile, e); mustReadOne(ixFile, fpos); if (e <= start) continue; if (s >= end) break; AllocVar(el); fseek(aliFile, fpos, SEEK_SET); el = cdaLoadOne(aliFile); if (el == NULL) errAbort("Truncated cdnaAli file"); slAddHead(&list, el); } slReverse(&list); fclose(aliFile); fclose(ixFile); return list; }