static struct slName *getBedFieldSlNameList(struct hTableInfo *hti,
        char *db, char *table)
/* Return the bed-compat field list for the given table, as
 * slName list of "$db.$table.$field". */
{
    struct slName *snList = NULL, *sn = NULL;
    int fieldCount = 0;
    char *fields = NULL;
    char *words[16];
    char dtf[256];
    int i;
    if (hti == NULL)
        errAbort("Can't find table info for table %s.%s", db, table);
    bedSqlFieldsExceptForChrom(hti, &fieldCount, &fields);
    /* Update our notion of fieldCount -- the chrom field is omitted, and
     * (if applicable) the reserved field is omitted too: */
    fieldCount = chopCommas(fields, words);
    for (i=fieldCount-1;  i >= 0;  i--)
    {
        if (sameString(words[i], "0"))
            continue;
        safef(dtf, sizeof(dtf), "%s.%s.%s", db, table, words[i]);
        sn = slNameNew(dtf);
        slAddHead(&snList, sn);
    }
    safef(dtf, sizeof(dtf), "%s.%s.%s", db, table, hti->chromField);
    sn = slNameNew(dtf);
    slAddHead(&snList, sn);
    freez(&fields);
    return snList;
}
struct slName *getTablesForField(struct sqlConnection *conn,
                                 char *splitPrefix, char *table, char *splitSuffix)
/* Get tables that match field. */
{
    struct slName *list = NULL, *el;
    if (splitPrefix != NULL || splitSuffix != NULL)
    {
        char query[256], **row;
        struct sqlResult *sr;
        safef(query, sizeof(query), "show tables like '%s%s%s'",
              emptyForNull(splitPrefix), table, emptyForNull(splitSuffix));
        sr = sqlGetResult(conn, query);
        while ((row = sqlNextRow(sr)) != NULL)
        {
            el = slNameNew(row[0]);
            slAddHead(&list, el);
        }
        sqlFreeResult(&sr);
        slReverse(&list);
    }
    if (list == NULL)
    {
        if (sqlTableExists(conn, table))
            list = slNameNew(table);
    }
    return list;
}
Пример #3
0
static void addTablesAccordingToTrackType(char *db, struct slName **pList, struct hash *uniqHash,
                                          struct trackDb *track)
