25a1ed58b2f9fc2d9ad7fdbe9117f0b2f47253f3 fanhsu Tue Nov 9 16:38:23 2010 -0800 Update for RGD Genes, Redmine issue #29. diff --git src/hg/hgGene/hgGene.c src/hg/hgGene/hgGene.c index c8a78f6..399eeff 100644 --- src/hg/hgGene/hgGene.c +++ src/hg/hgGene/hgGene.c @@ -22,30 +22,32 @@ /* ---- Global variables. ---- */ struct cart *cart; /* This holds cgi and other variables between clicks. */ struct hash *oldVars; /* Old cart hash. */ char *database; /* Name of genome database - hg15, mm3, or the like. */ char *genome; /* Name of genome - mouse, human, etc. */ char *curGeneId; /* Current Gene Id. */ char *curGeneName; /* Biological name of gene. */ char *curGeneChrom; /* Chromosome current gene is on. */ struct genePred *curGenePred; /* Current gene prediction structure. */ int curGeneStart,curGeneEnd; /* Position in chromosome. */ struct sqlConnection *spConn; /* Connection to SwissProt database. */ char *swissProtAcc; /* SwissProt accession (may be NULL). */ int kgVersion = KG_UNKNOWN; /* KG version */ +//#include "rgdInfo.c" + void usage() /* Explain usage and exit. */ { errAbort( "hgGene - A CGI script to display the gene details page.\n" "usage:\n" " hgGene cgi-vars in var=val format\n" "options:\n" " -hgsid=XXX Session ID to grab vars from session database\n" " -db=XXX Genome database associated with gene\n" " -org=XXX Organism associated with gene\n" " -hgg_gene=XXX ID of gene\n" ); } @@ -136,30 +138,35 @@ { char *name = genoQuery(id, "nameSql", conn); if (name == NULL) name = cloneString(id); return name; } char *getSwissProtAcc(struct sqlConnection *conn, struct sqlConnection *spConn, char *geneId) /* Look up SwissProt id. Return NULL if not found. FreeMem this when done. * spConn is existing SwissProt database conn. May be NULL. */ { char *proteinSql = genomeSetting("proteinSql"); char query[256]; char *someAcc, *primaryAcc = NULL; +if (isRgdGene(conn)) + { + return(getRgdGeneUniProtAcc(curGeneId, conn)); + } + safef(query, sizeof(query), proteinSql, geneId); someAcc = sqlQuickString(conn, query); if (someAcc == NULL || someAcc[0] == 0) return NULL; primaryAcc = spFindAcc(spConn, someAcc); freeMem(someAcc); return primaryAcc; } /* --------------- Page printers ----------------- */ boolean idInAllMrna(char *id, struct sqlConnection *conn) /* Return TRUE if id is in allMrna table */ { @@ -326,48 +333,59 @@ const struct section *a = *((struct section **)va); const struct section *b = *((struct section **)vb); float dif = a->priority - b->priority; if (dif < 0) return -1; else if (dif > 0) return 1; else return 0; } static void addGoodSection(struct section *section, struct sqlConnection *conn, struct section **pList) /* Add section to list if it is non-null and exists returns ok. */ { +//printf("
adding %s section \n", section->name);fflush(stdout); if (section != NULL && hashLookup(section->settings, "hide") == NULL && section->exists(section, conn, curGeneId)) slAddHead(pList, section); } struct section *loadSectionList(struct sqlConnection *conn) /* Load up section list - first load up sections.ra, and then * call each section loader. */ { struct hash *sectionRa = NULL; struct section *sectionList = NULL; readRa("section.ra", §ionRa); addGoodSection(linksSection(conn, sectionRa), conn, §ionList); /* disable ortherOrg section for CGB servers for the time being */ if (!hIsCgbServer()) addGoodSection(otherOrgsSection(conn, sectionRa), conn, §ionList); addGoodSection(gadSection(conn, sectionRa), conn, §ionList); addGoodSection(ctdSection(conn, sectionRa), conn, §ionList); +/*if (isRgdGene(conn)) + { + addGoodSection(ctdRgdGene2Section(conn, sectionRa), conn, §ionList); + } +else + { + addGoodSection(ctdSection(conn, sectionRa), conn, §ionList); + } +*/ +addGoodSection(rgdGeneRawSection(conn, sectionRa), conn, §ionList); //addGoodSection(microarraySection(conn, sectionRa), conn, §ionList); /* temporarily disable microarray section for Zebrafish, until a bug is fixed */ if (strstr(database, "danRer") == NULL) { addGoodSection(microarraySection(conn, sectionRa), conn, §ionList); } addGoodSection(rnaStructureSection(conn, sectionRa), conn, §ionList); addGoodSection(domainsSection(conn, sectionRa), conn, §ionList); addGoodSection(altSpliceSection(conn, sectionRa), conn, §ionList); // addGoodSection(multipleAlignmentsSection(conn, sectionRa), conn, §ionList); addGoodSection(swissProtCommentsSection(conn, sectionRa), conn, §ionList); addGoodSection(flyBaseRolesSection(conn, sectionRa), conn, §ionList); addGoodSection(flyBasePhenotypesSection(conn, sectionRa), conn, §ionList); addGoodSection(flyBaseSynonymsSection(conn, sectionRa), conn, §ionList); @@ -426,30 +444,32 @@ } void printSections(struct section *sectionList, struct sqlConnection *conn, char *geneId) /* Print each section in turn. */ { struct section *section; for (section = sectionList; section != NULL; section = section->next) { char *closeVarName = sectionCloseVar(section->name); boolean isOpen = !(cartUsualInt(cart, closeVarName, 0)); char *otherState = (isOpen ? "1" : "0"); char *indicator = (isOpen ? "-" : "+"); char *indicatorImg = (isOpen ? "../images/remove.gif" : "../images/add.gif"); struct dyString *header = dyStringNew(0); + //keep the following line for future debugging need + //printf("
printing %s section\n", section->name);fflush(stdout); dyStringPrintf(header, "", section->name); dyStringPrintf(header, "\"%s\"  ", geneCgi, cartSidUrlString(cart), closeVarName, otherState, section->name, indicatorImg, indicator); dyStringAppend(header, section->longLabel); webNewSection(header->string); if (isOpen) { section->print(section, conn, geneId); } else { printf("Press \"+\" in the title bar above to open this section."); } dyStringFree(&header); } @@ -540,31 +560,30 @@ hUserAbort("Couldn't find %s in %s.%s", curGeneId, database, table); sqlFreeResult(&sr); } } struct genePred *getCurGenePred(struct sqlConnection *conn) /* Return current gene in genePred. */ { char *track = genomeSetting("knownGene"); char table[64]; boolean hasBin; char query[256]; struct sqlResult *sr; char **row; struct genePred *gp = NULL; - hFindSplitTable(sqlGetDatabase(conn), curGeneChrom, track, table, &hasBin); safef(query, sizeof(query), "select * from %s where name = '%s' " "and chrom = '%s' and txStart=%d and txEnd=%d" , table, curGeneId, curGeneChrom, curGeneStart, curGeneEnd); sr = sqlGetResult(conn, query); if ((row = sqlNextRow(sr)) != NULL) gp = genePredLoad(row + hasBin); sqlFreeResult(&sr); if (gp == NULL) errAbort("getCurGenePred: Can't find %s", query); return gp; } void doKgMethod() @@ -597,30 +616,31 @@ // Silly googlebots. hUserAbort("Error: the hgg_gene parameter is missing from the cart and the CGI params."); } /* if kgProtMap2 table exists, this means we are doing KG III */ if (hTableExists(database, "kgProtMap2")) kgVersion = KG_III; conn = hAllocConn(database); curGeneId = findGeneId(conn, geneName); getGenePosition(conn); curGenePred = getCurGenePred(conn); curGeneName = getGeneName(curGeneId, conn); spConn = hAllocConn(UNIPROT_DB_NAME); swissProtAcc = getSwissProtAcc(conn, spConn, curGeneId); + if (isRgdGene(conn)) swissProtAcc=getRgdGeneUniProtAcc(curGeneId, conn); /* Check command variables, and do the ones that * don't want to put up the hot link bar etc. */ if (cartVarExists(cart, hggDoGetMrnaSeq)) doGetMrnaSeq(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoWikiTrack)) doWikiTrack(conn); else if (cartVarExists(cart, hggDoGetProteinSeq)) doGetProteinSeq(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoRnaFoldDisplay)) doRnaFoldDisplay(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoOtherProteinSeq)) doOtherProteinSeq(conn, curGeneName); else if (cartVarExists(cart, hggDoOtherProteinAli)) doOtherProteinAli(conn, curGeneId, curGeneName); else