void emblMatrixToMotif(char *inName, char *outName) /* emblMatrixToMotif - Convert transfac matrix in EMBL format to dnaMotif. */ { struct hash *hash = NULL; struct lineFile *lf = emblOpen(inName, NULL); FILE *f = mustOpen(outName, "w"); struct dnaMotif *motif; while ((hash = emblRecord(lf)) != NULL) { char *ac = hashFindVal(hash, "AC"); char *po = hashFindVal(hash, "P0"); if (ac != NULL && po != NULL && orgFits(hash)) { motif = emblToMotif(ac, hash); dnaMotifTabOut(motif, f); dnaMotifFree(&motif); } } }
struct lineFile *emblOpen(char *fileName, char type[256]) /* Open up embl file, verify format and optionally return * type (VV line). Close this with lineFileClose(). */ { struct lineFile *lf = lineFileOpen(fileName, TRUE); struct hash *hash = emblRecord(lf); char *vv; if (hash == NULL) notEmbl(fileName); if ((vv = hashFindVal(hash, "VV")) == NULL) notEmbl(fileName); if (type != NULL) { if (strlen(vv) >= 256) notEmbl(fileName); strcpy(type, vv); } freeHashAndVals(&hash); return lf; }