/* Parse out track->type and if necessary add some tables from it. */
{
struct slName *name;
char *trackDupe = cloneString(track->type);
if (trackDupe != NULL && trackDupe[0] != 0)
    {
    char *s = trackDupe;
    char *type = nextWord(&s);
    if (sameString(type, "wigMaf"))
        {
	static char *wigMafAssociates[] = {"frames", "summary"};
	int i;
	for (i=0; i<ArraySize(wigMafAssociates); ++i)
	    {
	    char *setting = wigMafAssociates[i];
	    char *table = trackDbSetting(track, setting);
            if (table != NULL)
                {
                name = slNameNew(table);
                slAddHead(pList, name);
                hashAdd(uniqHash, table, NULL);
                }
	    }
        /* include conservation wiggle tables */
        struct consWiggle *wig, *wiggles = wigMafWiggles(db, track);
        slReverse(&wiggles);
        for (wig = wiggles; wig != NULL; wig = wig->next)
            {
            name = slNameNew(wig->table);
            slAddHead(pList, name);
            hashAdd(uniqHash, wig->table, NULL);
            }
	}
    if (track->subtracks)
        {
        struct slName *subList = NULL;
	struct slRef *tdbRefList = trackDbListGetRefsToDescendantLeaves(track->subtracks);
	slSort(&tdbRefList, trackDbRefCmp);
	struct slRef *tdbRef;
	for (tdbRef = tdbRefList; tdbRef != NULL; tdbRef = tdbRef->next)
            {
	    struct trackDb *subTdb = tdbRef->val;
	    name = slNameNew(subTdb->table);
	    slAddTail(&subList, name);
	    hashAdd(uniqHash, subTdb->table, NULL);
            }
        pList = slCat(pList, subList);
        }
    }
freez(&trackDupe);
}
Пример #4
0
struct slName *cartTrackDbTablesForTrack(char *db, struct trackDb *track, boolean useJoiner)
/* Return list of all tables associated with track.  If useJoiner, the result can include
 * non-positional tables that are related to track by all.joiner. */
{
static struct joiner *allJoiner = NULL;
struct hash *uniqHash = newHash(8);
struct slName *name, *nameList = NULL;
char *trackTable = track->table;

hashAdd(uniqHash, trackTable, NULL);
if (useJoiner)
    {
    if (allJoiner == NULL)
        allJoiner = joinerRead("all.joiner");
    struct joinerPair *jpList, *jp;
    jpList = joinerRelate(allJoiner, db, trackTable);
    for (jp = jpList; jp != NULL; jp = jp->next)
	{
	struct joinerDtf *dtf = jp->b;
	if (cartTrackDbIsAccessDenied(dtf->database, dtf->table))
	    continue;
	char buf[256];
	char *s;
	if (sameString(dtf->database, db))
	    s = dtf->table;
	else
	    {
	    safef(buf, sizeof(buf), "%s.%s", dtf->database, dtf->table);
	    s = buf;
	    }
	if (!hashLookup(uniqHash, s))
	    {
	    hashAdd(uniqHash, s, NULL);
	    name = slNameNew(s);
	    slAddHead(&nameList, name);
	    }
	}
    slNameSort(&nameList);
    }
/* suppress for parent tracks -- only the subtracks have tables */
if (track->subtracks == NULL)
    {
    name = slNameNew(trackTable);
    slAddHead(&nameList, name);
    }
addTablesAccordingToTrackType(db, &nameList, uniqHash, track);
hashFree(&uniqHash);
return nameList;
}
Пример #5
0
struct slName *charSepToSlNames(char *string, char c)
/* Convert character-separated list of items to slName list. 
 * Note that the last occurence of c is optional.  (That
 * is for a comma-separated list a,b,c and a,b,c, are
 * equivalent. */
{
struct slName *list = NULL, *el;
char *s, *e;

s = string;
while (s != NULL && s[0] != 0)
    {
    e = strchr(s, c);
    if (e == NULL)
        {
	el = slNameNew(s);
	slAddHead(&list, el);
	break;
	}
    else
        {
	el = slNameNewN(s, e - s);
	slAddHead(&list, el);
	s = e+1;
	}
    }
slReverse(&list);
return list;
}
Пример #6
0
struct slName *randomBigBedIds(char *table, struct sqlConnection *conn, int count)
/* Return some arbitrary IDs from a bigBed file. */
{
/* Figure out bigBed file name and open it.  Get contents for first chromosome as an example. */
struct slName *idList = NULL;
char *fileName = bigBedFileName(table, conn);
struct bbiFile *bbi = bigBedFileOpen(fileName);
struct bbiChromInfo *chromList = bbiChromList(bbi);
struct lm *lm = lmInit(0);
int orderedCount = count * 4;
if (orderedCount < 100)
    orderedCount = 100;
struct bigBedInterval *iv, *ivList = getNElements(bbi, chromList, lm, orderedCount);
shuffleList(&ivList);
// Make a list of item names from intervals.
int outCount = 0;
for (iv = ivList;  iv != NULL && outCount < count;  iv = iv->next)
    {
    char *row[bbi->fieldCount];
    char startBuf[16], endBuf[16];
    bigBedIntervalToRow(iv, chromList->name, startBuf, endBuf, row, bbi->fieldCount);
    if (idList == NULL || differentString(row[3], idList->name))
	{
	slAddHead(&idList, slNameNew(row[3]));
	outCount++;
	}
    }
lmCleanup(&lm);
bbiFileClose(&bbi);
freeMem(fileName);
return idList;
}
Пример #7
0
struct hash *mtfToRnaHash(char *pcrBed)
/* Make hash keyed by numeric part of MTF id with values
 * of rnaList type */
{
struct rnaList *rl;
struct hash *hash = hashNew(0);
struct lineFile *lf = lineFileOpen(pcrBed, TRUE);
char *row[6];

while (lineFileRow(lf, row))
    {
    char *mtf = row[3] + 3;
    char *rna = row[0];
    struct slName *el;
    rl = hashFindVal(hash, mtf);
    if (rl == NULL)
        {
	AllocVar(rl);
	hashAdd(hash, mtf, rl);
	}
    chopSuffix(rna);
    el = slNameNew(rna);
    slAddHead(&rl->accList, el);
    }
lineFileClose(&lf);
return hash;
}
Пример #8
0
void checkDbTables(char *database, char *composite, struct hash *mdbHash, struct hash *allBbiNames)
// search the database for tables that begin with composite and call checkTable
{
struct sqlConnection *conn = sqlConnect(database);
char buffer[10 * 1024];

verbose(1, "----------------------------------------------\n");
verbose(1, "Checking that tables starting with composite in db are in metaDb\n (also checks dummy table and the bbi symlink and its target)\n");
verbose(1, "----------------------------------------------\n");
sqlSafef(buffer, sizeof buffer, "show tables like '%s%%'", composite);

struct sqlResult *sr;
sr = sqlGetResult(conn, buffer);
char **row;
struct slName *list = NULL;
while ((row = sqlNextRow(sr)) != NULL)
    {
    struct slName *el = slNameNew(row[0]);
    slAddHead(&list, el);
    }
sqlFreeResult(&sr);

for(; list; list = list->next)
    checkTable(conn, list->name, mdbHash, allBbiNames);
sqlDisconnect(&conn);
}
Пример #9
0
void doPrintSelectedFields()
/* Actually produce selected field output as text stream. */
{
char *db = cartString(cart, hgtaDatabase);
char *table = cartString(cart, hgtaTable);
char *varPrefix = checkVarPrefix();
int varPrefixSize = strlen(varPrefix);
struct hashEl *varList = NULL, *var;
struct slName *fieldList = NULL, *field;

textOpen();

/* Gather together field list for primary and linked tables from cart. */
varList = cartFindPrefix(cart, varPrefix);
for (var = varList; var != NULL; var = var->next)
    {
    if (!sameString(var->val, "0"))
	{
	field = slNameNew(var->name + varPrefixSize);
	if (primaryOrLinked(field->name))
	    slAddHead(&fieldList, field);
	}
    }
if (fieldList == NULL)
    errAbort("Please go back and select at least one field");
slReverse(&fieldList);

/* Do output. */
tabOutSelectedFields(db, table, NULL, fieldList);

/* Clean up. */
slFreeList(&fieldList);
hashElFreeList(&varList);
}
Пример #10
0
struct slName *getChromListFromContigInfo(char *contigGroup)
/* get all chromNames that match contigGroup */
{
struct slName *ret = NULL;
struct slName *el = NULL;
char query[512];
struct sqlConnection *conn = hAllocConn();
struct sqlResult *sr;
char **row;
char chromName[64];

sqlSafef(query, sizeof(query), "select distinct(contig_chr) from ContigInfo where group_term = '%s' and contig_end != 0", contigGroup);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
    {
    safef(chromName, sizeof(chromName), "%s", row[0]);
    el = slNameNew(chromName);
    slAddHead(&ret, el);
    }
sqlFreeResult(&sr);

// not needed for canFam1
// safef(query, sizeof(query), "select distinct(contig_chr) from ContigInfo where group_term = '%s' and contig_end = 0", contigGroup);
// sr = sqlGetResult(conn, query);
// while ((row = sqlNextRow(sr)) != NULL)
    // {
    // safef(chromName, sizeof(chromName), "%s_random", row[0]);
    // el = slNameNew(chromName);
    // slAddHead(&ret, el);
    // }
// sqlFreeResult(&sr);

hFreeConn(&conn);
return ret;
}
Пример #11
0
static struct slName *getGenomeDbs(struct gbConf *conf)
/* get list of genome databases from variable names */
{
// build hash of dbs
struct hash *dbSet = hashNew(20);
struct hashCookie cookie = hashFirst(conf->hash);
struct hashEl *hel;
while ((hel = hashNext(&cookie)) != NULL)
    {
    char *prefix = parsePrefix(hel->name);
    if (isGenomeDb(prefix))
        hashStore(dbSet, prefix);
    }

// convert to a list of dbs
struct slName *dbs = NULL;
cookie = hashFirst(dbSet);
while ((hel = hashNext(&cookie)) != NULL)
    slSafeAddHead(&dbs, slNameNew(hel->name));
#ifdef DUMP_HASH_STATS
hashPrintStats(dbSet, "gbConfDbSet", stderr);
#endif
hashFree(&dbSet);
slSort(&dbs, slNameCmp);
return dbs;
}
Пример #12
0
struct slName *stringToSlNames(char *string)
/* Convert string to a list of slNames separated by
 * white space, but allowing multiple words in quotes.
 * Quotes if any are stripped.  */
{
struct slName *list = NULL, *name;
char *dupe = cloneString(string);
char c, *s = dupe, *e;

for (;;)
    {
    if ((s = skipLeadingSpaces(s)) == NULL)
        break;
    if ((c = *s) == 0)
        break;
    if (c == '\'' || c == '"')
        {
	if (!parseQuotedString(s, s, &e))
	    errAbort("missing closing %c in %s", c, string);
	}
    else
        {
	e = skipToSpaces(s);
	if (e != NULL) *e++ = 0;
	}
    name = slNameNew(s);
    slAddHead(&list, name);
    s = e;
    }
freeMem(dupe);
slReverse(&list);
return list;
}
Пример #13
0
void customPpReuse(struct customPp *cpp, char *line)
/* Reuse line.  May be called many times before next customPpNext/NextReal.
 * Should be called with last line to be reused first if called multiply. */
{
struct slName *s = slNameNew(line);
slAddHead(&cpp->reusedLines, s);
}
Пример #14
0
struct slName *htmlPageScanAttribute(struct htmlPage *page, 
	char *tagName, char *attribute)
