src/hg/instinct/hgGeneset/hgGenesets.c 1.7
1.7 2010/01/28 23:12:28 sbenz
First cut, it's ugly but it works (kinda)
Index: src/hg/instinct/hgGeneset/hgGenesets.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/hgGeneset/hgGenesets.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -b -B -U 4 -r1.6 -r1.7
--- src/hg/instinct/hgGeneset/hgGenesets.c 28 Jan 2010 23:05:25 -0000 1.6
+++ src/hg/instinct/hgGeneset/hgGenesets.c 28 Jan 2010 23:12:28 -0000 1.7
@@ -436,8 +436,41 @@
hFreeConn(&conn);
}
+void getSamples()
+{
+char *cohortId = cartOptionalString(cart, hghCohortId);
+if (!cohortId)
+ errAbort("%s is required\n", hghCohortId);
+
+char query[256];
+safef(query, sizeof(query),
+ "select s.* from %s s,%s dc where dc.dataset_id = s.dataset_id and dc.cohort_id = '%s' group by s.sample_id;", SA_TABLE, DC_TABLE, cohortId);
+
+struct sqlConnection *conn = hAllocConnProfile(localDb, db);
+struct samples *sa, *saList = samplesLoadByQuery(conn, query);
+
+struct json *js = newJson();
+struct json *sample, *samples = jsonAddContainerList(js, "samples");
+sample = samples;
+for (sa = saList; sa; sa = sa->next)
+ {
+ jsonAddInt(sample, "sample_id", sa->sample_id);
+ jsonAddString(sample, "sample_name", sa->sample_name);
+ jsonAddInt(sample, "patient_id", sa->patient_id);
+ jsonAddString(sample, "patient_name", sa->patient_name);
+
+ if (sa->next)
+ sample = jsonAddContainerToList(&samples);
+ }
+
+if (js)
+ hPrintf("%s\n", js->print(js));
+
+hFreeConn(&conn);
+}
+
void sendNoMatch(struct json *js)
{
return;
}
@@ -919,8 +952,12 @@
errAbort("%s is required.", hghMode);
if (sameString(mode, "drawHeatmap"))
drawHeatmap();
+else if (sameString(mode, "getCohorts"))
+ getCohorts();
+else if (sameString(mode, "getSamples"))
+ getSamples();
else
errAbort("Incorrect mode = %s", mode);
cartRemovePrefix(cart, hghPrefix);