src/hg/hgc/hgc.c 1.1553
1.1553 2009/06/12 07:21:29 markd
added support for chimera in H1N1 prototype; also some refactoring
Index: src/hg/hgc/hgc.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgc/hgc.c,v
retrieving revision 1.1552
retrieving revision 1.1553
diff -b -B -U 4 -r1.1552 -r1.1553
--- src/hg/hgc/hgc.c 9 Jun 2009 15:55:39 -0000 1.1552
+++ src/hg/hgc/hgc.c 12 Jun 2009 07:21:29 -0000 1.1553
@@ -217,12 +217,13 @@
#include "twoBit.h"
#include "itemConf.h"
#include "chromInfo.h"
#include "gbWarn.h"
-#include "mammalPsg.h"
#include "lsSnpPdbChimera.h"
+#include "mammalPsg.h"
#include "net.h"
#include "jsHelper.h"
+#include "virusClick.h"
static char const rcsid[] = "$Id$";
static char *rootDir = "hgcData";
@@ -9517,421 +9518,8 @@
*s = 0;
return trimSpaces(gi);
}
-static void h1n1DownloadPdb(char *item, char *pdbUrl, struct tempName *tmpPdb)
-/* uncompress PDB to trash */
-{
-int inFd = netOpenHttpExt(pdbUrl, "GET", TRUE);
-int inFdRedir = 0;
-char *pdbUrlRedir = NULL;
-if (!netSkipHttpHeaderLinesHandlingRedirect(inFd, pdbUrl, &inFdRedir, &pdbUrlRedir))
- errAbort("Unable to access predicted 3D structure file: %s", pdbUrl);
-if (pdbUrlRedir != NULL)
- {
- close(inFd);
- inFd = inFdRedir;
- freez(&pdbUrlRedir);
- }
-
-trashDirFile(tmpPdb, "hgct", item, ".pdb");
-FILE *outFh = mustOpen(tmpPdb->forCgi, "w");
-struct lineFile *inLf = lineFileDecompressFd(pdbUrl, TRUE, inFd);
-char *line;
-while (lineFileNext(inLf, &line, NULL))
- {
- fputs(line, outFh);
- fputc('\n', outFh);
- }
-lineFileClose(&inLf);
-carefulClose(&outFh);
-}
-
-static void h1n1MkChimeraxTrashFullUrl(struct tempName *tmpPdb, char *fullUrl, int fullUrlSize)
-/* generate full URL for a chimerax file decompressed to trash */
-{
-// FIXME: this is not generate (URL generation will not work on all web servers).
-// if this is kept, should address this.
-char *serverName = getenv("SERVER_NAME");
-char *serverPort = getenv("SERVER_PORT");
-char *scriptName = getenv("SCRIPT_NAME");
-if ((serverName != NULL) && (serverPort != NULL) && (scriptName != NULL))
- {
- // remote url
- safef(fullUrl, fullUrlSize, "http://%s", serverName);
- if (!sameString(serverPort, "80"))
- {
- safecat(fullUrl, fullUrlSize, ":");
- safecat(fullUrl, fullUrlSize, serverPort);
- }
- safecat(fullUrl, fullUrlSize, scriptName);
- char *p = strrchr(fullUrl, '/');
- if (p != NULL)
- *++p = '\0'; // drop cgi name, keeping directory
- safecat(fullUrl, fullUrlSize, tmpPdb->forHtml);
- }
-else
- {
- // local url
- safef(fullUrl, fullUrlSize, "file:///%s/%s", getCurrentDir(), tmpPdb->forHtml);
- }
-}
-
-static void h1n1MkChimerax(char *item, char *pdbUrl, struct tempName *chimerax)
-/* generate a chimerax file for downloading h1n1 PDB structure */
-{
-// chimera doesn't handle compressed files via URL, so uncompress into the trash
-struct tempName tmpPdb;
-char usePdbUrl[PATH_LEN];
-if (endsWith(pdbUrl, ".gz") || endsWith(pdbUrl, ".Z"))
- {
- h1n1DownloadPdb(item, pdbUrl, &tmpPdb);
- h1n1MkChimeraxTrashFullUrl(&tmpPdb, usePdbUrl, sizeof(usePdbUrl));
- }
-else
- safecpy(usePdbUrl, sizeof(usePdbUrl), pdbUrl);
-lsSnpPdbChimeraGenericLink(usePdbUrl, NULL, "hgct", item, chimerax);
-}
-
-void showProtH1n1(char *item)
-{
-char query2[256];
-struct sqlResult *sr2;
-char **row2;
-struct sqlConnection *conn2 = hAllocConn(database);
-
-char *gisaidAaSeqSelectFileName;
-//= cartOptionalString(cart, gisaidAaSeqList);
-
-char *subjId, *dnaSeqId;
-char *aaSeqId= NULL;
-char *gene=NULL;
-
-char cond_str[256];
-char *predFN;
-char *homologID;
-char *SCOPdomain;
-char *chain;
-char goodSCOPdomain[40];
-int first = 1;
-float eValue;
-char *chp;
-int homologCount;
-int gotPDBFile = 0;
-char *extUrl = "http://users.soe.ucsc.edu/~karplus/h1n1";
-
-safef(query2, sizeof(query2),
- "select subjId, dnaSeqId, aaSeqId, gene from gisaidXref where dnaSeqId='%s'", item);
-sr2 = sqlMustGetResult(conn2, query2);
-row2 = sqlNextRow(sr2);
-if (row2 != NULL)
- {
- subjId = strdup(row2[0]);
- dnaSeqId = strdup(row2[1]);
- aaSeqId = strdup(row2[2]);
- gene = strdup(row2[3]);
- }
-else
- {
- errAbort("%s not found.", item);
- }
-sqlFreeResult(&sr2);
-
-printf("<H3>Protein Structure Analysis and Prediction</H3>");
-
-printf("<B>Comparison to 1918 Flu Virus:</B> ");
-printf("<A HREF=\"%s/%s/%s/1918_%s.mutate", extUrl, gene, aaSeqId, aaSeqId);
-printf("\" TARGET=_blank>%s</A><BR>\n", aaSeqId);
-
-printf("<B>Comparison to A H1N1 gene %s concensus:</B> ", gene);
-printf("<A HREF=\"%s/%s/%s/consensus_%s.mutate", extUrl, gene, aaSeqId, aaSeqId);
-printf("\" TARGET=_blank>%s</A><BR>\n", aaSeqId);
-
-//printf("<BR><B>3D structure prediction:</B> ");
-
-printf("<BR><B>3D Structure Prediction (PDB file):</B> ");
-char pdbUrl[PATH_LEN];
-safef(pdbUrl, sizeof(pdbUrl), "%s/%s/decoys/%s.try1-opt3.pdb.gz", extUrl, item, item);
-
-// Mark: please use cartOptionalString(cart, gisaidAaSeqList)
-// to get the actual file name of aa Seqs selected
-
-gisaidAaSeqSelectFileName = cartOptionalString(cart, gisaidAaSeqList);
-if (gisaidAaSeqSelectFileName != NULL)
-{
-printf("<br>gisaidAaSeqSelectionFile is at: %s<br>\n", gisaidAaSeqSelectFileName);fflush(stdout);
-}
-
-// resurect after Keven is done with new Modeller stuff
-printf(" To be done.");
-//struct tempName chimerax;
-
-//h1n1MkChimerax(item, pdbUrl, &chimerax);
-
-//printf("<A HREF=\"%s\" TARGET=_blank>%s</A>, view with <A HREF=\"%s\">Chimera</A><BR>\n", pdbUrl, item, chimerax.forHtml);
-
-printf("<TABLE>\n");
-printf("<TR>\n");
-printf("<TD ALIGN=\"center\"><img src=\"");
-
-printf("%s/%s/%s/%s_400.jpeg", extUrl, gene, aaSeqId, aaSeqId);
-printf("\"></TD>");
-printf("</TR>\n");
-printf("</TABLE>\n");
-
-return;
-
-gotPDBFile = 0;
-safef(cond_str, sizeof(cond_str), "proteinID='%s' and evalue <1.0e-5;", item);
-
-printf("<TABLE>\n");
-printf("<TR><TD ALIGN=\"center\">Front</TD>\n");
-printf("<TD ALIGN=\"center\">Top</TD>\n");
-printf("<TD ALIGN=\"center\">Side</TD>\n");
-printf("</TR>\n");
-printf("<TR>\n");
-printf("<TD ALIGN=\"center\"><img src=\"%s/%s/%s.undertaker-align.view1_200.jpg\"></TD>", extUrl, item, item);
-printf("<TD ALIGN=\"center\"><img src=\"%s/%s/%s.undertaker-align.view2_200.jpg\"></TD>", extUrl, item, item);
-printf("<TD ALIGN=\"center\"><img src=\"%s/%s/%s.undertaker-align.view3_200.jpg\"></TD>", extUrl, item, item);
-printf("</TR>\n");
-printf("<TR>\n");
-printf("<TD ALIGN=\"center\"><A HREF=\"%s/%s/%s.undertaker-align.view1_500.jpg\">500x500</A></TD>",
- extUrl, item, item);
-printf("<TD ALIGN=\"center\"><A HREF=\"%s/%s/%s.undertaker-align.view2_500.jpg\">500x500</A></TD>",
- extUrl, item, item);
-printf("<TD ALIGN=\"center\"><A HREF=\"%s/%s/%s.undertaker-align.view3_500.jpg\">500x500</A></TD>",
- extUrl, item, item);
-printf("</TR>\n");
-printf("</TABLE>\n");
-
-printf("<BR><B>Detailed results of SAM-T02:</B> ");
-printf("<A HREF=\"%s/%s/summary.html", extUrl, item);
-printf("\" TARGET=_blank>%s</A><BR>\n", item);
-
-/* by pass the following additional processing for now, until two necessary tables are built */
-hFreeConn(&conn2);
-return;
-
-if (sqlGetField(database, "protHomolog", "proteinID", cond_str) != NULL)
- {
- safef(cond_str, sizeof(cond_str), "proteinID='%s'", item);
- predFN = sqlGetField(database, "protPredFile", "predFileName", cond_str);
- if (predFN != NULL)
- {
- printf("<A HREF=\"../SARS/%s/", item);
- /* printf("%s.t2k.undertaker-align.pdb\">%s</A><BR>\n", item,item); */
- printf("%s\">%s</A><BR>\n", predFN,item);
- gotPDBFile = 1;
- }
- }
-if (!gotPDBFile)
- {
- printf("No high confidence level structure prediction available for this sequence.");
- printf("<BR>\n");
- }
-printf("<B>3D Structure of Close Homologs:</B> ");
-homologCount = 0;
-strcpy(goodSCOPdomain, "dummy");
-
-conn2= hAllocConn(database);
-safef(query2, sizeof(query2),
- "select homologID,eValue,SCOPdomain,chain from sc1.protHomolog where proteinID='%s' and evalue <= 0.01;",
- item);
-sr2 = sqlMustGetResult(conn2, query2);
-row2 = sqlNextRow(sr2);
-if (row2 != NULL)
- {
- while (row2 != NULL)
- {
- homologID = row2[0];
- sscanf(row2[1], "%e", &eValue);
- SCOPdomain = row2[2];
- chp = SCOPdomain+strlen(SCOPdomain)-1;
- while (*chp != '.') chp--;
- *chp = '\0';
- chain = row2[3];
- if (eValue <= 1.0e-10)
- strcpy(goodSCOPdomain, SCOPdomain);
- else
- {
- if (strcmp(goodSCOPdomain,SCOPdomain) != 0)
- goto skip;
- else
- if (eValue > 0.1) goto skip;
- }
- if (first)
- first = 0;
- else
- printf(", ");
-
- printf("<A HREF=\"http://www.rcsb.org/pdb/cgi/explore.cgi?job=graphics&pdbId=%s",
- homologID);
- if (strlen(chain) >= 1)
- printf("\"TARGET=_blank>%s(chain %s)</A>", homologID, chain);
- else
- printf("\"TARGET=_blank>%s</A>", homologID);
- homologCount++;
-
- skip:
- row2 = sqlNextRow(sr2);
- }
- }
-hFreeConn(&conn2);
-sqlFreeResult(&sr2);
-if (homologCount == 0)
- printf("None<BR>\n");
-
-printf("<BR><B>Details:</B> ");
-printf("<A HREF=\"../SARS/%s/summary.html", item);
-printf("\" TARGET=_blank>%s</A><BR>\n", item);
-
-htmlHorizontalLine();
-}
-void showSAM_h1n1(char *item)
-{
-char query2[256];
-struct sqlResult *sr2;
-char **row2;
-struct sqlConnection *conn2 = hAllocConn(database);
-char cond_str[256];
-char *predFN;
-char *homologID;
-char *SCOPdomain;
-char *chain;
-char goodSCOPdomain[40];
-int first = 1;
-float eValue;
-char *chp;
-int homologCount;
-int gotPDBFile = 0;
-char *extUrl = "http://users.soe.ucsc.edu/~karplus/h1n1";
-
-printf("<H3>Protein Structure Analysis and Prediction by ");
-printf("<A HREF=\"http://www.soe.ucsc.edu/research/compbio/SAM_T02/sam-t02-faq.html\"");
-printf(" TARGET=_blank>SAM-T02</A></H3>\n");
-
-printf("<B>Multiple Alignment:</B> ");
-printf("<A HREF=\"%s/%s/summary.html#alignment", extUrl, item);
-printf("\" TARGET=_blank>%s</A><BR>\n", item);
-
-printf("<B>Secondary Structure Predictions:</B> ");
-printf("<A HREF=\"%s/%s/summary.html#secondary-structure", extUrl, item);
-printf("\" TARGET=_blank>%s</A><BR>\n", item);
-
-printf("<B>3D Structure Prediction (PDB file):</B> ");
-char pdbUrl[PATH_LEN];
-safef(pdbUrl, sizeof(pdbUrl), "%s/%s/decoys/%s.try1-opt3.pdb.gz", extUrl, item, item);
-struct tempName chimerax;
-h1n1MkChimerax(item, pdbUrl, &chimerax);
-
-printf("<A HREF=\"%s\" TARGET=_blank>%s</A>, view with <A HREF=\"%s\">Chimera</A><BR>\n", pdbUrl, item, chimerax.forHtml);
-
-gotPDBFile = 0;
-safef(cond_str, sizeof(cond_str), "proteinID='%s' and evalue <1.0e-5;", item);
-
-printf("<TABLE>\n");
-printf("<TR><TD ALIGN=\"center\">Front</TD>\n");
-printf("<TD ALIGN=\"center\">Top</TD>\n");
-printf("<TD ALIGN=\"center\">Side</TD>\n");
-printf("</TR>\n");
-printf("<TR>\n");
-printf("<TD ALIGN=\"center\"><img src=\"%s/%s/%s.undertaker-align.view1_200.jpg\"></TD>", extUrl, item, item);
-printf("<TD ALIGN=\"center\"><img src=\"%s/%s/%s.undertaker-align.view2_200.jpg\"></TD>", extUrl, item, item);
-printf("<TD ALIGN=\"center\"><img src=\"%s/%s/%s.undertaker-align.view3_200.jpg\"></TD>", extUrl, item, item);
-printf("</TR>\n");
-printf("<TR>\n");
-printf("<TD ALIGN=\"center\"><A HREF=\"%s/%s/%s.undertaker-align.view1_500.jpg\">500x500</A></TD>",
- extUrl, item, item);
-printf("<TD ALIGN=\"center\"><A HREF=\"%s/%s/%s.undertaker-align.view2_500.jpg\">500x500</A></TD>",
- extUrl, item, item);
-printf("<TD ALIGN=\"center\"><A HREF=\"%s/%s/%s.undertaker-align.view3_500.jpg\">500x500</A></TD>",
- extUrl, item, item);
-printf("</TR>\n");
-printf("</TABLE>\n");
-
-printf("<BR><B>Detailed results of SAM-T02:</B> ");
-printf("<A HREF=\"%s/%s/summary.html", extUrl, item);
-printf("\" TARGET=_blank>%s</A><BR>\n", item);
-
-/* by pass the following additional processing for now, until two necessary tables are built */
-hFreeConn(&conn2);
-return;
-
-if (sqlGetField(database, "protHomolog", "proteinID", cond_str) != NULL)
- {
- safef(cond_str, sizeof(cond_str), "proteinID='%s'", item);
- predFN = sqlGetField(database, "protPredFile", "predFileName", cond_str);
- if (predFN != NULL)
- {
- printf("<A HREF=\"../SARS/%s/", item);
- /* printf("%s.t2k.undertaker-align.pdb\">%s</A><BR>\n", item,item); */
- printf("%s\">%s</A><BR>\n", predFN,item);
- gotPDBFile = 1;
- }
- }
-if (!gotPDBFile)
- {
- printf("No high confidence level structure prediction available for this sequence.");
- printf("<BR>\n");
- }
-printf("<B>3D Structure of Close Homologs:</B> ");
-homologCount = 0;
-strcpy(goodSCOPdomain, "dummy");
-
-conn2= hAllocConn(database);
-safef(query2, sizeof(query2),
- "select homologID,eValue,SCOPdomain,chain from sc1.protHomolog where proteinID='%s' and evalue <= 0.01;",
- item);
-sr2 = sqlMustGetResult(conn2, query2);
-row2 = sqlNextRow(sr2);
-if (row2 != NULL)
- {
- while (row2 != NULL)
- {
- homologID = row2[0];
- sscanf(row2[1], "%e", &eValue);
- SCOPdomain = row2[2];
- chp = SCOPdomain+strlen(SCOPdomain)-1;
- while (*chp != '.') chp--;
- *chp = '\0';
- chain = row2[3];
- if (eValue <= 1.0e-10)
- strcpy(goodSCOPdomain, SCOPdomain);
- else
- {
- if (strcmp(goodSCOPdomain,SCOPdomain) != 0)
- goto skip;
- else
- if (eValue > 0.1) goto skip;
- }
- if (first)
- first = 0;
- else
- printf(", ");
-
- printf("<A HREF=\"http://www.rcsb.org/pdb/cgi/explore.cgi?job=graphics&pdbId=%s",
- homologID);
- if (strlen(chain) >= 1)
- printf("\"TARGET=_blank>%s(chain %s)</A>", homologID, chain);
- else
- printf("\"TARGET=_blank>%s</A>", homologID);
- homologCount++;
-
- skip:
- row2 = sqlNextRow(sr2);
- }
- }
-hFreeConn(&conn2);
-sqlFreeResult(&sr2);
-if (homologCount == 0)
- printf("None<BR>\n");
-
-printf("<BR><B>Details:</B> ");
-printf("<A HREF=\"../SARS/%s/summary.html", item);
-printf("\" TARGET=_blank>%s</A><BR>\n", item);
-
-htmlHorizontalLine();
-}
void showSAM_T02(char *itemName)
{
char query2[256];
struct sqlResult *sr2;
@@ -16322,45 +15910,8 @@
sqlFreeResult(&sr);
hFreeConn(&conn);
}
-void doH1n1Seq(struct trackDb *tdb, char *item)
-/* Show extra info for H1N1 Seq Annotations track. */
-{
-struct sqlConnection *conn = hAllocConn(database);
-struct sqlResult *sr;
-char query[256];
-char **row;
-genericHeader(tdb, item);
-
-/*pslList = getAlignments(conn, track, item);
-printAlignmentsSimple(pslList, start, "h1n1Seq", track, item);
-*/
-sprintf(query, "select * from h1n1SeqXref where seqId = '%s'", item);
-sr = sqlGetResult(conn, query);
-if ((row = sqlNextRow(sr)) != NULL)
- {
- char *seqId, *geneSymbol, *strain;
-
- seqId = row[0];
- geneSymbol = row[1];
- strain = row[2];
-
- printf("<B>Sequence ID: %s</B> <BR>", seqId);
- printf("<B>Gene: %s</B> <BR>", geneSymbol);
- printf("<B>Strain: %s</B> <BR>", strain);
- }
-htmlHorizontalLine();
-//showSAM_h1n1(item);
-showProtH1n1(item);
-
-htmlHorizontalLine();
-printTrackHtml(tdb);
-
-sqlFreeResult(&sr);
-hFreeConn(&conn);
-}
-
void doGbProtAnn(struct trackDb *tdb, char *item)
/* Show extra info for GenBank Protein Annotations track. */
{
struct sqlConnection *conn = hAllocConn(database);