/* Scan page for values of particular attribute in particular tag.
 * if tag is NULL then scans in all tags. */
{
struct htmlTag *tag;
struct htmlAttribute *att;
struct slName *list = NULL, *el;

for (tag = page->tags; tag != NULL; tag = tag->next)
    {
    if (tagName == NULL || sameWord(tagName, tag->name))
        {
	for (att = tag->attributes; att != NULL; att = att->next)
	    {
	    if (sameWord(attribute, att->name))
	        {
		el = slNameNew(att->val);
		slAddHead(&list, el);
		}
	    }
	}
    }
slReverse(&list);
return list;
}
Пример #15
0
void enumFilterOption(char *db, char *table, char *field, char *type,
		      char *logOp)
/* Print out a table row with filter constraint options for an enum/set.  */
{
char *name = NULL;
char **valMenu = NULL;
int valMenuSize = 0;

hPrintf("<TR VALIGN=BOTTOM align='left'><TD valign=top align='left'colspan=2> %s </TD>"
        "<TD valign=top>\n", field);
name = filterFieldVarName(db, table, field, filterDdVar);
cgiMakeDropListClassWithStyle(name, ddOpMenu, ddOpMenuSize,
                              cartUsualString(cart, name, ddOpMenu[0]),"normalText","width: 76px");
hPrintf("<TD valign=top>%s</TD><TD colspan=4 nowrap>\n", isSqlSetType(type) ? "include" : "match");
name = filterPatternVarName(db, table, field);
makeEnumValMenu(type, &valMenu, &valMenuSize);
if (logOp == NULL)
    logOp = "";
if (valMenuSize-1 > 2)
    {
    struct slName *defaults = cartOptionalSlNameList(cart, name);
    if (defaults == NULL)
	defaults = slNameNew("*");
    cgiMakeCheckboxGroup(name, valMenu, valMenuSize, defaults, 5);
    hPrintf("</TD><TD>%s </TD></TR>\n", logOp);
    }
else
    {
    cgiMakeDropList(name, valMenu, valMenuSize,cartUsualString(cart, name, valMenu[0]));
    hPrintf("&nbsp;%s </TD></TR>\n", logOp);
    }
}
Пример #16
0
static void normalizePatList(struct slName **pPatList)
/* patList might be a plain old list of terms, in which case we keep the
 * terms only if they are not no-ops.  patList might also be one element
 * that is a space-separated list of terms, in which case we make a new
 * list item for each non-no-op term.  (Trim spaces while we're at it.) */
{
struct slName *pat, *nextPat, *patListOut = NULL;
if (pPatList == NULL) return;
for (pat = *pPatList;  pat != NULL;  pat = nextPat)
    {
    nextPat = pat->next;
    strcpy(pat->name, trimSpaces(pat->name));
    if (hasWhiteSpace(pat->name))
	{
	char *line = pat->name, *word;
	while ((word = nextQuotedWord(&line)) != NULL)
	    if (wildReal(word))
		{
		struct slName *newPat = slNameNew(word);
		slAddHead(&patListOut, newPat);
		}
	slNameFree(&pat);
	}
    else if (wildReal(pat->name))
	slAddHead(&patListOut, pat);
    }
*pPatList = patListOut;
}
Пример #17
0
void getAllSplices(char *database, FILE *f)
/* Write out table linking flybase genes with BDGP transcripts --
 * unfortunately bdgpGeneInfo lacks -R* transcript/isoform identifiers,
 * so strip those off of bdgpGene.name. 
 * This is not necessary with flyBaseGene/flyBase2004Xref where -R*'s 
 * are preserved.
*/
{
struct sqlConnection *conn = sqlConnect(database);
struct sqlResult *sr;
char query[256], **row;
struct geneAlt *altList = NULL, *alt;
struct hash *bdgpHash = newHash(16);	/* Keyed by bdgp gene id. */
struct slName *n;

/* First build up list of all genes with flybase and bdgp ids. */
sqlSafef(query, sizeof(query), "select bdgpName,flyBaseId from bdgpGeneInfo");
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
    {
    AllocVar(alt);
    alt->bdgpName = cloneString(row[0]);
    alt->fbName = cloneString(row[1]);
    slAddHead(&altList, alt);
    hashAdd(bdgpHash, alt->bdgpName, alt);
    }
sqlFreeResult(&sr);
slReverse(&altList);

/* Now associate splicing variants. */
sqlSafef(query, sizeof(query), "select name from %s", geneTable);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
    {
    char *s = row[0];
    char *e = rStringIn("-R", s);
    int size = e ? (e - s) : strlen(s);
    char bdgpGene[16];
    if (size >= sizeof(bdgpGene))
        errAbort("'%s' too big", s);
    memcpy(bdgpGene, s, size);
    bdgpGene[size] = 0;
    alt = hashMustFindVal(bdgpHash, bdgpGene);
    n = slNameNew(s);
    slAddTail(&alt->isoformList, n);
    }
sqlFreeResult(&sr);
sqlDisconnect(&conn);

for (alt = altList; alt != NULL; alt = alt->next)
    {
    for (n = alt->isoformList; n != NULL; n = n->next)
	fprintf(f, "%s\t%s\n", alt->fbName, n->name);
    }
freeHash(&bdgpHash);
}
Пример #18
0
static void hashAddSlName(struct hash *hash, char *key, char *val)
/* If key is already in hash, add an slName for val to the head of the list;
 * otherwise just store key -> slName for val. */
{
struct slName *sln = slNameNew(val);
struct hashEl *hel = hashLookup(hash, key);
if (hel == NULL)
    hashAdd(hash, key, sln);
else
    slAddHead(&(hel->val), sln);
}
void userSettingsCapturePrefix(struct userSettings *us, char *prefix)
/* Capture all variables that start with prefix. */
{
struct hashEl *el, *list = cartFindPrefix(us->cart, prefix);
for (el = list; el != NULL; el = el->next)
     {
    struct slName *n = slNameNew(el->name);
    slAddHead(&us->saveList, n);
    }
slFreeList(&list);
}
Пример #20
0
struct slName *tablesForDb(char *db)
/* Find tables associated with database. */
{
boolean isGenomeDb = sameString(db, database);
struct sqlConnection *conn = hAllocConn(db);
struct slName *raw, *rawList = sqlListTables(conn);
struct slName *cooked, *cookedList = NULL;
struct hash *uniqHash = newHash(0);

hFreeConn(&conn);
for (raw = rawList; raw != NULL; raw = raw->next)
    {
    if (cartTrackDbIsAccessDenied(db, raw->name))
        continue;
    if (isGenomeDb)
	{
	/* Deal with tables split across chromosomes. */
	char *root = unsplitTableName(raw->name);
	if (cartTrackDbIsAccessDenied(db, root))
	    continue;
	if (!hashLookup(uniqHash, root))
	    {
	    hashAdd(uniqHash, root, NULL);
	    cooked = slNameNew(root);
	    slAddHead(&cookedList, cooked);
	    }
	}
    else
        {
	char dbTable[256];
	safef(dbTable, sizeof(dbTable), "%s.%s", db, raw->name);
	cooked = slNameNew(dbTable);
	slAddHead(&cookedList, cooked);
	}
    }
hashFree(&uniqHash);
slFreeList(&rawList);
slSort(&cookedList, slNameCmp);
return cookedList;
}
Пример #21
0
void hgProtIdToGenePred(char *database, char *geneTable, 
	char *linkTable, char *geneField, char *protField)
