Пример #1
0
static struct chromInfo *loadChromInfo(struct sqlConnection *conn)
{
struct chromInfo *ret = NULL;
char **row;
char query[256];
int chromCount = 0;

cInfoHash = newHash(0);

if (workChr)
    sqlSafef(query, ArraySize(query), "SELECT * FROM chromInfo WHERE "
	"chrom='%s' ORDER BY chrom DESC", workChr);
else
    sqlSafef(query, ArraySize(query),
	"SELECT * FROM chromInfo ORDER BY chrom DESC");

struct sqlResult *sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
    {
    struct chromInfo *el;
    struct chromInfo *ci;
    AllocVar(ci);
    el = chromInfoLoad(row);
    ci->chrom = cloneString(el->chrom);
    ci->size = el->size;
    slAddHead(&ret, ci);
    hashAddInt(cInfoHash, el->chrom, el->size);
    ++chromCount;
    }
sqlFreeResult(&sr);
verbose(2,"#\tchrom count: %d\n", chromCount);
return (ret);
}
Пример #2
0
static struct hash *chromInfoHash(struct sqlConnection *conn)
/* Build up hash of chromInfo keyed by name */
{
struct sqlResult *sr;
char **row;
struct hash *hash = hashNew(0);
sr = sqlGetResult(conn, NOSQLINJ "select * from chromInfo");
while ((row = sqlNextRow(sr)) != NULL)
    {
    struct chromInfo *ci = chromInfoLoad(row);
    hashAdd(hash, ci->chrom, ci);
    }
sqlFreeResult(&sr);
return hash;
}
Пример #3
0
struct chromInfo *chromInfoLoadAllByChar(char *fileName, char chopper) 
/* Load all chromInfo from a chopper separated file.
 * Dispose of this with chromInfoFreeList(). */
{
struct chromInfo *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[3];

while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
    {
    el = chromInfoLoad(row);
    slAddHead(&list, el);
    }
lineFileClose(&lf);
slReverse(&list);
return list;
}
Пример #4
0
struct chromInfo *chromInfoLoadAll(char *fileName) 
/* Load all chromInfo from a whitespace-separated file.
 * Dispose of this with chromInfoFreeList(). */
{
struct chromInfo *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[3];

while (lineFileRow(lf, row))
    {
    el = chromInfoLoad(row);
    slAddHead(&list, el);
    }
lineFileClose(&lf);
slReverse(&list);
return list;
}
Пример #5
0
struct chromInfo *createChromInfoList(char *name, char *database)
/* Load up chromosome information for chrom 'name'.
 * If name is NULL or "all" then load all chroms.
 * Similar to featureBits.c - could be moved to library */
{
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr = NULL;
char **row;
int loaded=0;
struct chromInfo *ret = NULL;
unsigned totalSize = 0;
/* do the query */
if (!name || sameWord(name, "all"))
    sr = sqlGetResult(conn, "NOSQLINJ select * from chromInfo");
else
    {
    char select[256];
    sqlSafef(select, ArraySize(select), "select * from chromInfo where chrom='%s'", name);
    sr = sqlGetResult(conn, select);
    }
/* read the rows and build the chromInfo list */
while ((row = sqlNextRow(sr)) != NULL)
    {
    struct chromInfo *el;
    struct chromInfo *ci;
    AllocVar(ci);
    el = chromInfoLoad(row);
    ci->chrom = cloneString(el->chrom);
    ci->size = el->size;
    totalSize += el->size;
    slAddHead(&ret, ci);
    ++loaded;
    }
if (loaded < 1)
    errAbort("ERROR: can not find chrom name: '%s'\n", name ? name : "NULL");
slReverse(&ret);
if (!name || sameWord(name, "all"))
    verbose(2, "#\tloaded size info for %d chroms, total size: %u\n",
        loaded, totalSize);
sqlFreeResult(&sr);
hFreeConn(&conn);
return ret;
}
Пример #6
0
static struct chromInfo *fbCreateChromInfoList(char *name, char *database)
/* Load up all chromosome infos. */
{
struct sqlConnection *conn = sqlConnect(database);
struct sqlResult *sr = NULL;
char **row;
int loaded=0;
struct chromInfo *ret = NULL;
unsigned totalSize = 0;

if (sameWord(name, "all"))
    sr = sqlGetResult(conn, NOSQLINJ "select * from chromInfo");
else
    {
    char select[256];
    sqlSafef(select, ArraySize(select), "select * from chromInfo where chrom='%s'",
	name);
    sr = sqlGetResult(conn, select);
    }

while ((row = sqlNextRow(sr)) != NULL)
    {
    struct chromInfo *el;
    struct chromInfo *ci;
    AllocVar(ci);

    el = chromInfoLoad(row);
    ci->chrom = cloneString(el->chrom);
    ci->size = el->size;
    totalSize += el->size;
    slAddHead(&ret, ci);
    ++loaded;
    }
if (loaded < 1)
    errAbort("ERROR: can not find chrom name: '%s'\n", name);
slReverse(&ret);
if (sameWord(name, "all"))
    verbose(2, "#\tloaded size info for %d chroms, total size: %u\n",
	loaded, totalSize);
sqlFreeResult(&sr);
sqlDisconnect(&conn);
return ret;
}
Пример #7
0
struct chromInfo *getAllChromInfo(char *database)
/* Return list of info for all chromosomes. */
{
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
struct chromInfo *ci, *ciList = NULL;

sr = sqlGetResult(conn, "NOSQLINJ select * from chromInfo");
while ((row = sqlNextRow(sr)) != NULL)
    {
    ci = chromInfoLoad(row);
    slAddHead(&ciList, ci);
    }
sqlFreeResult(&sr);
hFreeConn(&conn);
slReverse(&ciList);
return ciList;
}
Пример #8
0
struct chromInfo *readChroms(struct hash *chromHash, struct sqlConnection *conn)
/* Return chromosomes in list/hash. */
{
struct chromInfo *chrom, *chromList = NULL;
char query[512];
char **row;
struct sqlResult *sr;

sqlSafef(query, sizeof query, "select * from chromInfo");
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
    {
    chrom = chromInfoLoad(row);
    hashAddUnique(chromHash, chrom->chrom, chrom);
    slAddHead(&chromList, chrom);
    }
sqlFreeResult(&sr);
slReverse(&chromList);
return chromList;
}
Пример #9
0
struct chromInfo *loadAllChromInfo(char *database)
/* Load up all chromosome infos. */
{
struct chromInfo *list = NULL, *el;
struct sqlConnection *conn = sqlConnect(database);
struct sqlResult *sr = NULL;
char **row;

sr = sqlGetResult(conn, "NOSQLINJ select * from chromInfo");
while ((row = sqlNextRow(sr)) != NULL)
    {
    el = chromInfoLoad(row);
    slAddHead(&list, el);
    }
sqlFreeResult(&sr);
slReverse(&list);
sqlDisconnect(&conn);
printf("Loaded %d chromosomes\n", slCount(list));
return list;
}
Пример #10
0
/* Copied from hgLoadWiggle. */
static struct hash *loadAllChromInfo()
/* Load up all chromosome infos. */
{
struct chromInfo *el;
struct sqlConnection *conn = sqlConnect(database);
struct sqlResult *sr = NULL;
struct hash *ret;
char **row;

ret = newHash(0);

sr = sqlGetResult(conn, "NOSQLINJ select * from chromInfo");
while ((row = sqlNextRow(sr)) != NULL)
    {
    el = chromInfoLoad(row);
    verbose(4, "Add hash %s value %u (%#lx)\n", el->chrom, el->size, (unsigned long)&el->size);
    hashAdd(ret, el->chrom, (void *)(& el->size));
    }
sqlFreeResult(&sr);
sqlDisconnect(&conn);
return ret;
}