Exemplo n.º 1
0
struct subjInfo *intAdvFilter(struct column *col,
	struct sqlConnection *conn, struct subjInfo *list)
/* Do advanced filter on string in main table. */
{
char *minString = advFilterVal(col, "min");
char *maxString = advFilterVal(col, "max");
if (minString || maxString)
    {
    int min = minString ? sqlSigned(minString) : 0;
    int max = maxString ? sqlSigned(maxString) : 0;
    struct subjInfo *newList = NULL, *next, *si;
    for (si = list; si != NULL; si = next)
        {
	char *cell = col->cellVal(col, si, conn);
	int val = sqlSigned(cell);
	freez(&cell);
	next = si->next;
	if (!((minString && (val < min)) || (maxString && (val > max))))
	    {
	    slAddHead(&newList, si);
	    }
	}
    slReverse(&newList);
    list = newList;
    }
return list;
}
Exemplo n.º 2
0
struct subjInfo *doubleAdvFilter(struct column *col,
	struct sqlConnection *conn, struct subjInfo *list)
/* Do advanced filter on string in main table. */
{
char *minString = advFilterVal(col, "min");
char *maxString = advFilterVal(col, "max");
if (minString || maxString)
    {
    double min = minString ? sqlDouble(minString) : 0.0;
    double max = maxString ? sqlDouble(maxString) : 0.0;
    struct subjInfo *newList = NULL, *next, *si;
    for (si = list; si != NULL; si = next)
        {
	char *cell = col->cellVal(col, si, conn);
	boolean invalid = sameString(cell,".");
	double val = invalid ? 0.0 : sqlDouble(cell);
	freez(&cell);
	next = si->next;
	if (!invalid && !((minString && (val < min)) || (maxString && (val > max))))
	    {
	    slAddHead(&newList, si);
	    }
	}
    slReverse(&newList);
    list = newList;
    }
return list;
}
Exemplo n.º 3
0
static struct genePos *genePredPosAdvFilter(struct column *col, 
	struct sqlConnection *conn, struct genePos *list)
/* Do advanced filter on position. */
{
char *chrom = advFilterVal(col, "chr");
char *startString = advFilterVal(col, "start");
char *endString = advFilterVal(col, "end");
if (chrom != NULL)
    {
    struct genePos *newList = NULL, *gp, *next;
    for (gp = list; gp != NULL; gp = next)
	{
	next = gp->next;
	if (sameWord(chrom, gp->chrom))
	    {
	    slAddHead(&newList, gp);
	    }
	}
    slReverse(&newList);
    list = newList;
    }
if (startString != NULL)
    {
    int start = atoi(startString)-1;
    struct genePos *newList = NULL, *gp, *next;
    for (gp = list; gp != NULL; gp = next)
	{
	next = gp->next;
	if (gp->end > start)
	    {
	    slAddHead(&newList, gp);
	    }
	}
    slReverse(&newList);
    list = newList;
    }
if (endString != NULL)
    {
    int end = atoi(endString);
    struct genePos *newList = NULL, *gp, *next;
    for (gp = list; gp != NULL; gp = next)
	{
	next = gp->next;
	if (gp->start < end)
	    {
	    slAddHead(&newList, gp);
	    }
	}
    slReverse(&newList);
    list = newList;
    }
return list;
}
Exemplo n.º 4
0
void refineFilterOn(struct column *colList)
/* Consult cart to see if filtering is on/off. */
{
char *val;
struct column *col;

for (col = colList; col != NULL; col = col->next)
    {
    val = advFilterVal(col,"max");
    if (val != NULL)
        col->filterOn = TRUE; //sameString(val, "1");
    val = advFilterVal(col,"wild");
    if (val != NULL)
        col->filterOn = TRUE; //sameString(val, "1");
    }
}
Exemplo n.º 5
0
static struct genePos *xyzAdvFilter(struct column *col,
                                    struct sqlConnection *conn, struct genePos *list)
/* Do advanced filter on xyz type column. */
{
    char *term = advFilterVal(col, "term");
    if (term != NULL)
    {
        /* Construct a hash of all genes that pass filter. */
        struct hash *passHash = newHash(17);
        char query[1000];
        char **row;
        struct sqlResult *sr;
        sqlSafef(query, sizeof(query), "select %s from %s where %s='%s'",
                 col->keyField, col->table, col->valField, term);
        sr = sqlGetResult(conn, query);
        while ((row = sqlNextRow(sr)) != NULL)
            hashAdd(passHash, row[0], NULL);
        sqlFreeResult(&sr);

        /* Remove non-passing genes. */
        list = weedUnlessInHash(list, passHash);
        hashFree(&passHash);
    }
    return list;
}
Exemplo n.º 6
0
static char *keyFileName(struct column *col)
/* Return key file name for this column.  Return
 * NULL if no key file. */
{
char *fileName = advFilterVal(col, "keyFile");
if (fileName == NULL)
    return NULL;
if (!fileExists(fileName))
    {
    cartRemove(cart, advFilterName(col, "keyFile"));
    return NULL;
    }
return fileName;
}
static struct genePos *associationAdvFilter(struct column *col, 
	struct sqlConnection *conn, struct genePos *list)
/* Do advanced filter on position. */
{
char *terms = advFilterVal(col, "terms");
if (terms != NULL)
    {
    boolean orLogic = advFilterOrLogic(col, "logic", TRUE);
    struct slName *termList = stringToSlNames(terms);

    if (anyWild(terms))
	list = wildAssociationFilter(termList, orLogic, col, conn, list);
    else
	list = tameAssociationFilter(termList, orLogic, col, conn, list);

    }
return list;
}
Exemplo n.º 8
0
struct subjInfo *stringAdvFilter(struct column *col,
	struct sqlConnection *conn, struct subjInfo *list)