/* hgProtIdToGenePred - Add proteinID column to genePrediction. */
{
struct sqlConnection *conn = sqlConnect(database);
struct sqlResult *sr;
char **row;
char query[256];
struct hash *protHash = makeProtHash(conn, linkTable, geneField, protField);
struct slName *gene, *geneList = NULL;

/* Create new column not filled with anything. */
printf("Adding column\n");
sqlSafef(query, sizeof(query), 
   "alter table %s add column (proteinID varchar(40) not null)",
   geneTable);
sqlUpdate(conn, query);

/* Get list of genes. */
printf("scanning genes\n");
sqlSafef(query, sizeof(query),
   "select name from %s", geneTable);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
    {
    gene = slNameNew(row[0]);
    slAddHead(&geneList, gene);
    }
sqlFreeResult(&sr);
slReverse(&geneList);

/* Update each gene. */
printf("updating proteinID values\n");
for (gene = geneList; gene != NULL; gene = gene->next)
    {
    char *prot = hashFindVal(protHash, gene->name);
    if (prot == NULL)
        prot = "n/a";
    sqlSafef(query, sizeof(query), 
    	"update %s set proteinID = '%s' where name = '%s'",
	geneTable, prot, gene->name);
    sqlUpdate(conn, query);
    }

/* Add new index. */
printf("indexing\n");
sqlSafef(query, sizeof(query),
    "create index proteinID on %s (proteinID(10))", geneTable);
sqlUpdate(conn, query);
}
Пример #22
0
static struct hash *getAllPossibleIds(struct sqlConnection *conn,
				      struct lm *lm, char *idField, char *extraWhere)
