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; }
void wormOpenAliSnof() /* Set up for fast access alignments of named cDNAs. */ { if (aliSnof == NULL) { char fileName[512]; sprintf(fileName, "%sgood", wormCdnaDir()); aliSnof = snofOpen(fileName); } if (aliFile == NULL) aliFile = wormOpenGoodAli(); }
FILE *anyOpenGoodAli() /* Open up binary alignment file for fly or worm. */ { if (isFly) { return flyOpenGoodAli(); } else { return wormOpenGoodAli(); } }
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; }