Example #1
0
void correlateGraphs(struct genoGraph *aGg, struct genoGraph *bGg)
/* Do correlation between two graphs */
{
double r = chromGraphBinCorrelate(aGg->binFileName, bGg->binFileName);

webPrintLinkCell(aGg->shortLabel);
webPrintLinkCell(bGg->shortLabel);
webPrintLinkCellStart();
hPrintf("%f", r);
webPrintLinkCellEnd();
webPrintLinkCellStart();
hPrintf("%f", r*r);
webPrintLinkCellEnd();
}
Example #2
0
void printIndex(struct section *sectionList)
/* Print index to section. */
{
int maxPerRow = 6, itemPos = 0;
int rowIx = 0;
struct section *section;

hPrintf("<BR>\n");
hPrintf("<BR>\n");
webPrintLinkTableStart();
webPrintLabelCell("Page Index");
itemPos += 1;
for (section=sectionList; section != NULL; section = section->next)
    {
    if (++itemPos > maxPerRow)
        {
	hPrintf("</TR><TR>");
	itemPos = 1;
	++rowIx;
	}
    webPrintLinkCellStart();
    hPrintf("<A HREF=\"#%s\" class=\"toc\">%s</A>",
    	section->name, section->shortLabel);
    webPrintLinkCellEnd();
    }
webFinishPartialLinkTable(rowIx, itemPos, maxPerRow);
webPrintLinkTableEnd();
}
static void otherOrgPrintLink(struct otherOrg *otherOrg,  
	char *label,  char *missingLabel, boolean internalLink,
	char *otherId, char *urlFormat)
/* If label and urlFormat exist then print up a link.  Otherwise print n/a. */
{
if (internalLink)
    webPrintLinkCellStart();
else
    webPrintLinkOutCellStart();
if (urlFormat != NULL && label != NULL)
    {
    if (otherId != NULL)
        {
	hPrintf("<A HREF=\"");
	hPrintf(urlFormat, otherId);
	if (internalLink)
	    hPrintf("&db=%s", otherOrg->db);
	hPrintf("\"");
	hPrintf(" TARGET=_blank");
	hPrintf(" class=\"toc\">");
	hPrintf("%s", label);
	hPrintf("</A>");
	}
    else
        {
	hPrintf("%s", missingLabel);
	}
    }
else
    hPrintf("&nbsp;");
webPrintLinkCellEnd();
}
Example #4
0
void webPrintLinkCell(char *link)
/* Print link cell in our colors, if links is null, print empty cell */
{
webPrintLinkCellStart();
if (link != NULL)
    puts(link);
webPrintLinkCellEnd();
}
Example #5
0
static void showTableDataRows(struct fieldedTable *table, int pageSize, int maxLenField,
    struct hash *tagOutputWrappers, void *wrapperContext)