/* If curTable is a custom track or bigFile, return NULL.  Otherwise,
 * make a hash of all identifiers in curTable (and alias tables if specified)
 * so that we can check the validity of pasted/uploaded identifiers. */
{
if (isCustomTrack(curTable) || isBamTable(curTable) || isVcfTable(curTable, NULL) ||
    isBigBed(database, curTable, curTrack, ctLookupName))
    return NULL;

struct hash *matchHash = hashNew(20);
struct slName *tableList;
char *xrefTable = NULL, *xrefIdField = NULL, *aliasField = NULL;
struct sqlConnection *alternateConn = conn;

if (sameWord(curTable, WIKI_TRACK_TABLE))
    alternateConn = wikiConnect();

if (sameWord(curTable, WIKI_TRACK_TABLE))
    tableList = slNameNew(WIKI_TRACK_TABLE);
else if (strchr(curTable, '.'))
    tableList = slNameNew(curTable);
else
    tableList = hSplitTableNames(database, curTable);
if (idField != NULL)
    addPrimaryIdsToHash(alternateConn, matchHash, idField, tableList, lm, extraWhere);
getXrefInfo(alternateConn, &xrefTable, &xrefIdField, &aliasField);
if (xrefTable != NULL)
    {
    addXrefIdsToHash(alternateConn, matchHash, idField,
		     xrefTable, xrefIdField, aliasField, lm, extraWhere);
    }
if (sameWord(curTable, WIKI_TRACK_TABLE))
    wikiDisconnect(&alternateConn);
return matchHash;
}
void testIntersect(char *db, char *track1, char *track2)
/* testIntersect - Test some ideas on intersections. */
{
struct slName *chromList = NULL, *chrom;
struct sqlConnection *conn;

hSetDb(db);
if (optionExists("chrom"))
    chromList = slNameNew(optionVal("chrom", NULL));
else
    chromList = hAllChromNames();
conn = hAllocConn();
for (chrom = chromList; chrom != NULL; chrom = chrom->next)
     intersectOnChrom(db, conn, chrom->name, track1, track2);
hFreeConn(&conn);
}
Пример #24
0
static struct slName *getPreview(struct customPp *cpp, int count)
/* Get preview lines. */
{
struct slName *list = NULL, *el;
int i;
for (i=0; i<count; ++i)
    {
    char *s = customFactoryNextRealTilTrack(cpp);
    if (s == NULL)
        break;
    el = slNameNew(s);
    slAddHead(&list, el);
    }
slReverse(&list);
return list;
}
Пример #25
0
static void testLoadPrefixes(struct gbSelect* select, unsigned flags,
                             char* restrictPrefix)
