src/hg/instinct/bioInt2/bioIntUI.c 1.8
1.8 2009/03/31 20:36:50 jsanborn
added suggestions api and changed getFeatureData api
Index: src/hg/instinct/bioInt2/bioIntUI.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/bioInt2/bioIntUI.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -b -B -U 4 -r1.7 -r1.8
--- src/hg/instinct/bioInt2/bioIntUI.c 31 Mar 2009 05:06:38 -0000 1.7
+++ src/hg/instinct/bioInt2/bioIntUI.c 31 Mar 2009 20:36:50 -0000 1.8
@@ -139,8 +139,18 @@
return sqlQuickString(conn, query);
}
+struct pathways *getPathwayByName(struct sqlConnection *conn, char *name)
+{
+char query[256];
+safef(query, sizeof(query),
+ "select * from %s where name = \"%s\" ",
+ PA_TABLE, name);
+
+return pathwaysLoadByQuery(conn, query);
+}
+
void setAnalysisFeatureDesc(struct sqlConnection *conn, struct json *js,
struct analysisFeatures *af)
{
char *desc = getFieldFromKgXref(conn, af->feature_name, "description");
@@ -157,11 +167,23 @@
void setAnalysisFeatureLink(struct sqlConnection *conn, struct json *js,
struct analysisFeatures *af)
{
-char *kgId = getFieldFromKgXref(conn, af->feature_name, "kgId");
-if (kgId)
- jsonAddString(js, "hgg_gene", kgId);
+char *name, *source;
+name = getFieldFromKgXref(conn, af->feature_name, "kgId");
+if (name)
+ source = "UCSC";
+else
+ {
+ struct pathways *pa = getPathwayByName(conn, af->feature_name);
+ if (!pa)
+ return;
+ name = pa->name;
+ source = pa->source;
+ }
+
+jsonAddString(js, "name", name);
+jsonAddString(js, "source", source);
}
/****** END HELPER FUNCTIONS *******/
@@ -382,8 +404,35 @@
cohort_id = 1; // hard code for first analysis during testing!
/* feature source = gene,geneset,clinical... */
char *source = cartOptionalString(cart, bioIntSourceName);
+char *feature_name = cartOptionalString(cart, bioIntFeatureName);
+if (!feature_name || !source)
+ errAbort("%s and %s must be set for mode=getFeatureData\n", bioIntFeature, bioIntSourceName);
+
+struct sqlConnection *conn = hAllocConnProfile(localDb, db);
+
+struct datasets *daList = getDatasetsByCohortId(conn, cohort_id);
+if (!daList)
+ errAbort("No datasets matching cohort_id = %d", cohort_id);
+
+struct json *js = newJson();
+sendUniqueMatch(conn, js, cohort_id, feature_name, source, daList);
+
+if (js)
+ hPrintf("%s\n", js->print(js));
+
+hFreeConn(&conn);
+}
+
+void getSuggestions()
+{
+int cohort_id = cartUsualInt(cart, bioIntCohortId, -1);
+if (cohort_id == -1)
+ cohort_id = 1; // hard code for first analysis during testing!
+
+/* feature source = gene,geneset,clinical... */
+//char *source = cartOptionalString(cart, bioIntSourceName);
char *feature_name = cartOptionalString(cart, bioIntFeatureName);
if (!feature_name)
errAbort("%s or %s must be set for mode=getFeatureData\n", bioIntFeature, bioIntFeatureId);
@@ -394,25 +443,14 @@
if (!daList)
errAbort("No datasets matching cohort_id = %d", cohort_id);
struct json *js = newJson();
-if (source)
- sendUniqueMatch(conn, js, cohort_id, feature_name, source, daList);
-else
- {
- struct slPair *spList = searchForFeatures(conn, cohort_id, daList, feature_name);
-
- int numMatched = slCount(spList);
- if (numMatched == 0)
+struct slPair *spList = searchForFeatures(conn, cohort_id, daList, feature_name);
+int numMatched = slCount(spList);
+if (numMatched == 0)
sendNoMatch(js);
- else if (numMatched == 1)
- {
- source = spList->val;
- sendUniqueMatch(conn, js, cohort_id, spList->name, source, daList);
- }
- else
+else
sendAmbiguities(js, spList);
- }
if (js)
hPrintf("%s\n", js->print(js));
@@ -644,8 +682,10 @@
if (sameString(mode, "getAnalyses"))
getAnalyses();
else if (sameString(mode, "getFeatureData"))
getFeatureData();
+else if (sameString(mode, "getSuggestions"))
+ getSuggestions();
else if (sameString(mode, "getClinicalData"))
getClinicalData();
else if (sameString(mode, "getClinicalFeatures"))
getClinicalFeatures();