/* Do advanced filter on string in main table. */
{
char *wild = advFilterVal(col, "wild");
struct hash *keyHash = keyFileHash(col);
if (keyHash != NULL)
    {
    struct subjInfo *newList = NULL, *next, *si;
    for (si = list; si != NULL; si = next)
        {
	char *cell = col->cellVal(col, si, conn);
	next = si->next;
	if (hashLookupUpperCase(keyHash, cell))
	    {
	    slAddHead(&newList, si);
	    }
	freez(&cell);
	}
    slReverse(&newList);
    list = newList;
    }
if (wild != NULL)
    {
    boolean orLogic = advFilterOrLogic(col, "logic", TRUE);
    struct subjInfo *newList = NULL, *next, *si;
    struct slName *wildList = stringToSlNames(wild);
    for (si = list; si != NULL; si = next)
        {
	char *cell = col->cellVal(col, si, conn);
	next = si->next;
	if (wildMatchList(cell, wildList, orLogic))
	    {
	    slAddHead(&newList, si);
	    }
	freez(&cell);
	}
    slReverse(&newList);
    list = newList;
    }
hashFree(&keyHash);
return list;
}
Exemplo n.º 9
0
void lookupAdvFilterControls(struct column *col, struct sqlConnection *conn)
/* Print out controls for advanced filter on lookup column. */
{
char *fileName = advFilterVal(col, "keyFile");
hPrintf("%s search (including * and ? wildcards):", col->shortLabel);
advFilterRemakeTextVar(col, "wild", 18);
hPrintf("<BR>\n");
hPrintf("Include if ");
advFilterAnyAllMenu(col, "logic", TRUE);
hPrintf("words in search term match.<BR>");
if (!columnSetting(col, "noKeys", NULL))
    {
    hPrintf("Limit to items (no wildcards) in list: ");
    advFilterKeyPasteButton(col);
    hPrintf(" ");
    advFilterKeyUploadButton(col);
    hPrintf(" ");
    if (fileName != NULL)
        {
        if (fileExists(fileName))
            {
            int count = countQuotedWordsInFile(fileName);
            advFilterKeyClearButton(col);
            hPrintf("<BR>\n");
            if (count == 1)
                hPrintf("(There is currently 1 item in the list.)");
            else
                hPrintf("(There are currently %d items in the list.)", count);
            }
        else
            {
            cartRemove(cart, advFilterName(col, "keyFile"));
            }
       }
    }
if (col->filterDropDown)
    showListOfFilterValues(col, conn);

}
Exemplo n.º 10
0
static struct genePos *pfamAdvFilter(struct column *col, 
	struct sqlConnection *defaultConn, struct genePos *list)
/* Do advanced filter on for pfam. */
{
char *terms = advFilterVal(col, "terms");
if (terms != NULL)
    {
    struct sqlConnection *conn = sqlConnect(col->protDb);
    char query[256];
    struct sqlResult *sr;
    struct dyString *dy = newDyString(1024);
    char **row;
    boolean orLogic = advFilterOrLogic(col, "logic", TRUE);
    struct slName *term, *termList = stringToSlNames(terms);
    struct hash *passHash = newHash(17);
    struct hash *prevHash = NULL;
    struct genePos *gp;

    /* Build up hash of all genes. */
    struct hash *geneHash = newHash(18);
    for (gp = list; gp != NULL; gp = gp->next)
        hashAdd(geneHash, gp->name, gp);
    for (term = termList; term != NULL; term = term->next)
        {
	/* Build up a list of IDs of descriptions that match term. */
	struct slName *idList = NULL, *id;
	if (isPfamId(term->name))
	    {
	    idList = slNameNew(term->name);
	    }
	else
	    {
	    char *sqlWild = sqlLikeFromWild(term->name);
	    sqlSafef(query, sizeof(query),
	    	"select pfamAC from pfamDesc where description like '%s'",
		sqlWild);
	    sr = sqlGetResult(conn, query);
	    while ((row = sqlNextRow(sr)) != NULL)
		{
	        id = slNameNew(row[0]);
		slAddHead(&idList, id);
		}
	    sqlFreeResult(&sr);
	    }

	if (idList != NULL)
	    {
	    /* Build up query that includes all IDs. */
	    dyStringClear(dy);
	    sqlDyStringPrintf(dy, "select name from %s where ", col->table);
	    sqlDyStringPrintf(dy, "value='%s'", idList->name);
	    for (id = idList->next; id != NULL; id = id->next)
		sqlDyStringPrintf(dy, "or value='%s'", id->name);

	    /* Execute query and put matchers into hash. */
	    sr = sqlGetResult(defaultConn, dy->string);
	    while ((row = sqlNextRow(sr)) != NULL)
		{
		gp = hashFindVal(geneHash, row[0]);
		if (gp != NULL)
		    {
		    char *name = gp->name;
		    if (prevHash == NULL || hashLookup(prevHash, name) != NULL)
			hashStore(passHash, name);
		    }
		}
	    sqlFreeResult(&sr);
	    slFreeList(&idList);
	    }
	if (!orLogic)
	    {
	    hashFree(&prevHash);
	    if (term->next != NULL)
		{
		prevHash = passHash;
		passHash = newHash(17);
		}
	    }
	}
    list = weedUnlessInHash(list, passHash);
    hashFree(&prevHash);
    hashFree(&passHash);
    dyStringFree(&dy);
    sqlDisconnect(&conn);
    }
return list;
}