/* do load testing of part of a release */
{
struct slName* prefixes, *prefix;
if (restrictPrefix != NULL)
    prefixes = slNameNew(restrictPrefix);
else
    prefixes = gbReleaseGetAccPrefixes(select->release, GB_PROCESSED, GB_EST);
for (prefix = prefixes; prefix != NULL; prefix = prefix->next)
    {
    select->accPrefix = prefix->name;
    testLoad(select, flags);
    }
slFreeList(&prefixes);
select->accPrefix = NULL;
}
static struct slName *expTissuesForProbeInImage(struct sqlConnection *conn, 
	int imageId,
	int probeId)
/* Get list of tissue where we have expression info in gene.
 * Put + or - depending on expression level. */
{
struct dyString *dy = dyStringNew(0);
struct slName *tissueList = NULL, *tissue;
char query[512], **row;
struct sqlResult *sr;
safef(query, sizeof(query),
   "select bodyPart.name,expressionLevel.level,expressionPattern.description "
   "from expressionLevel join bodyPart join imageProbe "
   "left join expressionPattern on expressionLevel.expressionPattern = expressionPattern.id "
   "where imageProbe.image = %d "
   "and imageProbe.probe = %d "
   "and imageProbe.id = expressionLevel.imageProbe "
   "and expressionLevel.bodyPart = bodyPart.id "
   "order by bodyPart.name"
   , imageId, probeId);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
    {
    double level = atof(row[1]);
    char *pattern = row[2];
    if (pattern)
    	tolowers(pattern);
    dyStringClear(dy);
    dyStringAppend(dy, row[0]);
    if (level == 1.0)
       dyStringAppend(dy, "(+)");
    else if (level == 0.0)
       dyStringAppend(dy, "(-)");
    else 
       dyStringPrintf(dy, "(%.2f)",level);
    if (pattern && !sameWord(pattern,"Not Applicable") && !sameWord(pattern,"Not Specified"))
    	dyStringPrintf(dy, " %s",pattern);
    tissue = slNameNew(dy->string);
    slAddHead(&tissueList, tissue);
    }
sqlFreeResult(&sr);
slReverse(&tissueList);
dyStringFree(&dy);
return tissueList;
}
Пример #27
0
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, optionSpecs);
if (argc != 7)
    usage();
