aab4f66a2aca5293f3536cc1d1438b17d2b09dfd
tdreszer
Thu May 5 16:14:15 2011 -0700
A large set of tiny changes. These fix a lot of discrepencies with bgcolor and font color declarations which were tripping up docttype 4.01.
diff --git src/hg/hgc/dbRIP.c src/hg/hgc/dbRIP.c
index 2ea0f70..9f050a4 100644
--- src/hg/hgc/dbRIP.c
+++ src/hg/hgc/dbRIP.c
@@ -1,226 +1,228 @@
/* Handle details pages for dbRIP tracks. */
#include "common.h"
#include "hash.h"
#include "linefile.h"
#include "hgc.h"
#include "hui.h"
#include "obscure.h"
#include "cheapcgi.h"
#include "htmshell.h"
#include "dbRIP.h"
#include "polyGenotype.h"
static char const rcsid[] = "$Id: dbRIP.c,v 1.9 2010/05/11 01:43:28 kent Exp $";
static int sortEthnicGroup(const void *e1, const void *e2)
/* used by slSort to sort the polyGenotype in order of ethnic group name */
{
const struct polyGenotype *p1 = *((struct polyGenotype**)e1);
const struct polyGenotype *p2 = *((struct polyGenotype**)e2);
return(strcmp(p1->ethnicGroup, p2->ethnicGroup));
}
static void polyTable(char *name)
{
struct sqlConnection *conn = hAllocConn(database);
char query[256];
struct sqlResult *sr;
char **row;
struct polyGenotype *pgList = NULL;
sprintf(query, "select * from polyGenotype where name = '%s'", name);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
struct polyGenotype *pg;
AllocVar(pg);
pg = polyGenotypeLoad(row);
slAddHead(&pgList, pg);
}
sqlFreeResult(&sr);
hFreeConn(&conn);
if (slCount(pgList) > 0)
{
struct polyGenotype *pg;
int totalPlusPlus = 0;
int totalPlusMinus = 0;
int totalMinusMinus = 0;
int totalSamples = 0;
double alleleFrequency = 0.0;
double unbiasedHeterozygosity = 0.0;
int sampleSize = 0;
int plusAlleles = 0;
int minusAlleles = 0;
slSort(&pgList,sortEthnicGroup);
printf("Polymorphism Frequencies and Genotypes:
\n");
/* This surrounding table avoids the problem of the border lines of
* the second table go missing. Something about the style sheet ...
*/
printf("
\n");
printf("\n");
printf("Ethnic Group | ");
printf("Sample Size | ");
printf("Allele Frequency | ");
printf("+/+ | ");
printf("+/- | ");
printf("-/- | ");
printf("Unbiased Heterozygosity | ");
printf(" \n");
for (pg = pgList; pg != NULL; pg = pg->next)
{
plusAlleles = (pg->plusPlus << 1) + pg->plusMinus;
minusAlleles = (pg->minusMinus << 1) + pg->plusMinus;
sampleSize = pg->plusPlus + pg->plusMinus + pg->minusMinus;
if ((plusAlleles + minusAlleles) > 0)
{
alleleFrequency = (double)plusAlleles /
(double)(plusAlleles + minusAlleles);
}
else
alleleFrequency = 0.0;
printf("%s | ", pg->ethnicGroup);
printf("%d | ", sampleSize);
printf("%.3f | ", alleleFrequency);
printf("%d | ", pg->plusPlus);
printf("%d | ", pg->plusMinus);
printf("%d | ", pg->minusMinus);
/* adjust by 2N/(2N-1) for small sample heterozygosity calculation
* http://www.genetics.org/cgi/content/abstract/89/3/583
* Masatoshi Nei (1978)
*/
if (sampleSize > 0)
{
unbiasedHeterozygosity=2*alleleFrequency*(1.0 - alleleFrequency);
unbiasedHeterozygosity *=
(double)(sampleSize << 1) / (double)((sampleSize << 1) - 1);
}
else
unbiasedHeterozygosity=2*alleleFrequency*(1.0 - alleleFrequency);
printf("%.3f | ", unbiasedHeterozygosity);
printf(" \n");
totalSamples += sampleSize;
totalPlusPlus += pg->plusPlus;
totalMinusMinus += pg->minusMinus;
totalPlusMinus += pg->plusMinus;
}
plusAlleles = (totalPlusPlus << 1) + totalPlusMinus;
minusAlleles = (totalMinusMinus << 1) + totalPlusMinus;
if ((plusAlleles + minusAlleles) > 0)
{
alleleFrequency = (double)plusAlleles /
(double)(plusAlleles + minusAlleles);
}
else
{
alleleFrequency = 0.0;
}
printf("All Samples | ");
printf("%d | ", totalSamples);
printf("%.3f | ", alleleFrequency);
printf("%d | ", totalPlusPlus);
printf("%d | ", totalPlusMinus);
printf("%d | ", totalMinusMinus);
if (totalSamples > 0)
{
unbiasedHeterozygosity = 2 * alleleFrequency * (1.0 - alleleFrequency);
unbiasedHeterozygosity *=
(double)(totalSamples << 1)/(double)((totalSamples << 1) - 1);
}
else
unbiasedHeterozygosity = 2 * alleleFrequency * (1.0 - alleleFrequency);
printf("%.3f | ", unbiasedHeterozygosity);
printf(" \n");
printf(" \n");
printf(" |
\n");
}
else
printf("Polymorphism Frequencies and Genotypes: NA
\n");
}
void dbRIP(struct trackDb *tdb, char *item, char *itemForUrl)
/* Put up dbRIP track info */
{
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr = NULL;
char table[64];
boolean hasBin;
struct dbRIP *loadItem;
struct dyString *query = newDyString(512);
char **row;
boolean firstTime = TRUE;
int start = cartInt(cart, "o");
int itemCount = 0;
genericHeader(tdb, item);
hFindSplitTable(database, seqName, tdb->table, table, &hasBin);
dyStringPrintf(query, "select * from %s where chrom = '%s' and ",
table, seqName);
hAddBinToQuery(winStart, winEnd, query);
dyStringPrintf(query, "name = '%s' and chromStart = %d", item, start);
sr = sqlGetResult(conn, query->string);
while ((row = sqlNextRow(sr)) != NULL)
{
if (firstTime)
firstTime = FALSE;
else
htmlHorizontalLine();
++itemCount;
loadItem = dbRIPLoad(row+hasBin);
printf("Database ID: %s
\n", loadItem->name);
printf("Original ID: %s
\n", loadItem->originalId);
printf("Class: %s
\n", loadItem->polyClass);
printf("Family: %s
\n", loadItem->polyFamily);
printf("Subfamily: %s
\n", loadItem->polySubfamily);
printf("Associated Disease: %s
\n", loadItem->disease);
printf("Sequence of L1 insertion and 400bp flanking on each side:");
- printf("(5' flanking-");
- printf("TSD1-REPEAT SEQUENCE");
- printf("-TSD2-3'");
- printf("flanking)
(\"nnnnn\"");
- printf(" --> unknown TSD; \"NNNNNNNNNN\" -->");
- printf(" unknown Repeat Sequence):
\n%s", loadItem->polySeq);
- printf("
\n");
+ printf("(5' flanking-"); // ' = '
+ printf("");
+ printf("TSD1-REPEAT SEQUENCE");
+ printf("-");
+ printf("TSD2-3' flanking)
"); // ' = '
+ printf("(\"nnnnn\"");
+ printf(" --> unknown TSD; \"NNNNNNNNNN\" -->");
+ printf(" unknown Repeat Sequence):
\n%s", loadItem->polySeq);
+ printf("
\n");
printf("Forward Primer: %s
\n", loadItem->forwardPrimer);
printf("Reverse Primer: %s
\n", loadItem->reversePrimer);
if (loadItem->tm > 0.0)
printf("Annealing Temperature: %.1f °C.
\n", loadItem->tm);
else
printf("Annealing Temperature: NA
\n");
if (loadItem->filledSize > 0)
printf("PCR Product Size (Filled): %d bp.
\n", loadItem->filledSize);
else
printf("PCR Product Size (Filled): NA
\n");
if (loadItem->emptySize > 0)
printf("PCR Product Size (Empty): %d bp.
\n", loadItem->emptySize);
else
printf("PCR Product Size (Empty): NA
\n");
printf("Ascertaining Method: %s
\n", loadItem->ascertainingMethod);
printf("Insertion found in reference sequence: %s
\n",
startsWith("UCSC",loadItem->polySource) ? "yes" : "no");
printf("Remarks: %s
\n", loadItem->remarks);
if (strlen(loadItem->genoRegion) > 0)
printf("Gene Context: %s
\n", loadItem->genoRegion);
else
printf("Gene Context: NA
\n");
polyTable(loadItem->name);
printPosOnChrom(loadItem->chrom, loadItem->chromStart, loadItem->chromEnd,
loadItem->strand, TRUE, loadItem->name);
printf("
\nReference(s): %s\n
\n", loadItem->reference);
}
sqlFreeResult(&sr);
hFreeConn(&conn);
printTrackHtml(tdb);
}