/* Render data rows into HTML */
{
int count = 0;
struct fieldedRow *row;
boolean isNum[table->fieldCount];
int i;
for (i=0; i<table->fieldCount; ++i)
    isNum[i] = fieldedTableColumnIsNumeric(table, i);

for (row = table->rowList; row != NULL; row = row->next)
    {
    if (++count > pageSize)
         break;
    printf("<TR>\n");
    int fieldIx = 0;
    for (fieldIx=0; fieldIx<table->fieldCount; ++fieldIx)
	{
	char shortVal[maxLenField+1];
	char *longVal = emptyForNull(row->row[fieldIx]);
	char *val = longVal;
	int valLen = strlen(val);
	if (maxLenField > 0 && maxLenField < valLen)
	    {
	    if (valLen > maxLenField)
		{
		memcpy(shortVal, val, maxLenField-3);
		shortVal[maxLenField-3] = 0;
		strcat(shortVal, "...");
		val = shortVal;
		}
	    }
	if (isNum[fieldIx])
	    webPrintLinkCellRightStart();
	else
	    webPrintLinkCellStart();
	boolean printed = FALSE;
	if (tagOutputWrappers != NULL && !isEmpty(val))
	    {
	    char *field = table->fields[fieldIx];
	    webTableOutputWrapperType *printer = hashFindVal(tagOutputWrappers, field);
	    if (printer != NULL)
		{
		printer(table, row, field, longVal, val, wrapperContext);
		printed = TRUE;
		}
	    
	    }
	if (!printed)
	    printf("%s", val);
	webPrintLinkCellEnd();
	}
    printf("</TR>\n");
    }
}
Example #6
0
static void prGenbankLink(struct cloneInfo *ci)
/* create link to Genbank database */
{
webPrintLinkTableNewRow();
webPrintLinkCellStart();
printf("<a href=\"");
printEntrezNucleotideUrl(stdout, ci->acc);
printf("\" TARGET=_blank>Genbank %s</a>", ci->acc);
webPrintLinkCellEnd();
}
Example #7
0
static void prImageLink(struct cloneInfo *ci)
/* create link to IMAGE database */
{
webPrintLinkTableNewRow();
webPrintLinkCellStart();
printf("<a href=\"");
printImageUrl(ci->imageId);
printf("\" TARGET=_blank>IMAGE clone %d</a>", ci->imageId);
webPrintLinkCellEnd();
}
Example #8
0
static void prOrderLink(char *name, struct cloneInfo *ci)
/* create link to NCBI clone order CGI */
{
webPrintLinkTableNewRow();
webPrintLinkCellStart();
printf("<a href=\"");
printOrderUrl(ci->gi);
printf("\" TARGET=_blank>Order %s clone</a>", name);
webPrintLinkCellEnd();
}
Example #9
0
static void printParLink(struct bed *par)
/* print one par link back to the browser */
{
webPrintLinkCellStart();
printf("<A HREF=\"%s?db=%s&position=%s:%d-%d\">%s:%d-%d</A>",
       hgTracksName(), database, 
       par->chrom, par->chromStart, par->chromEnd,
       par->chrom, par->chromStart+1, par->chromEnd);
webPrintLinkCellEnd();
}
Example #10
0
static void prRefSeqLinks(struct cloneInfo *ci)
/* print link to RefSeq */
{
webPrintLinkTableNewRow();
webPrintLinkCellStart();
printf("<a href=\"");
printEntrezNucleotideUrl(stdout, ci->refSeqAccv);
printf("\" TARGET=_blank>RefSeq %s</a>", ci->refSeqAccv);
webPrintLinkCellEnd();
}
Example #11
0
static void prSeqLinks(struct sqlConnection *conn, struct cloneInfo *ci)
/* print table of sequence links */
{
webNewSection("Sequences");
webPrintLinkTableStart();

webPrintLinkCellStart();
hgcAnchorSomewhere("htcDisplayMrna", ci->acc, ci->pslTbl, seqName);
printf("mRNA</a>");
webPrintLinkCellEnd();

webPrintLinkCellStart();
hgcAnchorSomewhere("htcTranslatedMRna", ci->acc, ci->pslTbl, seqName);
printf("Protein</A><br>");
webPrintLinkCellEnd();

webPrintLinkCellStart();
hgcAnchorSomewhere("htcGeneInGenome", ci->acc, ci->gpTbl, seqName);
printf("Genomic</A>");
webPrintLinkCellEnd();

webPrintLinkTableNewRow();

webPrintLinkCellStart();
hgcAnchorSomewhere("htcDisplayMrna", ci->acc, ci->gpTbl, seqName);
printf("Reference genome mRNA</A>");
webPrintLinkCellEnd();

#if BROKEN
// FIXME: doesn't work when genePred table is not the track; not that important
webPrintLinkCellStart();
hgcAnchorSomewhereTbl("htcTranslatedPredMRna", ci->acc, ci->pslTbl, seqName, ci->gpTbl);
printf("Reference genome protein</A>");
webPrintLinkCellEnd();
webFinishPartialLinkTable(1, 2, 3);
#else
webFinishPartialLinkTable(1, 1, 3);
#endif

webPrintLinkTableEnd();
}
Example #12
0
static void prMgcCloneLinks(struct sqlConnection *conn, struct mgcDb *mgcDb, struct cloneInfo *ci)
/* print table of clone links */
{
webPrintLinkTableStart();
webPrintLabelCell("Links");
if (ci->gi > 0)
    prOrderLink(mgcDb->name, ci);

// link to MGC database
webPrintLinkTableNewRow();
webPrintLinkCellStart();
printf("<a href=\"");
printMgcUrl(ci->imageId);
printf("\" TARGET=_blank>%s clone database</a>", mgcDb->name);
webPrintLinkCellEnd();

prImageLink(ci);
prGenbankLink(ci);
if (ci->refSeqAccv != NULL)
    prRefSeqLinks(ci);
if (sqlTableExists(conn, "ccdsGene"))
    prCcdsLinks(conn, ci);
if (sqlTableExists(conn, "knownGene"))
    prUcscGenesLinks(conn, ci);

// Brent lab validation database
if (isInMBLabValidDb(ci->acc))
    {
    webPrintLinkTableNewRow();
    webPrintLinkCellStart();
    printf("<a href=\"");
    printMBLabValidDbUrl(ci->acc);
    printf("\" TARGET=_blank>Brent Lab Clone Validation</a>");
    webPrintLinkCellEnd();
    }
webPrintLinkTableEnd();
}
Example #13
0
static void prAlign(struct sqlConnection *conn, char *pslTbl, struct psl *psl)
/* print an alignment */
{
// genomic location
webPrintLinkCellStart();
printf("<A HREF=\"%s&db=%s&position=%s%%3A%d-%d\">%s:%d-%d</A>",
       hgTracksPathAndSettings(), database, psl->tName, psl->tStart+1, psl->tEnd,
       psl->tName, psl->tStart+1, psl->tEnd);
webPrintLinkCellEnd();

// genomic span
webPrintLinkCellRightStart();
printf("%d", psl->tEnd-psl->tStart);
webPrintLinkCellEnd();

// strand
webPrintLinkCell(psl->strand);

// mRNA location, linked to aligment viewer
webPrintLinkCellStart();
char other[128];
safef(other, sizeof(other), "%d&aliTable=%s", psl->tStart, pslTbl);
hgcAnchorSomewhere("htcCdnaAli", psl->qName, other, psl->tName);
printf("%s:%d-%d</A>", psl->qName, psl->qStart+1, psl->qEnd);
webPrintLinkCellEnd();

// identity
webPrintLinkCellRightStart();
printf("%.2f%%", 100.0 * pslIdent(psl));
webPrintLinkCellEnd();

// fraction aligned
webPrintLinkCellRightStart();
int aligned = psl->match + psl->misMatch + psl->repMatch;
printf("%.2f%%", 100.0*aligned/((float)psl->qSize));
webPrintLinkCellEnd();
}
Example #14
0
static void prRefSeqSim(struct cloneInfo *ci, struct geneSim *gs)
/* print similarity information for a given RefSeq */
{
webPrintLinkTableNewRow();
// RefSeq acc and link
webPrintLinkCellStart();
printf("<a href=\"");
printEntrezNucleotideUrl(stdout, gs->gene->name);
printf("\" TARGET=_blank>%s</a>", gs->gene->name);
webPrintLinkCellEnd();

// link to browser
webPrintLinkCellStart();
printf("<A HREF=\"%s&db=%s&position=%s%%3A%d-%d\" target=_blank>%s:%d-%d</A>",
       hgTracksPathAndSettings(), database,
       gs->gene->chrom, gs->gene->txStart+1, gs->gene->txEnd,
       gs->gene->chrom, gs->gene->txStart+1, gs->gene->txEnd);
webPrintLinkCellEnd();

// similarity
webPrintLinkCellRightStart();
printf("%0.2f%%", 100.0*gs->sim);
webPrintLinkCellEnd();
}
Example #15
0
static void prUcscGenesLinks(struct sqlConnection *conn, struct cloneInfo *ci)
/* generate links to UCSC or known genes */
{
struct geneSimilarities *ucscGenes
    = geneSimilaritiesBuildAt(conn, TRUE, ci->acc, seqName, ci->start,
                              ci->gpTbl, "knownGene");
if (ucscGenes->genes != NULL)
    {
    /* just use cloest one */
    struct genePred *gene = ucscGenes->genes->gene;
    webPrintLinkTableNewRow();
    webPrintLinkCellStart();
    printf("<A href=\"../cgi-bin/hgGene?%s&db=%s&hgg_gene=%s&hgg_chrom=%s&hgg_start=%d&hgg_end=%d&hgg_type=knownGene\">UCSC Gene %s</A>",
           cartSidUrlString(cart), database, gene->name, seqName, gene->txStart, gene->txEnd, gene->name);
    webPrintLinkCellEnd();
    }
geneSimilaritiesFree(&ucscGenes);
}
Example #16
0
static void printMetadataForTable(char *table)
/* If table exists, _and_ tdb associated with it exists, print out
 * a metadata link that expands on click.  Otherwise print "unavailable" */
{
webPrintLinkCellStart();
struct trackDb *tdb = hashFindVal(trackHash, table);
if (tdb == NULL)
    printf("%s info n/a", table);
else if (!compositeMetadataToggle(database, tdb, "metadata", TRUE, FALSE))
    {
    /* no metadata, but there is a track table to point TB at */
    struct trackDb *parent = trackDbTopLevelSelfOrParent(tdb);
    printf("<A target='_blank' title='browse table' "
                "href='%s?db=%s&hgta_table=%s&hgta_group=%s&hgta_track=%s'>%s</A>",
                    hgTablesName(), database, table, parent->grp, parent->track, table);
    }
webPrintLinkCellEnd();
}
static void linksPrint(struct section *section, struct sqlConnection *conn,
	char *geneId)
