e70152e44cc66cc599ff6b699eb8adc07f3e656a
kent
Sat May 24 21:09:34 2014 -0700
Adding Copyright NNNN Regents of the University of California to all files I believe with reasonable certainty were developed under UCSC employ or as part of Genome Browser copyright assignment.
diff --git src/hg/hgGene/swissProtComments.c src/hg/hgGene/swissProtComments.c
index 042f0cb..5a89388 100644
--- src/hg/hgGene/swissProtComments.c
+++ src/hg/hgGene/swissProtComments.c
@@ -1,162 +1,165 @@
/* SwissProt comments - print out SwissProt comments if any. */
+/* Copyright (C) 2013 The Regents of the University of California
+ * See README in this or parent directory for licensing information. */
+
#include "common.h"
#include "hash.h"
#include "linefile.h"
#include "dystring.h"
#include "spDb.h"
#include "hgGene.h"
struct spComment
/* Swiss prot comment. */
{
struct spComment *next;
int typeId; /* Comment type. */
int valId; /* Comment value. */
};
static boolean swissProtCommentsExists(struct section *section,
struct sqlConnection *conn, char *geneId)
/* Return TRUE if swissProt database exists and there are comments
* on this gene. This does first part of database lookup and
* stores it in section->items as a spComment list. */
{
char query[512], **row;
struct sqlResult *sr;
boolean commentFound = FALSE;
struct spComment *list = NULL, *com;
char *acc = swissProtAcc;
if (acc != NULL)
{
sqlSafef(query, sizeof(query),
"select commentType,commentVal from comment where acc='%s'" , acc);
sr = sqlGetResult(spConn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
commentFound = TRUE;
AllocVar(com);
com->typeId = atoi(row[0]);
com->valId = atoi(row[1]);
slAddHead(&list, com);
}
slReverse(&list);
section->items = list;
if (!commentFound)
{
/* check if the acc has become a secondary ID */
sqlSafef(query, sizeof(query),
"select accession from proteome.spSecondaryID where accession2='%s'" , acc);
sr = sqlGetResult(spConn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
acc = cloneString(row[0]);
sqlFreeResult(&sr);
sqlSafef(query, sizeof(query),
"select commentType,commentVal from comment where acc='%s'" , acc);
sr = sqlGetResult(spConn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
AllocVar(com);
com->typeId = atoi(row[0]);
com->valId = atoi(row[1]);
slAddHead(&list, com);
}
slReverse(&list);
section->items = list;
}
}
}
return list != NULL;
}
static char *omimUrl = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Search&db=OMIM&term=%d&doptcmdl=Detailed&tool=genome.ucsc.edu";
static void mimSubPrint(char *s)
/* Print out putting in hyperlinks for OMIM. */
{
char *e, *f, *g;
while (s != NULL && s[0] != 0)
{
boolean gotOmim = FALSE;
e = stringIn("[MIM:", s);
if (e != NULL)
{
f = e + strlen("[MIM:");
if (isdigit(f[0]))
{
g = strchr(f, ']');
if (g != 0 && g - f < 8)
{
int omimId = atoi(f);
int skipSize = g - e + 1;
mustWrite(stdout, s, e-s);
hPrintf("");
mustWrite(stdout, e, skipSize);
hPrintf("");
s = e + skipSize;
gotOmim = TRUE;
}
}
}
if (!gotOmim)
{
hPrintf("%s", s);
s = NULL;
}
}
}
static void swissProtCommentsPrint(struct section *section,
struct sqlConnection *conn, char *geneId)
/* Print out SwissProt comments - looking up typeId/commentVal. */
{
struct spComment *com;
char *acc = swissProtAcc;
char *description;
char *id = spAnyAccToId(spConn, acc);
if (id == NULL)
{
errAbort("
%s seems to no longer be a valid protein ID in our latest UniProtKB DB", acc);
}
/* the new logic below is to handle the situation that an accession may have
become a secondary accession number in a newer UniProt DB release */
description = spDescription(spConn, spFindAcc(spConn, acc));
hPrintf("ID: ");
hPrintf("", acc);
hPrintf("%s
\n", id);
if (description != NULL)
hPrintf("DESCRIPTION: %s
\n", description);
for (com = section->items; com != NULL; com = com->next)
{
char *type = spCommentType(spConn, com->typeId);
if (!sameWord(type, "ALTERNATIVE PRODUCTS"))
{
char *val = spCommentVal(spConn, com->valId);
hPrintf("%s: ", type);
mimSubPrint(val);
hPrintf("
");
freeMem(type);
freeMem(val);
}
}
slFreeList(§ion->items);
freeMem(description);
}
struct section *swissProtCommentsSection(struct sqlConnection *conn,
struct hash *sectionRa)
/* Create SwissProt comments section. */
{
struct section *section = sectionNew(sectionRa, "swissProtComments");
section->exists = swissProtCommentsExists;
section->print = swissProtCommentsPrint;
return section;
}