ad2e6ce4b7e06a2d9e93901474729864f8f23a24 fanhsu Thu Jun 2 09:05:00 2011 -0700 Updated OMIM entry selection/filtering logic functions and color scheme. diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c index 685fc7c..33849c7 100644 --- src/hg/hgTracks/simpleTracks.c +++ src/hg/hgTracks/simpleTracks.c @@ -10746,101 +10746,149 @@ if (isNotEmpty(ret)) dyStringAppend(dy, ret); safef(query,sizeof(query), "select distinct description from omimPhenotype, omimGene2 where name='%s' and name=cast(omimId as char) order by description", name); char *disorders = collapseRowsFromQuery(query, "; ", 20); if (isNotEmpty(disorders)) { dyStringAppend(dy, "; disorder(s): "); dyStringAppend(dy, disorders); } hFreeConn(&conn); return(dy->string); } -boolean hasOmimPhenotypeClass(char *omimId, int targetClass) -/* Look up phenotypeClass for omimId, for filtering items. Don't free result! */ +boolean isOmimOtherClass(char *omimId) +/* check if this omimId belongs to the "Others" phenotype class */ + +/* NOTE: The definition of Others class is kind of tricky. + + The Other class is defined as: + + 2. does not have class 1 or 2 or 3, or 4; some may have class '-1'. + 3. for an entry of omimId that the omimPhenotype table does not even have a row with omimId +*/ { boolean result; char answer[255]; struct sqlConnection *conn = hAllocConn(database); char query[256]; safef(query,sizeof(query), + "select phenotypeClass from omimPhenotype where omimId =%s and (phenotypeClass=1 or phenotypeClass=2 or phenotypeClass=3 or phenotypeClass=4)", omimId); +char *ret = sqlQuickQuery(conn, query, answer, sizeof(answer)); + +if (ret == NULL) + { + result = TRUE; + } +else + { + result = FALSE; + } +hFreeConn(&conn); +return(result); +} + +int hasOmimPhenotypeClass(char *omimId, int targetClass) +/* Look up phenotypeClass for omimId, for filtering items. Don't free result! */ +{ +int result; +char answer[255]; +struct sqlConnection *conn = hAllocConn(database); +char query[256]; +safef(query,sizeof(query), "select phenotypeClass from omimPhenotype where omimId =%s and phenotypeClass=%d", omimId, targetClass); char *ret = sqlQuickQuery(conn, query, answer, sizeof(answer)); + if (ret == NULL) - result = FALSE; + { + if (targetClass == -1) + { + result = -1; + } else - result = TRUE; + { + result = 0; + } + } +else + result = targetClass; hFreeConn(&conn); return(result); } boolean doThisOmimEntry(struct track *tg, char *omimId) /* check if the specific class of this OMIM entry is selected by the user */ { boolean doIt; char labelName[255]; boolean doClass1 = FALSE; boolean doClass2 = FALSE; boolean doClass3 = FALSE; boolean doClass4 = FALSE; boolean doOthers = FALSE; struct hashEl *omimLocationLabels; struct hashEl *label; safef(labelName, sizeof(labelName), "%s.label", tg->table); omimLocationLabels = cartFindPrefix(cart, labelName); + /* if user has not made selection(s) from the filter, enable every item */ if (omimLocationLabels == NULL) return(TRUE); /* check which classes have been selected */ for (label = omimLocationLabels; label != NULL; label = label->next) { if (endsWith(label->name, "class1") && differentString(label->val, "0")) { doClass1 = TRUE; } if (endsWith(label->name, "class2") && differentString(label->val, "0")) { doClass2 = TRUE; } if (endsWith(label->name, "class3") && differentString(label->val, "0")) { doClass3 = TRUE; } if (endsWith(label->name, "class4") && differentString(label->val, "0")) { doClass4 = TRUE; } if (endsWith(label->name, "others") && differentString(label->val, "0")) { doOthers = TRUE; } } doIt = FALSE; -doIt = doIt || (doClass1 && hasOmimPhenotypeClass(omimId, 1)); -doIt = doIt || (doClass2 && hasOmimPhenotypeClass(omimId, 2)); -doIt = doIt || (doClass3 && hasOmimPhenotypeClass(omimId, 3)); -doIt = doIt || (doClass4 && hasOmimPhenotypeClass(omimId, 4)); -doIt = doIt || (doOthers && hasOmimPhenotypeClass(omimId, 0)); +/* process regular class 1-4 first */ +doIt = doIt || (doClass1 && (hasOmimPhenotypeClass(omimId, 1) == 1)); +doIt = doIt || (doClass2 && (hasOmimPhenotypeClass(omimId, 2) == 2)); +doIt = doIt || (doClass3 && (hasOmimPhenotypeClass(omimId, 3) == 3)); +doIt = doIt || (doClass4 && (hasOmimPhenotypeClass(omimId, 4) == 4)); + +// if this is a regular (1-4) class and the result is to do it, return TRUE now +if (doIt) return(doIt); + +/* process the tricky "Other" class here */ +doIt = doOthers && isOmimOtherClass(omimId); return(doIt); } static void omimFilter(struct track *tg) /* Filter the already-loaded items in the omimGene2 or the omimLocation track */ { struct bed *bed, *nextBed = NULL, *list = NULL; for (bed = tg->items; bed != NULL; bed = nextBed) { nextBed = bed->next; /* check if user has selected the specific class for this OMIM entry */ if (doThisOmimEntry(tg, bed->name)) slAddHead(&list, bed); } @@ -10887,38 +10935,45 @@ lighter.r = (6*normal->r + 4*255) / 10; lighter.g = (6*normal->g + 4*255) / 10; lighter.b = (6*normal->b + 4*255) / 10; lightest.r = (1*normal->r + 2*255) / 3; lightest.g = (1*normal->g + 2*255) / 3; lightest.b = (1*normal->b + 2*255) / 3; struct sqlConnection *conn = hAllocConn(database); class1Clr = hvGfxFindColorIx(hvg, lightest.r, lightest.g, lightest.b); class2Clr = hvGfxFindColorIx(hvg, lighter.r, lighter.g, lighter.b); class3Clr = hvGfxFindColorIx(hvg, normal->r, normal->g, normal->b); -//class4Clr = hvGfxFindColorIx(hvg, 153,0, 204); // purple class4Clr = hvGfxFindColorIx(hvg, 56, 11, 97); -//classOtherClr = hvGfxFindColorIx(hvg, 200, 200, 200); // light gray -classOtherClr = MG_RED; -//hvGfxFindColorIx(hvg, 200, 200, 200); // light gray +class4Clr = hvGfxFindColorIx(hvg, 105,50,155); +classOtherClr = hvGfxFindColorIx(hvg, 190, 190, 190); // light gray + +/* last try of Brooke's suggestion, the class 1 and 2 are too bright */ +/* +class1Clr = hvGfxFindColorIx(hvg, 125,225,115); +class2Clr = hvGfxFindColorIx(hvg, 35,155,10); +class3Clr = hvGfxFindColorIx(hvg, 10,60,0); +class4Clr = hvGfxFindColorIx(hvg, 105,50,155); +classOtherClr = hvGfxFindColorIx(hvg, 190, 190, 190); // light gray +*/ safef(query, sizeof(query), - "select omimId, phenotypeClass from omimPhenotype where omimId=%s", el->name); + "select omimId, phenotypeClass from omimPhenotype where omimId=%s order by phenotypeClass desc", el->name); sr = sqlMustGetResult(conn, query); row = sqlNextRow(sr); hFreeConn(&conn); if (row == NULL) { // set to gray if this entry does not have any disorder info sqlFreeResult(&sr); return classOtherClr; } else { omimId = row[0]; phenClass = row[1]; @@ -11056,34 +11111,42 @@ Light Gray: for Others */ lighter.r = (6*normal->r + 4*255) / 10; lighter.g = (6*normal->g + 4*255) / 10; lighter.b = (6*normal->b + 4*255) / 10; lightest.r = (1*normal->r + 2*255) / 3; lightest.g = (1*normal->g + 2*255) / 3; lightest.b = (1*normal->b + 2*255) / 3; class1Clr = hvGfxFindColorIx(hvg, lightest.r, lightest.g, lightest.b); class2Clr = hvGfxFindColorIx(hvg, lighter.r, lighter.g, lighter.b); class3Clr = hvGfxFindColorIx(hvg, normal->r, normal->g, normal->b); -//class4Clr = hvGfxFindColorIx(hvg, 153,0, 204); // purple class4Clr = hvGfxFindColorIx(hvg, 56, 11, 97); -//class4Clr = hvGfxFindColorIx(hvg, 97, 11, 94); -classOtherClr = hvGfxFindColorIx(hvg, 200, 200, 200); // light gray +class4Clr = hvGfxFindColorIx(hvg, 105,50,155); +classOtherClr = hvGfxFindColorIx(hvg, 190, 190, 190); // light gray + +/* last try of Brooke's suggestion, the class 1 and 2 are too bright */ +/* +class1Clr = hvGfxFindColorIx(hvg, 125,225,115); +class2Clr = hvGfxFindColorIx(hvg, 35,155,10); +class3Clr = hvGfxFindColorIx(hvg, 10,60,0); +class4Clr = hvGfxFindColorIx(hvg, 105,50,155); +classOtherClr = hvGfxFindColorIx(hvg, 190, 190, 190); // light gray +*/ struct sqlConnection *conn = hAllocConn(database); safef(query, sizeof(query), "select omimId, phenotypeClass from omimPhenotype where omimId=%s", el->name); sr = sqlMustGetResult(conn, query); row = sqlNextRow(sr); hFreeConn(&conn); if (row == NULL) { // set to gray if this entry does not have any disorder info sqlFreeResult(&sr); return classOtherClr;