/* Print the links section. */
{
int maxPerRow = 6, itemPos = 0;
int rowIx = 0;
struct link *link, *linkList = section->items;

webPrintLinkTableStart();
printGenomicSeqLink(conn, geneId, curGeneChrom, curGeneStart, curGeneEnd);
printMrnaSeqLink(conn,geneId);
printProteinSeqLink(conn,geneId);
hPrintf("</TR>\n<TR>");
++rowIx;

for (link = linkList; link != NULL; link = link->next)
    {
    char *url = linkGetUrl(link, conn, geneId);
    if (url != NULL)
	{
	boolean fakeOut = link->useHgsid &&
		differentWord(link->name,"wikiTrack");
	char *target = (fakeOut ? "" : " TARGET=_blank");
	if (++itemPos > maxPerRow)
	    {
	    hPrintf("</TR>\n<TR>");
	    itemPos = 1;
	    ++rowIx;
	    }
	if (fakeOut)
	    webPrintLinkCellStart();
	else
	    webPrintLinkOutCellStart();
	hPrintf("<A HREF=\"%s\"%s class=\"toc\">", url, target);
	hPrintf("%s", link->shortLabel);
	hPrintf("</A>");
	webPrintLinkCellEnd();
	freez(&url);
	}
    }
webFinishPartialLinkOutTable(rowIx, itemPos, maxPerRow);
webPrintLinkTableEnd();
}
Example #18
0
static void prCcdsLinks(struct sqlConnection *conn, struct cloneInfo *ci)
/* generate links to CCDS gene */
{
struct geneSimilarities *ccdsGenes
    = geneSimilaritiesBuildAt(conn, TRUE, ci->acc, seqName, ci->start,
                              ci->gpTbl, "ccdsGene");
if (ccdsGenes->genes != NULL)
    {
    /* just use cloest one */
    char *ccdsId = ccdsGenes->genes->gene->name;
    webPrintLinkTableNewRow();
    webPrintLinkCellStart();
    printf("<A href=\"");
    printCcdsUrl(conn, ccdsId);
    printf("\">%s</A>", ccdsId);
    webPrintLinkCellEnd();
    }
geneSimilaritiesFree(&ccdsGenes);
}
void printProteinSeqLink(struct sqlConnection *conn, char *geneId)
/* Print out link to fetch protein. */
{
char *table = genomeSetting("knownGenePep");
char query[256];
char title[128];
safef(query, sizeof(query), 
	"select length(seq) from %s where name='%s'" , table,  geneId);
int protSize = sqlQuickNum(conn, query);
if (protSize > 0)
    {
    safef(title, sizeof(title), "Protein (%d aa)", protSize);
    printSeqLink(conn, geneId, "knownGenePep", hggDoGetProteinSeq,
	    title, 1);
    }
else
    {
    webPrintLinkCellStart();
    hPrintf("No protein");
    webPrintLinkCellEnd();
    }
}
void otherOrgPepLink(struct otherOrg *otherOrg, char *command, char *label,
	char *id, struct sqlConnection *conn)
