a44421a79fb36cc2036fe116b97ea3bc9590cd0c
braney
Fri Dec 2 09:34:39 2011 -0800
removed rcsid (#295)
diff --git src/hg/hgGene/flyBaseInfo.c src/hg/hgGene/flyBaseInfo.c
index bc57305..8752c7e 100644
--- src/hg/hgGene/flyBaseInfo.c
+++ src/hg/hgGene/flyBaseInfo.c
@@ -1,392 +1,391 @@
/* flyBaseInfo - print out selected information from flybase. */
#include "common.h"
#include "hash.h"
#include "linefile.h"
#include "dystring.h"
#include "hdb.h"
#include "spDb.h"
#include "hgGene.h"
#include "fbTables.h"
#include "bdgpExprLink.h"
-static char const rcsid[] = "$Id: flyBaseInfo.c,v 1.8 2006/03/06 17:46:34 angie Exp $";
boolean isFly()
/* Return true if organism is D. melanogaster. */
{
return(sameWord(hOrganism(database), "D. melanogaster"));
}
char *getFlyBaseId(struct sqlConnection *conn, char *geneId)
/* Return flyBase ID of gene if any. */
{
if (sqlTableExists(conn, "bdgpGeneInfo"))
{
char query[256];
char *cutId = cloneString(geneId);
char *e = strchr(cutId, '-');
if (e != NULL)
*e = 0;
safef(query, sizeof(query),
"select flyBaseId from bdgpGeneInfo where bdgpName = '%s'", cutId);
freeMem(cutId);
return sqlQuickString(conn, query);
}
else if (sqlTableExists(conn, "flyBase2004Xref"))
{
char query[256];
safef(query, sizeof(query),
"select fbgn from flyBase2004Xref where name = '%s'", geneId);
return sqlQuickString(conn, query);
}
return NULL;
}
static boolean flyBaseInfoExists(struct section *section,
struct sqlConnection *conn, char *geneId)
/* Return TRUE if flyBase info tables exist. */
{
char *flyBaseId = getFlyBaseId(conn, geneId);
char query[256];
int roleCount;
if (flyBaseId == NULL)
return FALSE;
if (!sqlTableExists(conn, section->flyBaseTable) )
return FALSE;
if (!sqlTablesExist(conn, "fbAllele fbGene fbRef") )
return FALSE;
safef(query, sizeof(query), "select count(*) from %s where geneId = '%s'",
section->flyBaseTable, flyBaseId);
roleCount = sqlQuickNum(conn, query);
freeMem(flyBaseId);
return roleCount != 0;
}
struct fbAlleleInfo
/* Info on allele */
{
struct fbAlleleInfo *next;
int id;
struct fbRole *roleList;
};
static int fbAlleleInfoCmp(const void *va, const void *vb)
/* Compare to sort based on id. */
{
const struct fbAlleleInfo *a = *((struct fbAlleleInfo **)va);
const struct fbAlleleInfo *b = *((struct fbAlleleInfo **)vb);
return a->id - b->id;
}
static void addToAllele(struct hash *alleleHash,
struct fbAlleleInfo **pAlleleList,
int alleleId, struct fbRole *role)
/* Look up alleleId in hash, and if it isn't there create
* a new allele and add it to hash and list. Add role and phenotype
* to allele. */
{
char numBuf[16];
struct fbAlleleInfo *allele;
safef(numBuf, sizeof(numBuf), "%x", alleleId);
allele = hashFindVal(alleleHash, numBuf);
if (allele == NULL)
{
AllocVar(allele);
allele->id = alleleId;
slAddTail(pAlleleList, allele);
hashAdd(alleleHash, numBuf, allele);
}
if (role != NULL)
{
slAddTail(&allele->roleList, role);
}
}
static void printSubAt(char *s)
/* Print out text, substituting @ for or */
{
boolean italic = FALSE;
char c;
while ((c = *s++) != 0)
{
if (c == '@')
{
italic = !italic;
if (italic)
hPrintf("");
else
hPrintf("");
}
else
hPrintf("%c", c);
}
if (italic) /* Just in case turn off. */
hPrintf("");
}
static void printCite(struct sqlConnection *conn, int id)
/* Print out reference info. */
{
char query[256];
char *refText;
safef(query, sizeof(query), "select text from fbRef where id=%d", id);
refText = sqlQuickString(conn, query);
if (refText != NULL)
{
char *s = refText;
if (startsWith("FBrf", refText))
{
char *e = stringIn("==", s);
if (e != NULL)
s = e + 3;
}
hPrintf(" (%s)", s);
freeMem(refText);
}
}
static void flyBaseInfoPrint(struct section *section,
struct sqlConnection *conn, char *geneId)
/* Print out FlyBase info. */
{
char *flyBaseId = getFlyBaseId(conn, geneId);
char query[256], **row;
struct sqlResult *sr;
struct fbAlleleInfo *alleleList = NULL, *allele;
struct hash *alleleHash = newHash(10);
struct fbRole *role = NULL;
safef(query, sizeof(query),
"select * from %s where geneId='%s'", section->flyBaseTable, flyBaseId);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
role = fbRoleLoad(row);
addToAllele(alleleHash, &alleleList, role->fbAllele, role);
}
sqlFreeResult(&sr);
slSort(&alleleList, fbAlleleInfoCmp);
for (allele = alleleList; allele != NULL; allele = allele->next)
{
char *alleleName = NULL;
if (allele->id != 0)
{
safef(query, sizeof(query),
"select name from fbAllele where id=%d", allele->id);
alleleName = sqlQuickString(conn, query);
if (alleleName != NULL)
hPrintf("Allele %s:
\n", alleleName);
}
if (allele->roleList != NULL)
{
hPrintf("