/* hgBioImage - CGI script to display things from bioImage database on web. */ #include "common.h" #include "linefile.h" #include "hash.h" #include "options.h" #include "cart.h" #include "dystring.h" #include "jksql.h" #include "cheapcgi.h" #include "portable.h" #include "htmshell.h" #include "web.h" #include "cart.h" #include "hui.h" #include "bioImage.h" #include "hgBioImage.h" /* Globals */ struct cart *cart; /* Current CGI values */ struct hash *oldCart; /* Previous CGI values */ void usage() /* Explain usage and exit. */ { errAbort( "hgBioImage - CGI script to display things from bioImage database on web\n" "usage:\n" " hgBioImage XXX\n" "options:\n" " -xxx=XXX\n" ); } void printCaption(struct sqlConnection *conn, int id, char *geneName) /* Print information about image. */ { char query[256]; char **row; char *treatment, *publication; char *setUrl, *itemUrl; printf("gene: %s ", naForNull(geneName)); printf("accession: %s ", naForNull(bioImageAccession(conn,id))); printf("type: %s
\n", naForNull(bioImageType(conn,id))); printf("organism: %s ", bioImageOrganism(conn, id)); printf("stage: %s
\n", bioImageStage(conn, id, TRUE)); printf("body part: %s ", naForNull(bioImageBodyPart(conn,id))); printf("section type: %s
\n", naForNull(bioImageSliceType(conn,id))); treatment = bioImageTreatment(conn,id); if (treatment != NULL) printf("treatment: %s
\n", treatment); publication = bioImagePublication(conn,id); if (publication != NULL) { char *pubUrl = bioImagePubUrl(conn,id); printf("reference: "); if (pubUrl != NULL) printf("%s", pubUrl, publication); else printf("%s", publication); printf("
\n"); } printf("contributors: %s
\n", naForNull(bioImageContributors(conn,id))); setUrl = bioImageSetUrl(conn, id); itemUrl = bioImageItemUrl(conn, id); if (setUrl != NULL || itemUrl != NULL) { printf("contributor links: "); if (setUrl != NULL) printf("image set ", setUrl); if (itemUrl != NULL) { printf("this image"); } printf("
\n"); } } void mainPage(struct sqlConnection *conn, int id, char *geneName) /* Put up fancy main page - image, caption, and then a bunch of thumbnails. */ { struct slInt *thumbList = NULL, *thumb; cartWebStart(cart, NULL, "UCSC BioImage Browser on %s", geneName); printf(""); printf("
\n", bioImageScreenSizePath(conn, id)); printf("\n"); printCaption(conn, id, geneName); htmlHorizontalLine(); printf("Other images associated with gene. Click to view details.
"); thumbList = bioImageOnSameGene(conn, id); for (thumb = thumbList; thumb != NULL; thumb = thumb->next) { char *imageFile = bioImageThumbSizePath(conn, thumb->val); printf("", hgbiId, thumb->val); printf("\n", imageFile); printf(" "); } cartWebEnd(); } void cartMain(struct cart *theCart) /* We got the persistent/CGI variable cart. Now * set up the globals and make a web page. */ { cart = theCart; /* Break out new block after have set cart */ { int id = cartUsualInt(cart, hgbiId, 1); struct sqlConnection *conn = sqlConnect("bioImage"); char *geneName = bioImageGeneName(conn, id); if (cartVarExists(cart, hgbiDoFullSize)) { htmStart(stdout, "BioImage Full Sized Image"); printf("
\n", bioImageFullSizePath(conn, id)); printCaption(conn, id, geneName); htmlEnd(); } else /* Default case - start fancy web page. */ { mainPage(conn, id, geneName); } cartRemovePrefix(cart, hgbiDoPrefix); sqlDisconnect(&conn); } } char *excludeVars[] = {"Submit", "submit", NULL}; int main(int argc, char *argv[]) /* Process command line. */ { cgiSpoof(&argc, argv); if (argc != 1) usage(); oldCart = hashNew(12); cartEmptyShell(cartMain, hUserCookie(), excludeVars, oldCart); return 0; }