/* Print link that will invoke self to work on other organism peptide. */
{
boolean gotIt = FALSE;
webPrintLinkCellStart();
if (id != NULL)
    {
    if (otherOrg->db != NULL && otherOrg->pepTable != NULL)
	{
	char dbTable[128];
	safef(dbTable, sizeof(dbTable), "%s.%s", otherOrg->db, otherOrg->pepTable);
	if (sqlTableExists(conn, dbTable))
	    {
	    struct sqlResult *sr;
	    char **row;
	    char query[256];
	    safef(query, sizeof(query), "select seq from %s where name = '%s'",
	    	dbTable, id);
	    sr = sqlGetResult(conn, query);
	    if ((row = sqlNextRow(sr)) != NULL)
	        {
		gotIt = TRUE;
		hPrintf("<A HREF=\"%s?%s&%s=%s&%s=%s&%s=%s\" class=\"toc\">",
		    geneCgi, cartSidUrlString(cart), 
		    command, "on",
		    hggOtherPepTable, dbTable,
		    hggOtherId, id);
		hPrintf("%s", label);
		hPrintf("</A>");
		}
	    sqlFreeResult(&sr);
	    }
	}
    }
if (!gotIt)
    hPrintf("&nbsp;");
webPrintLinkCellEnd();
}
Example #21
0
static void showTableFilterControlRow(struct fieldedTable *table, struct cart *cart, 
    char *varPrefix, int maxLenField, struct hash *suggestHash)