keep = optionExists("keep");
loadDb = optionExists("loadDb");
statVals = optionMultiVal("stat", NULL);
if (statVals == NULL)
    {
    int i;
    for (i = 0; statValDefaults[i] != NULL; i++)
        slSafeAddHead(&statVals, slNameNew(statValDefaults[i]));
    }
ccdsMkTables(argv[1], argv[2], sqlSigned(argv[3]), argv[4], argv[5], argv[6]);
return 0;
}
Пример #28
0
static struct slName *storeRow(struct sqlConnection *conn, char *query)
/* Just save the results of a single row query in a string list. */
{
struct sqlResult *sr = sqlGetResult(conn, query);
char **row;
struct slName *list = NULL, *el;
int i, colCount = sqlCountColumns(sr);
if ((row = sqlNextRow(sr)) != NULL)
     {
     for (i=0; i<colCount; ++i)
         {
	 el = slNameNew(row[i]);
	 slAddTail(&list, el);
	 }
     }
sqlFreeResult(&sr);
return list;
}
Пример #29
0
static void asParseColSymSpec(struct tokenizer *tkz, struct asObject *obj,
                              struct asColumn *col)
/* parse the enum or set symbolic values for a column */
{
    tokenizerMustHaveNext(tkz);
    while (tkz->string[0] != ')')
    {
        slSafeAddHead(&col->values, slNameNew(tkz->string));
        /* look for `,' or `)', but allow `,' after last token */
        tokenizerMustHaveNext(tkz);
        if (!((tkz->string[0] == ',') || (tkz->string[0] == ')')))
            tokenizerErrAbort(tkz, "expected `,' or `)' got `%s'", tkz->string);
        if (tkz->string[0] != ')')
            tokenizerMustHaveNext(tkz);
    }
    tokenizerMustMatch(tkz, ")");
    slReverse(&col->values);
}
Пример #30
0
static struct slName *hgFindSpecNameList(char *db)
/* Return the hgFindSpec table name(s) to use (based on trackDb name). */
{
struct slName *trackDbList = hTrackDbList();
struct slName *specNameList = NULL;
struct slName *tdbName;
for (tdbName = trackDbList; tdbName != NULL; tdbName = tdbName->next)
    {
    char *subbed = replaceChars(tdbName->name, "trackDb", "hgFindSpec");
    if (hTableExists(db, subbed))
	slNameAddHead(&specNameList, subbed);
    freez(&subbed);
    }
if (!specNameList)
    specNameList = slNameNew("hgFindSpec");
else
    slReverse(&specNameList);
return specNameList;
}