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);
}
Exemplo n.º 2
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;
}