/* Assuming we are in table already drow control row.
 * The suggestHash is keyed by field name.  If something is there we'll assume
 * it's value is slName list of suggestion values */
{
/* Include javascript and style we need  */
webIncludeResourceFile("jquery-ui.css");
jsIncludeFile("jquery.js", NULL);
jsIncludeFile("jquery.plugins.js", NULL);
jsIncludeFile("jquery-ui.js", NULL);
jsIncludeFile("jquery.watermark.js", NULL);

int i;
printf("<TR>");
for (i=0; i<table->fieldCount; ++i)
    {
    char *field = table->fields[i];
    char varName[256];
    safef(varName, sizeof(varName), "%s_f_%s", varPrefix, field);
    webPrintLinkCellStart();

#ifdef MAKES_TOO_WIDE
    /* Print out input control.  As you can see from all the commented out bits
     * this part has been a challenge.  We'd like to make the input cell fit the
     * table size, but if we do it with style it makes whole table wider. */
    char *oldVal = cartUsualString(cart, varName, "");
    printf("<input type=\"text\" name=\"%s\" style=\"display:table-cell; width=100%%\""
	   " value=\"%s\">", varName, oldVal);
#endif /* MAKES_TOO_WIDE */

    /* Approximate size of input control in characters */
    int size = fieldedTableMaxColChars(table, i);
    if (size > maxLenField)
	size = maxLenField;

#ifdef ACTUALLY_WORKS
    /* This way does work last I checked and is just a line of code.
     * Getting an id= property on the input tag though isn't possible this way. */
    cartMakeTextVar(cart, varName, "", size + 1);
#endif

    /* Print input control getting previous value from cart.  Set an id=
     * so auto-suggest can find this control. */
    char *oldVal = cartUsualString(cart, varName, "");
    printf("<INPUT TYPE=TEXT NAME=\"%s\" id=\"%s\" SIZE=%d VALUE=\"%s\">\n",
	varName, varName, size+1, oldVal);

    /* Write out javascript to initialize autosuggest on control */
    printWatermark(varName, " filter ");
    if (suggestHash != NULL)
        {
	struct slName *suggestList = hashFindVal(suggestHash, field);
	if (suggestList != NULL)
	    {
	    printSuggestScript(varName, suggestList);
	    }
	}
    webPrintLinkCellEnd();
    }


printf("</TR>");
}
static void rnaStructurePrint(struct section *section, 
	struct sqlConnection *conn, char *geneId)
