예제 #1
0
파일: chainDb.c 프로젝트: bowhan/kent
struct chain *chainHeadLoadAll(char *fileName) 
/* Load all chain from a tab-separated file.
 * Dispose of this with chainFreeList(). */
{
struct chain *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[11];

while (lineFileRow(lf, row))
    {
    el = chainHeadLoad(row);
    slAddHead(&list, el);
    }
lineFileClose(&lf);
slReverse(&list);
return list;
}
예제 #2
0
struct chain *chainDbLoad(char *db, struct sqlConnection *conn, char *track,
			  char *chrom, int id)
/** Load chain. */
{
char table[HDB_MAX_TABLE_STRING];
char query[256];
struct sqlResult *sr;
char **row;
int rowOffset;
struct chain *chain = NULL;

if (!hFindSplitTable(db, chrom, track, table, sizeof table, &rowOffset))
    errAbort("No %s track in database", track);
sqlSafef(query, sizeof(query), 
	 "select * from %s where id = %d", table, id);
sr = sqlGetResult(conn, query);
row = sqlNextRow(sr);
if (row == NULL)
    errAbort("Can't find %d in %s", id, table);
chain = chainHeadLoad(row + rowOffset);
sqlFreeResult(&sr);
chainDbAddBlocks(chain, track, conn);
return chain;
}