static void visiGeneMatchDescription(struct visiSearcher *searcher, 
	struct sqlConnection *conn, struct slName *wordList)
/* Fold in matches to description - using full text index. */
{
struct trix *trix = NULL;
struct slName *word;
int wordIx;
if (!fileExists("visiGeneData/visiGene.ix"))
    {
    safef(titleMessage,sizeof(titleMessage),
    	" - visiGene.ix not found, run vgGetText");
    fprintf(stderr,"%s\n",titleMessage);
    return;
    }
trix = trixOpen("visiGeneData/visiGene.ix");

for (word=wordList, wordIx=0; word != NULL; word = word->next, ++wordIx)
    {
    char *s = cloneString(word->name);
    struct trixSearchResult *tsr, *tsrList;
    tolowers(s);
    tsrList = trixSearch(trix, 1, &s, FALSE);
    for (tsr = tsrList; tsr != NULL; tsr = tsr->next)
        visiSearcherAdd(searcher, sqlUnsigned(tsr->itemId), 1.0, wordIx, 1);
    trixSearchResultFreeList(&tsrList);
    freez(&s);
    }

trixClose(&trix);
}
static struct slRef *simpleSearchForTracksstruct(struct trix *trix,char **descWords,int descWordCount)
// Performs the simple search and returns the found tracks.
{
struct slRef *tracks = NULL;

struct trixSearchResult *tsList;
for(tsList = trixSearch(trix, descWordCount, descWords, TRUE); tsList != NULL; tsList = tsList->next)
    {
    struct track *track = (struct track *) hashFindVal(trackHash, tsList->itemId);
    if (track != NULL)  // It is expected that this is NULL (e.g. when the trix references trackDb tracks which have no tables)
        {
        refAdd(&tracks, track);
        }
    }
return tracks;
}
Exemplo n.º 3
0
static struct slRef *simpleSearchForTracksstruct(char *simpleEntry)
// Performs the simple search and returns the found tracks.
{
struct slRef *tracks = NULL;

// Prepare for trix search
if (!isEmpty(simpleEntry))
    {
    int trixWordCount = 0;
    char *tmp = cloneString(simpleEntry);
    char *val = nextWord(&tmp);
    struct slName *el, *trixList = NULL;
    while (val != NULL)
        {
        slNameAddTail(&trixList, val);
        trixWordCount++;
        val = nextWord(&tmp);
        }
    if (trixWordCount > 0)
        {
        // Unfortunately trixSearch can't handle the slName list
        int i;
        char **trixWords = needMem(sizeof(char *) * trixWordCount);
        for (i = 0, el = trixList; el != NULL; i++, el = el->next)
            trixWords[i] = strLower(el->name);

        // Now open the trix file
        char trixFile[HDB_MAX_PATH_STRING];
        getSearchTrixFile(database, trixFile, sizeof(trixFile));
        struct trix *trix = trixOpen(trixFile);

        struct trixSearchResult *tsList = trixSearch(trix, trixWordCount, trixWords, TRUE);
        for ( ; tsList != NULL; tsList = tsList->next)
            {
            struct track *track = (struct track *) hashFindVal(trackHash, tsList->itemId);
            if (track != NULL)  // It is expected that this is NULL
                {               // (e.g. when trix references trackDb tracks which have no tables)
                refAdd(&tracks, track);
                }
            }
        //trixClose(trix);  // don't bother (this is a CGI that is about to end)
        }
    }
return tracks;
}
Exemplo n.º 4
0
static struct aHubMatch *searchPublicHubs(struct dbDb *dbDbList, char *term)
/* Search for term in public hub trix files -- return a list of matches to assembly hubs
 * (i.e. hubs that host an assembly with 2bit etc as opposed to only providing tracks.) */
{
struct aHubMatch *aHubMatchList = NULL;
char *trixFile = cfgOptionEnvDefault("HUBSEARCHTRIXFILE", "hubSearchTrixFile",
                                     hReplaceGbdb("/gbdb/hubs/public.ix"));
if (fileExists(trixFile))
    {
    struct trix *trix = trixOpen(trixFile);
    char termCopy[strlen(term)+1];
    safecpy(termCopy, sizeof(termCopy), term);
    tolowers(termCopy);
    char *words[512];
    int wordCount = chopByWhite(termCopy, words, ArraySize(words));
    struct trixSearchResult *tsrList = trixSearch(trix, wordCount, words, tsmFirstFive);
    aHubMatchList = filterTrixSearchMatches(dbDbList, tsrList);
    trixClose(&trix);
    }
return aHubMatchList;
}
struct visiMatch *visiSearch(struct sqlConnection *conn, char *searchString)
/* visiSearch - return list of images that match searchString sorted
 * by how well they match. This will search most fields in the
 * database. */
{
char *dupe = cloneString(searchString);
struct trix *trix = trixOpen("visiGeneData/visiGene.ix");
struct trixSearchResult *tsrList, *tsr;
struct visiMatch *matchList = NULL, *match;
int wordCount = chopByWhite(dupe, NULL, 0);
char **words;
boolean hasWild;
struct hash *privateHash = makePrivateHash(conn);

tolowers(dupe);
hasWild = (strchr(searchString, '*') != NULL);
if (hasWild)
    stripChar(dupe, '*');
AllocArray(words, wordCount);
chopByWhite(dupe, words, wordCount);
/* if (wordCount != 1 || 
	(matchList = matchGeneName(conn, words[0],privateHash)) == NULL) */
    {
    tsrList = trixSearch(trix, wordCount, words, hasWild);
    for (tsr = tsrList; tsr != NULL; tsr = tsr->next)
	{
	if (!isPrivate(conn, privateHash, tsr->itemId))
	    {
	    AllocVar(match);
	    match->imageId = sqlUnsigned(tsr->itemId);
	    slAddHead(&matchList, match);
	    }
	}
    trixSearchResultFreeList(&tsrList);
    trixClose(&trix);
    slReverse(&matchList);
    }
freeMem(dupe);
return matchList;
}