/* Print out rnaStructure table. */
{
static boolean firstTime = TRUE;
static char *names[2] = 
	{"5' UTR", "3' UTR"};
static char *tables[2] = {"foldUtr5", "foldUtr3"};
int side;

if (firstTime)
    {
    rnaTrashDirsInit(tables, ArraySize(tables));
    firstTime = FALSE;
    }

webPrintLinkTableStart();
webPrintLabelCell("Region");
webPrintLabelCell("Fold Energy");
webPrintLabelCell("Bases");
webPrintLabelCell("Energy/Base");
webPrintWideCenteredLabelCell("Display As", 3);
for (side = 0; side < ArraySize(names); ++side)
    {
    char *table = tables[side];
    struct sqlResult *sr;
    char query[256], **row;
    safef(query, sizeof(query), "select * from %s where name = '%s'",
    	table, geneId);
    sr = sqlGetResult(conn, query);
    if ((row = sqlNextRow(sr)) != NULL)
	{
	struct rnaFold fold;
	int bases;
	char psName[128];

	/* Load fold and save it as postScript. */
	rnaFoldStaticLoad(row, &fold);
	safef(psName, sizeof(psName), "../trash/%s/%s_%s.ps", table, table, geneId);
	if (!fileExists(psName))
	    {
	    FILE *f;
	    f = popen("../cgi-bin/RNAplot", "w");
	    if (f != NULL)
	        {
		fprintf(f, ">%s\n", psName);	/* This tells where to put file. */
		fprintf(f, "%s\n%s\n", fold.seq, fold.fold);
		pclose(f);
		}
	    }

	/* Print row of table, starting with energy terms . */
	hPrintf("</TR><TR>");
	bases = strlen(fold.seq);
	webPrintLinkCell(names[side]);
	webPrintLinkCellStart();
	hPrintf("%1.2f", fold.energy);
	webPrintLinkCellEnd();
	webPrintLinkCellStart();
	hPrintf("%d", bases);
	webPrintLinkCellEnd();
	webPrintLinkCellStart();
	hPrintf("%1.3f", fold.energy/bases);
	webPrintLinkCellEnd();

	/* Print link to png image. */
	webPrintLinkCellStart();
	hPrintf("<A HREF=\"%s?%s&%s=%s&%s=%s&%s=%s\" class=\"toc\" TARGET=_blank>",
	    geneCgi, cartSidUrlString(cart), 
	    hggMrnaFoldRegion, table,
	    hggMrnaFoldPs, psName,
	    hggDoRnaFoldDisplay, "picture");
	hPrintf(" Picture ");
	hPrintf("</A>");
	webPrintLinkCellEnd();

	/* Print link to PostScript. */
	webPrintLinkCellStart();
	hPrintf("<A HREF=\"%s\" class=\"toc\">", psName);
	hPrintf(" PostScript ");
	hPrintf("</A>");
	webPrintLinkCellEnd();

	/* Print link to text. */
	webPrintLinkCellStart();
	hPrintf("<A HREF=\"%s?%s&%s=%s&%s=%s\" class=\"toc\" TARGET=_blank>",
	    geneCgi, cartSidUrlString(cart), 
	    hggMrnaFoldRegion, table,
	    hggDoRnaFoldDisplay, "text");
	hPrintf(" Text ");
	hPrintf("</A>");
	webPrintLinkCellEnd();
	}
    sqlFreeResult(&sr);
    }
webPrintLinkTableEnd();
hPrintf("<BR>The RNAfold program from the ");
hPrintf("<A HREF=\"http://www.tbi.univie.ac.at/~ivo/RNA/\" TARGET=_blank>");
hPrintf("Vienna RNA Package</A> is used to perform the ");
hPrintf("secondary structure predictions and folding calculations. ");
hPrintf("The estimated folding energy is in kcal/mol.  The more ");
hPrintf("negative the energy, the more secondary structure the RNA ");
hPrintf("is likely to have.");
}
Example #23
0
static void printFactorSourceTableHits(struct factorSource *cluster, struct sqlConnection *conn,
	char *sourceTable, char *inputTrackTable, 
	struct slName *fieldList, boolean invert, char *vocab)
