src/hg/encode/hgEncodeVocab/hgEncodeVocab.c 1.33
1.33 2010/05/28 23:17:01 tdreszer
Improvements needed for passing list of terms: support control terms mixed with Antibodies
Index: src/hg/encode/hgEncodeVocab/hgEncodeVocab.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/encode/hgEncodeVocab/hgEncodeVocab.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -b -B -U 4 -r1.32 -r1.33
--- src/hg/encode/hgEncodeVocab/hgEncodeVocab.c 27 May 2010 19:24:58 -0000 1.32
+++ src/hg/encode/hgEncodeVocab/hgEncodeVocab.c 28 May 2010 23:17:01 -0000 1.33
@@ -94,45 +94,58 @@
/* Compare controlled vocab based on term value */
{
const struct hash *a = *((struct hash **)va);
const struct hash *b = *((struct hash **)vb);
+char *typeA = hashMustFindVal((struct hash *)a, "type");
+char *typeB = hashMustFindVal((struct hash *)b, "type");
char *termA = hashMustFindVal((struct hash *)a, "term");
char *termB = hashMustFindVal((struct hash *)b, "term");
+int ret = strcasecmp(typeA, typeB);
+if(ret != 0)
+ return ret;
return (strcasecmp(termA, termB));
}
void doTypeHeader(char *type)
{
-if (sameString(type,"Antibody"))
+if (sameString(type,"Cell Line"))
+ {
+ printf(" <TH>%s</TH><TH>Tier</TH><TH>Description</TH><TH>Lineage</TH><TH>Karyotype</TH><TH>Sex</TH><TH>Documents</TH><TH>Vendor ID</TH><TH>Term ID</TH>",type);
+ }
+else if (sameString(type,"Antibody"))
{
- puts(" <TH>Term</TH><TH>Target Description</TH><TH>Antibody Description</TH><TH>Vendor ID</TH><TH>Lab</TH><TH>Documents</TH><TH>Lots</TH><TH>Target Link</TH>");
+ printf(" <TH>%s</TH><TH>Target Description</TH><TH>Antibody Description</TH><TH>Vendor ID</TH><TH>Lab</TH><TH>Documents</TH><TH>Lots</TH><TH>Target Link</TH>",type);
}
else if (sameString(type,"ripAntibody"))
{
- puts(" <TH>Term</TH><TH>Antibody Description</TH><TH>Target Description</TH><TH>Vendor ID</TH>");
+ printf(" <TH>%s</TH><TH>Antibody Description</TH><TH>Target Description</TH><TH>Vendor ID</TH>",type);
}
else if (sameString(type,"ripTgtProtein"))
{
- puts(" <TH>Term</TH><TH>Alternative Symbols</TH><TH>Description</TH>");
+ printf(" <TH>%s</TH><TH>Alternative Symbols</TH><TH>Description</TH>",type);
}
-else if (sameString(type,"localization"))
+else
{
- puts(" <TH>Term</TH><TH>Description</TH><TH>GO ID</TH>");
- }
-else if (sameString(type,"Cell Line"))
+ char *caplitalized = cloneString(type);
+ toUpperN(caplitalized,1);
+
+ if (sameString(type,"localization"))
{
- puts(" <TH>Term</TH><TH>Tier</TH><TH>Description</TH><TH>Lineage</TH><TH>Karyotype</TH><TH>Sex</TH><TH>Documents</TH><TH>Vendor ID</TH><TH>Term ID</TH>");
+ printf(" <TH>%s</TH><TH>Description</TH><TH>GO ID</TH>",caplitalized);
+ }
+ else
+ printf(" <TH>%s</TH><TH>Description</TH>",caplitalized);
+
+ freeMem(caplitalized);
}
-else
- puts(" <TH>Term</TH><TH>Description</TH>");
}
-boolean doTypeRow(struct hash *ra, char *type)
+boolean doTypeRow(struct hash *ra)
{
-char *term;
+char *term = (char *)hashMustFindVal(ra, "term");
+char *type = (char *)hashMustFindVal(ra, "type");
char *s, *t, *u;
-term = (char *)hashMustFindVal(ra, "term");
if (sameString(type,"Antibody"))
{
puts("<TR>");
printf(" <TD>%s</TD>\n", term);
@@ -308,9 +321,9 @@
if(s != NULL)
{
puts("<TR>");
printf(" <TD>%s</TD>\n", term);
- printf(" <TD>%s</TD>\n", s);
+ printf(" <TD colspan=40>%s</TD>\n", s); // Control term might be printed with other (e.g. Antibody)
puts("</TR>");
}
else
{
@@ -354,9 +367,9 @@
{
char *thisType = hashMustFindVal(ra, "type");
if(type == NULL)
type = thisType;
- else if(differentWord(type,thisType)) // ignores terms not in hash, but catches this:
+ else if(differentWord(type,thisType) && differentWord("control",thisType)) // ignores terms not in hash, but catches this:
errAbort("Error: Requested %ss of type '%s'. But '%s' has type '%s'\n",
termOrTag,type,requested[ix],thisType);
}
}
@@ -403,10 +416,8 @@
// Get just the terms that match type and requested, then sort them
while ((hEl = hashNext(&hc)) != NULL)
{
ra = (struct hash *)hEl->val;
- if (differentString(hashMustFindVal(ra, "type"), type))
- continue;
// Skip all rows that do not match term or tag if specified
if(requested && -1 == stringArrayIx(hashMustFindVal(ra, termOrTag),requested,requestCount))
continue;
slAddTail(&termList, ra);
@@ -415,9 +426,9 @@
// Print out the terms
while((ra = slPopHead(&termList)) != NULL)
{
- if(doTypeRow(ra, type))
+ if(doTypeRow( ra ))
totalPrinted++;
}
puts("</TABLE><BR>");
if(totalPrinted > 1)