src/hg/encode/hgEncodeVocab/hgEncodeVocab.c 1.29
1.29 2009/12/04 01:31:44 kate
1. Add support for 'organism' option (for mouse) 2. Cleanup (e.g. remove unused ifdef) 3. Add 'tag' option
Index: src/hg/encode/hgEncodeVocab/hgEncodeVocab.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/encode/hgEncodeVocab/hgEncodeVocab.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -b -B -U 4 -r1.28 -r1.29
--- src/hg/encode/hgEncodeVocab/hgEncodeVocab.c 3 Dec 2009 22:11:44 -0000 1.28
+++ src/hg/encode/hgEncodeVocab/hgEncodeVocab.c 4 Dec 2009 01:31:44 -0000 1.29
@@ -16,14 +16,24 @@
* ra=cv.ra : Path to cv.ra file (default cv_file())
* type=TypeName : Type to display
* tier=N : If type="Cell Line" then this is the tier to display
* bgcolor=RRGGBB : Change background color (hex digits)
+ * organism=Human|Mouse : If type="Cell Line", then set 'Mouse' to override default Human
+ * term=a : Display row for a single term
+ * TODO: terms=a,b,c : Display rows for listed terms. Must use with 'type'.
+ * tag=a : Display row for a single term, using tag as identifier
+ * TODO: tags=a,b,c : Display rows for listed terms, using tags as identifiers. Must use with 'type'.
*/
-//#define HANDLE_IMPLICIT_CONTROL
-
static char const rcsid[] = "$Id$";
+//options that apply to all vocab types
+
+static char *termOpt = NULL;
+static char *tagOpt = NULL;
+static char *typeOpt = NULL;
+static char *organismOpt = "Human"; // default, uses naming convention from dbDb table
+
static char *cv_file()
{
/* return default location of cv.ra (can specify as cgi var: ra=cv.ra) */
@@ -66,34 +76,32 @@
else if (sameString(type,"Cell Line"))
{
puts(" <TH>Term</TH><TH>Tier</TH><TH>Description</TH><TH>Lineage</TH><TH>Karyotype</TH><TH>Documents</TH><TH>Vendor ID</TH><TH>Term ID</TH>");
}
-#ifdef HANDLE_IMPLICIT_CONTROL
-else if (sameWord(type,"control") || sameWord(type,"input"))
- {
- puts(" <TH>Term</TH><TH>Description</TH></TR><TR>");
- printf(" <Td>%s</Td><Td>This data represents a control being compared with the other tracks in the set.</Td>\n",type);
- }
-#endif//def HANDLE_IMPLICIT_CONTROL
else
puts(" <TH>Term</TH><TH>Description</TH>");
}
void doTypeRow(struct hash *ra, char *type, int *total)
{
-char *s, *u;
+char *term;
+char *s, *t, *u;
-// Skip all rows that do not match term
-char *term = cgiOptionalString("term");
-if(term)
+// Skip all rows that do not match term or tag if specified
+char *optVal = termOpt;
+char *optType = "term";
+if (tagOpt)
{
- (void)stripChar(term,'\"');
- if(differentWord(term,hashMustFindVal(ra,"term")))
+ optVal = tagOpt;
+ optType = "tag";
+ }
+if (optVal)
+ {
+ (void)stripChar(optVal,'\"');
+ if (differentWord(optVal, hashMustFindVal(ra, optType)))
return;
}
-else
- term = hashMustFindVal(ra,"term");
-
+term = (char *)hashMustFindVal(ra, "term");
if (sameString(type,"Antibody"))
{
++(*total);
puts("<TR>");
@@ -103,10 +111,10 @@
s = hashFindVal(ra, "antibodyDescription");
printf(" <TD>%s</TD>\n", s ? s : " ");
s = hashFindVal(ra, "vendorName");
- char *t = hashFindVal(ra, "vendorId");
- char *u = hashFindVal(ra, "orderUrl");
+ t = hashFindVal(ra, "vendorId");
+ u = hashFindVal(ra, "orderUrl");
printf(" <TD>");
if (u)
printf("<A TARGET=_BLANK HREF=%s>", u);
printf("%s %s", s ? s : " ", t ? t : " ");
@@ -141,10 +149,10 @@
printf(" <TD>%s</TD>\n", s ? s : " ");
s = hashFindVal(ra, "targetDescription");
printf(" <TD>%s</TD>\n", s ? s : " ");
s = hashFindVal(ra, "vendorName");
- char *t = hashFindVal(ra, "vendorId");
- char *u = hashFindVal(ra, "orderUrl");
+ t = hashFindVal(ra, "vendorId");
+ u = hashFindVal(ra, "orderUrl");
printf(" <TD>");
if (u)
printf("<A TARGET=_BLANK HREF=%s>", u);
printf("%s %s", s ? s : " ", t ? t : " ");
@@ -190,8 +198,11 @@
}
else if (sameString(type,"Cell Line"))
{
printf("<!-- Cell Line table: contains links to protocol file and vendor description page -->");
+ s = hashFindVal(ra, "organism");
+ if (s && differentString(s, organismOpt))
+ return;
if (cgiOptionalInt("tier",0))
{
if (hashFindVal(ra,"tier") == NULL)
return;
@@ -273,10 +284,10 @@
}
printf(" </TD>\n");
s = hashFindVal(ra, "vendorName");
- char *t = hashFindVal(ra, "vendorId");
- char *u = hashFindVal(ra, "orderUrl");
+ t = hashFindVal(ra, "vendorId");
+ u = hashFindVal(ra, "orderUrl");
printf(" <TD>");
if (u)
printf("<A TARGET=_BLANK HREF=%s>", u);
printf("%s %s", s ? s : " ", t ? t : " ");
@@ -334,38 +345,35 @@
{
struct hashCookie hc = hashFirst(cvHash);
struct hashEl *hEl;
struct hash *ra;
-char *type = cgiOptionalString("type");
+char *type = typeOpt;
-if(type==NULL) // If not type, but term, then search for first term and use it's type
+if (type == NULL) // If not type, but term (or tag), then search for match and use its type
{
- char *term = cgiOptionalString("term");
- if(term==NULL)
- errAbort("Error: Required 'term' or 'type' argument not found\n");
- (void)stripChar(term,'\"');
-#ifdef HANDLE_IMPLICIT_CONTROL
- if(sameWord(term,"control") || sameWord(term,"input"))
+ char *optType = "tag";
+ char *optVal = tagOpt;
+ if (optVal == NULL)
{
- type = term;
+ optVal = termOpt;
+ if (optVal == NULL)
+ errAbort("Error: Required 'term', 'tag', or 'type' optument not found\n");
+ optType = "term";
}
- else
-#endif//def HANDLE_IMPLICIT_CONTROL
- {
+ (void)stripChar(optVal,'\"');
while ((hEl = hashNext(&hc)) != NULL)
{
ra = (struct hash *)hEl->val;
- char *cmpTerm = hashFindVal(ra, "term");
- if (cmpTerm == NULL || differentWord(cmpTerm, term))
- continue;
- type = hashFindVal(ra, "type");
+ char *val = hashMustFindVal(ra, optType);
+ if (sameWord(val, optVal))
+ {
+ type = hashMustFindVal(ra, "type");
break;
}
- //hc = hashFirst(cvHash);
}
}
-if(type==NULL) // Still not type? abort
- errAbort("Error: Required 'type' or 'term' argument not found\n");
+if (type == NULL) // Still not type? abort
+ errAbort("Error: Required 'type', 'tag', or 'term' argument not found\n");
return normalizeType(type);
}
void doMiddle()
@@ -382,27 +390,21 @@
puts("<TR style=\"background:#D9E4F8\">");
type = findType(cvHash);
doTypeHeader(type);
puts("</TR>");
-
-#ifdef HANDLE_IMPLICIT_CONTROL
-if(differentWord(type,"control") && differentWord(type,"input"))
-#endif//def HANDLE_IMPLICIT_CONTROL
- {
- while ((hEl = hashNext(&hc)) != NULL)
+while ((hEl = hashNext(&hc)) != NULL)
{
ra = (struct hash *)hEl->val;
if (differentString(hashMustFindVal(ra, "type"), type))
continue;
slAddTail(&termList, ra);
}
- slSort(&termList, termCmp);
- while((ra = slPopHead(&termList)) != NULL)
+slSort(&termList, termCmp);
+while((ra = slPopHead(&termList)) != NULL)
{
// TODO: Add check for unknown tags in cv.ra
doTypeRow(ra, type, &total);
}
- }
puts("</TABLE><BR>");
if(total > 1)
printf("Total = %d\n", total);
}
@@ -410,8 +412,12 @@
int main(int argc, char *argv[])
/* Process command line */
{
cgiSpoof(&argc, argv);
+termOpt = cgiOptionalString("term");
+tagOpt = cgiOptionalString("tag");
+typeOpt = cgiOptionalString("type");
+organismOpt = cgiUsualString("organism", organismOpt);
char *bgColor = cgiOptionalString("bgcolor");
if (bgColor)
htmlSetBgColor(strtol(bgColor, 0, 16));
htmlSetStyle(htmlStyleUndecoratedLink);