/* Put out a lines in an html table that shows assayed sources that have hits in this
 * cluster, or if invert is set, that have misses. */
{
char *vocabFile = NULL;
if (vocab)
    {
    vocabFile = cloneFirstWord(vocab);
    }

/* Make the monster SQL query to get all assays*/
struct dyString *query = dyStringNew(0);
sqlDyStringPrintf(query, "select %s.id,%s.name,%s.tableName", sourceTable, sourceTable, 
	inputTrackTable);
struct slName *field;
for (field = fieldList; field != NULL; field = field->next)
    sqlDyStringPrintf(query, ",%s.%s", inputTrackTable, field->name);
sqlDyStringPrintf(query, " from %s,%s ", inputTrackTable, sourceTable);
sqlDyStringPrintf(query, " where %s.source = %s.description", inputTrackTable, sourceTable);
sqlDyStringPrintf(query, " and factor='%s' order by %s.source", cluster->name, inputTrackTable);

boolean encodeStanford = FALSE;
if (startsWith("encode3", sourceTable) || startsWith("encode4", sourceTable))
    encodeStanford = TRUE;

int displayNo = 0;
int fieldCount = slCount(fieldList);
struct sqlResult *sr = sqlGetResult(conn, query->string);
char **row;
while ((row = sqlNextRow(sr)) != NULL)
    {
    int sourceId = sqlUnsigned(row[0]);
    boolean hit = FALSE;
    int i;
    double signal = 0.0;
    for (i=0; i<cluster->expCount; i++)
        {
        if (cluster->expNums[i] == sourceId)
            {
            hit = TRUE;
            signal = cluster->expScores[i];
            break;
            }
        }
    if (hit ^ invert)
        {
	printf("</TR><TR>\n");
	webPrintIntCell(++displayNo);
	if (!invert)
	    webPrintDoubleCell(signal);
	webPrintLinkCell(row[1]);
	int i = 0;
        // find position of CV metadata in field list
        int offset = 3;
        struct slName *field = fieldList;
	for (i=0; i<fieldCount && field != NULL; ++i, field = field->next)
	    {
	    char *fieldVal = row[i+offset];
	    if (vocab)
	        {
                char *link = cloneString(factorSourceVocabLink(vocabFile, field->name, fieldVal));
		webPrintLinkCell(link);
		}
	    else
		webPrintLinkCell(fieldVal);
	    }
        char *table = row[2];
        if (encodeStanford)
            {
            char *file = stringIn("ENCFF", table);
            if (!file)
                webPrintLinkCell(table);
            else
                {
                webPrintLinkCellStart();
                printf("<A target='_blank'"
                        "href='https://www.encodeproject.org/files/%s'>%s</A>", file, file);
                webPrintLinkCellEnd();
               } 
            }
        else
            printMetadataForTable(table);
	}
    }
sqlFreeResult(&sr);
freez(&vocabFile);
dyStringFree(&query);
}