");
dnaSeqFree(&seq);
}
static int getEstTranscriptionDir(struct sqlConnection *conn, struct psl *psl)
/* get the direction of transcription for an EST; return splice support count */
{
char query[256], estOrient[64];
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select intronOrientation from %s.estOrientInfo where chrom = '%s' and chromStart = %d and name = '%s'",
database, psl->tName, psl->tStart, psl->qName);
if (sqlQuickQuery(conn, query, estOrient, sizeof(estOrient)) != NULL)
return sqlSigned(estOrient) * ((psl->strand[0] == '+') ? 1 : -1);
else
return 0;
}
static struct gbWarn *checkGbWarn(struct sqlConnection *conn, char *acc)
/* check if there is a gbWarn entry for this accession, return NULL if none */
{
struct gbWarn *gbWarn = NULL;
if (hTableExists(database, "gbWarn"))
gbWarn = sqlQueryObjs(conn, (sqlLoadFunc)gbWarnLoad, sqlQuerySingle,
"SELECT * FROM gbWarn WHERE acc = \"%s\"", acc);
@@ -5393,50 +5391,50 @@
struct gbWarn *gbWarn = checkGbWarn(conn, acc);
/* This sort of query and having to keep things in sync between
* the first clause of the select, the from clause, the where
* clause, and the results in the row ... is really tedious.
* One of my main motivations for going to a more object
* based rather than pure relational approach in general,
* and writing 'autoSql' to help support this. However
* the pure relational approach wins for pure search speed,
* and these RNA fields are searched. So it looks like
* the code below stays. Be really careful when you modify
* it.
*
* Uses the gbSeq table if available, otherwise use seq for older databases.
*/
-dyStringAppend(dy,
+sqlDyStringAppend(dy,
"select gbCdnaInfo.type,gbCdnaInfo.direction,"
"source.name,organism.name,library.name,mrnaClone.name,"
"sex.name,tissue.name,development.name,cell.name,cds.name,"
"description.name,author.name,geneName.name,productName.name,");
if (haveGbSeq)
dyStringAppend(dy,
"gbSeq.size,gbCdnaInfo.moddate,gbSeq.gbExtFile,gbSeq.file_offset,gbSeq.file_size ");
else
dyStringAppend(dy,
"seq.size,seq.gb_date,seq.extFile,seq.file_offset,seq.file_size ");
/* If the gbCdnaInfo table has a "version" column then will show it */
if (hasVersion)
{
dyStringAppend(dy,
", gbCdnaInfo.version ");
}
-dyStringPrintf(dy,
+sqlDyStringPrintf(dy,
" from gbCdnaInfo,%s,source,organism,library,mrnaClone,sex,tissue,"
"development,cell,cds,description,author,geneName,productName "
" where gbCdnaInfo.acc = '%s' and gbCdnaInfo.id = %s.id ",
seqTbl, acc, seqTbl);
dyStringAppend(dy,
"and gbCdnaInfo.source = source.id and gbCdnaInfo.organism = organism.id "
"and gbCdnaInfo.library = library.id and gbCdnaInfo.mrnaClone = mrnaClone.id "
"and gbCdnaInfo.sex = sex.id and gbCdnaInfo.tissue = tissue.id "
"and gbCdnaInfo.development = development.id and gbCdnaInfo.cell = cell.id "
"and gbCdnaInfo.cds = cds.id and gbCdnaInfo.description = description.id "
"and gbCdnaInfo.author = author.id and gbCdnaInfo.geneName = geneName.id "
"and gbCdnaInfo.productName = productName.id");
sr = sqlMustGetResult(conn, dy->string);
row = sqlNextRow(sr);
@@ -5495,31 +5493,31 @@
else
printf("unknown (can't guess from GenBank description) ");
}
else
printf("CDS: %s \n", cds);
printf("Date: %s \n", date);
if (hasVersion)
{
printf("Version: %s \n", version);
}
/* print RGD EST Report link if it is Rat genome and it has a link to RGD */
if (sameWord(organism, "Rat"))
{
if (hTableExists(database, "rgdEstLink"))
{
- snprintf(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select id from %s.rgdEstLink where name = '%s';", database, acc);
if (sqlQuickQuery(conn2, query, rgdEstId, sizeof(rgdEstId)) != NULL)
{
tdbRgdEst = hashFindVal(trackHash, "rgdEst");
printf("RGD EST Report: ");
printf("", tdbRgdEst->url, rgdEstId);
printf("RGD:%s
\n", rgdEstId);
}
}
}
if (isEst && hTableExists(database, "estOrientInfo") && (psl != NULL))
{
int estOrient = getEstTranscriptionDir(conn2, psl);
if (estOrient != 0)
printf("EST transcribed from %c strand (supported by %d splice sites). \n",
@@ -5630,55 +5628,55 @@
}
}
}
struct psl *getAlignments(struct sqlConnection *conn, char *table, char *acc)
/* get the list of alignments for the specified acc */
{
struct sqlResult *sr = NULL;
char **row;
struct psl *psl, *pslList = NULL;
boolean hasBin;
char splitTable[64];
char query[256];
if (!hFindSplitTable(database, seqName, table, splitTable, &hasBin))
errAbort("can't find table %s or %s_%s", table, seqName, table);
-safef(query, sizeof(query), "select * from %s where qName = '%s'", splitTable, acc);
+sqlSafef(query, sizeof(query), "select * from %s where qName = '%s'", splitTable, acc);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
psl = pslLoad(row+hasBin);
slAddHead(&pslList, psl);
}
sqlFreeResult(&sr);
slReverse(&pslList);
return pslList;
}
struct psl *loadPslRangeT(char *table, char *qName, char *tName, int tStart, int tEnd)
/* Load a list of psls given qName tName tStart tEnd */
{
struct sqlResult *sr = NULL;
char **row;
struct psl *psl = NULL, *pslList = NULL;
boolean hasBin;
char splitTable[64];
char query[256];
struct sqlConnection *conn = hAllocConn(database);
hFindSplitTable(database, seqName, table, splitTable, &hasBin);
-safef(query, sizeof(query), "select * from %s where qName = '%s' and tName = '%s' and tEnd > %d and tStart < %d", splitTable, qName, tName, tStart, tEnd);
+sqlSafef(query, sizeof(query), "select * from %s where qName = '%s' and tName = '%s' and tEnd > %d and tStart < %d", splitTable, qName, tName, tStart, tEnd);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
psl = pslLoad(row+hasBin);
slAddHead(&pslList, psl);
}
sqlFreeResult(&sr);
slReverse(&pslList);
hFreeConn(&conn);
return pslList;
}
void doHgRna(struct trackDb *tdb, char *acc)
/* Click on an individual RNA. */
{
@@ -5814,31 +5812,31 @@
struct sqlConnection *conn = hAllocConn(database);
struct sqlConnection *conn2 = hAllocConn(database);
if (itemForUrl == NULL)
itemForUrl = item;
dupe = cloneString(tdb->type);
genericHeader(tdb, item);
wordCount = chopLine(dupe, words);
printCustomUrl(tdb, itemForUrl, item == itemForUrl);
/* If this is the affyZebrafish track, check for human ortholog information */
if (sameString("affyZebrafish", tdb->table))
{
if (orthoTable != NULL && hTableExists(database, orthoTable))
{
- safef(query, sizeof(query), "select geneSymbol, description from %s where name = '%s' ", orthoTable, item);
+ sqlSafef(query, sizeof(query), "select geneSymbol, description from %s where name = '%s' ", orthoTable, item);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
printf("\n
\n");
printf("
Human %s Ortholog:
%s
\n", otherDb, row[0]);
printf("
Ortholog Description:
%s
\n",row[1]);
printf("
\n");
}
}
}
if (wordCount > 0)
{
type = words[0];
@@ -5867,31 +5865,31 @@
int wordCount;
int start = cartInt(cart, "o");
struct sqlConnection *conn = hAllocConn(database);
struct sqlConnection *conn1 = hAllocConn(database);
boolean rhMapInfoExists = sqlTableExists(conn, "rhMapZfishInfo");
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
genericHeader(tdb, itemName);
/* Print out RH map information if available */
if (rhMapInfoExists)
{
- sprintf(query, "SELECT * FROM rhMapZfishInfo WHERE name = '%s'", itemName);
+ sqlSafef(query, sizeof query, "SELECT * FROM rhMapZfishInfo WHERE name = '%s'", itemName);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
rhInfo = rhMapZfishInfoLoad(row);
if (rhInfo != NULL)
{
printf("
Information on %s
\n", itemName);
if (!sameString(rhInfo->zfinId, ""))
{
printf("
");
/* print position info */
printPosOnChrom(chrom, start, end, strand, TRUE, itemName);
/* print UCSC Genes in the reported region */
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select distinct t.name from knownCanonToDecipher t, kgXref x where value ='%s' and x.kgId=t.name order by geneSymbol", itemName);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
printf(" UCSC Canonical Gene(s) in this genomic region:
");
while (row != NULL)
{
- safef(query2, sizeof(query2),
+ sqlSafef(query2, sizeof(query2),
"select geneSymbol, kgId, description from kgXref where kgId ='%s'", row[0]);
sr2 = sqlMustGetResult(conn2, query2);
row2 = sqlNextRow(sr2);
if (row2 != NULL)
{
printf("
%s", disorder);
@@ -9807,91 +9805,91 @@
}
else
{
// show phenotype class if available, even phenotypeId is not available
if (!sameWord(phenotypeClass, "-1")) printf(" (%s)", phenotypeClass);
}
}
printf(" \n");
}
if (disorderShown) printf("
\n");
sqlFreeResult(&sr);
}
// show RefSeq Gene link(s)
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select distinct locusLinkId from refLink l, omim2gene g, refGene r where l.omimId=%s and g.geneId=l.locusLinkId and g.entryType='gene' and chrom='%s' and txStart = %s and txEnd= %s",
itemName, chrom, chromStart, chromEnd);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
char *geneId;
geneId = strdup(row[0]);
sqlFreeResult(&sr);
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select distinct l.mrnaAcc from refLink l where locusLinkId = '%s' order by mrnaAcc asc", geneId);
sr = sqlMustGetResult(conn, query);
if (sr != NULL)
{
int printedCnt;
printedCnt = 0;
while ((row = sqlNextRow(sr)) != NULL)
{
if (printedCnt < 1)
printf("RefSeq Gene(s): ");
else
printf(", ");
printf("", "../cgi-bin/hgc?g=refGene&i=",
row[0], chromStart, chromEnd);
printf("%s", row[0]);
printedCnt++;
}
if (printedCnt >= 1) printf(" \n");
}
sqlFreeResult(&sr);
}
// show Related UCSC Gene links
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select distinct kgId from kgXref x, refLink l, omim2gene g where x.refseq = mrnaAcc and l.omimId=%s and g.omimId=l.omimId and g.entryType='gene'",
itemName);
sr = sqlMustGetResult(conn, query);
if (sr != NULL)
{
int printedCnt;
printedCnt = 0;
while ((row = sqlNextRow(sr)) != NULL)
{
if (printedCnt < 1)
printf("Related UCSC Gene(s): ");
else
printf(", ");
printf("", "../cgi-bin/hgGene?hgg_gene=", row[0]);
printf("%s", row[0]);
printedCnt++;
}
if (printedCnt >= 1) printf(" \n");
}
sqlFreeResult(&sr);
// show GeneReviews link(s)
- if (sqlTablesExist(conn, "geneReviewsRefGene"))
+ if (sqlTableExists(conn, "geneReviewsRefGene"))
{
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select distinct r.name2 from refLink l, omim2gene g, refGene r where l.omimId=%s and g.geneId=l.locusLinkId and g.entryType='gene' and chrom='%s' and txStart = %s and txEnd= %s",
itemName, chrom, chromStart, chromEnd);
sr = sqlMustGetResult(conn, query);
if (sr != NULL)
{
while ((row = sqlNextRow(sr)) != NULL)
{
prGRShortRefGene(row[0]);
}
}
sqlFreeResult(&sr);
}
}
@@ -9916,186 +9914,186 @@
char *kgDescription = NULL;
char *refSeq;
char *omimId;
chrom = cartOptionalString(cart, "c");
chromStart = cartOptionalString(cart, "o");
chromEnd = cartOptionalString(cart, "t");
omimId = itemName;
if (url != NULL && url[0] != 0)
{
printf("OMIM: ");
printf("", url, itemName);
printf("%s", itemName);
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select title1, title2 from omimGeneMap where omimId=%s;", itemName);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
if (row[0] != NULL)
{
title1 = cloneString(row[0]);
printf(": %s", title1);
}
if (row[1] != NULL)
{
title2 = cloneString(row[1]);
printf(" %s ", title2);
}
}
sqlFreeResult(&sr);
printf(" ");
// disable NCBI link until they work it out with OMIM
/*
printf("OMIM page at NCBI: ");
printf("", ncbiOmimUrl, itemName);
printf("%s ", itemName);
*/
printf("Location: ");
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select location from omimGeneMap where omimId=%s;", itemName);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
if (row[0] != NULL)
{
char *locStr;
locStr= cloneString(row[0]);
printf("%s\n", locStr);
}
}
sqlFreeResult(&sr);
printf(" \n");
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select geneSymbol from omimGeneMap where omimId=%s;", itemName);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
geneSymbol = cloneString(row[0]);
}
sqlFreeResult(&sr);
- safef(query, sizeof(query),"select omimId from omimPhenotype where omimId=%s\n", omimId);
+ sqlSafef(query, sizeof(query),"select omimId from omimPhenotype where omimId=%s\n", omimId);
if (sqlQuickNum(conn, query) > 0)
{
char *phenotypeClass, *phenotypeId, *disorder;
printf("Gene symbol(s): %s", geneSymbol);
printf(" \n");
/* display disorder for genes in morbidmap */
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select description, %s, phenotypeId from omimPhenotype where omimId=%s order by description",
omimPhenotypeClassColName, itemName);
sr = sqlMustGetResult(conn, query);
printf("Disorder(s):
\n");
-sprintf(query, "select * from %s where qName = '%s'", table, itemName);
+sqlSafef(query, sizeof query, "select * from %s where qName = '%s'", table, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
psl = pslLoad(row + hasBin);
slAddHead(&pslList, psl);
}
sqlFreeResult(&sr);
slReverse(&pslList);
printAlignments(pslList, start, "htcCdnaAli", tdb->table, itemName);
printTrackHtml(tdb);
}
void doEst3(char *itemName)
/* Handle click on EST 3' end track. */
{
struct est3 el;
int start = cartInt(cart, "o");
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset;
cartWebStart(cart, database, "EST 3' Ends");
printf("
EST 3' Ends
\n");
rowOffset = hOffsetPastBin(database, seqName, "est3");
-sprintf(query, "select * from est3 where chrom = '%s' and chromStart = %d",
+sqlSafef(query, sizeof query, "select * from est3 where chrom = '%s' and chromStart = %d",
seqName, start);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
est3StaticLoad(row+rowOffset, &el);
printf("EST 3' End Count: %d \n", el.estCount);
bedPrintPos((struct bed *)&el, 3, NULL);
printf("strand: %s \n", el.strand);
htmlHorizontalLine();
}
puts("
This track shows where clusters of EST 3' ends hit the "
"genome. In many cases these represent the 3' ends of genes. "
"This data was kindly provided by Lukas Wagner and Greg Schuler "
"at NCBI. Additional filtering was applied by Jim Kent.
");
@@ -13436,31 +13437,31 @@
void doEncodeRna(struct trackDb *tdb, char *itemName)
/* Handle click on encodeRna track. */
{
struct encodeRna rna;
int start = cartInt(cart, "o");
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset;
struct slName *nameList, *sl;
genericHeader(tdb, itemName);
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
-sprintf(query, "select * from %s where chrom = '%s' and chromStart = %d and name = '%s'",
+sqlSafef(query, sizeof query, "select * from %s where chrom = '%s' and chromStart = %d and name = '%s'",
tdb->table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
encodeRnaStaticLoad(row + rowOffset, &rna);
printf("name: %s \n", rna.name);
bedPrintPos((struct bed *)&rna, 3, tdb);
printf("strand: %s \n", rna.strand);
printf("type: %s \n", rna.type);
printf("score: %2.1f
\n", rna.fullScore);
printf("is pseudo-gene: %s \n", (rna.isPsuedo ? "yes" : "no"));
printf("is Repeatmasked: %s \n", (rna.isRmasked ? "yes" : "no"));
printf("is Transcribed: %s \n", (rna.isTranscribed ? "yes" : "no"));
printf("is an evoFold prediction: %s \n", (rna.isPrediction ? "yes" : "no"));
printf("program predicted with: %s \n", rna.source);
@@ -13479,31 +13480,31 @@
void doRnaGene(struct trackDb *tdb, char *itemName)
/* Handle click on RNA Genes track. */
{
struct rnaGene rna;
int start = cartInt(cart, "o");
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset;
genericHeader(tdb, itemName);
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
-sprintf(query, "select * from %s where chrom = '%s' and chromStart = %d and name = '%s'",
+sqlSafef(query, sizeof query, "select * from %s where chrom = '%s' and chromStart = %d and name = '%s'",
tdb->table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
rnaGeneStaticLoad(row + rowOffset, &rna);
printf("name: %s \n", rna.name);
printf("type: %s \n", rna.type);
printf("score: %2.1f \n", rna.fullScore);
printf("is pseudo-gene: %s \n", (rna.isPsuedo ? "yes" : "no"));
printf("program predicted with: %s \n", rna.source);
printf("strand: %s \n", rna.strand);
bedPrintPos((struct bed *)&rna, 3, tdb);
htmlHorizontalLine();
}
printTrackHtml(tdb);
@@ -13533,72 +13534,72 @@
int i;
struct psl *pslList = NULL, *psl;
int pslStart;
char *sqlMarker = marker;
boolean hasBin;
/* Make sure to escpae single quotes for DB parseability */
if (strchr(marker, '\''))
sqlMarker = replaceChars(marker, "'", "''");
/* Print out non-sequence info */
sprintf(title, "STS Marker %s", marker);
cartWebStart(cart, database, "%s", title);
/* Find the instance of the object in the bed table */
-sprintf(query, "SELECT * FROM %s WHERE name = '%s' "
+sqlSafef(query, sizeof query, "SELECT * FROM %s WHERE name = '%s' "
"AND chrom = '%s' AND chromStart = %d "
"AND chromEnd = %d",
table, sqlMarker, seqName, start, end);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
hasBin = hOffsetPastBin(database, seqName, table);
if (row != NULL)
{
if (stsMapExists)
stsMapStaticLoad(row+hasBin, &stsRow);
else
/* Load and convert from original bed format */
{
struct stsMarker oldStsRow;
stsMarkerStaticLoad(row+hasBin, &oldStsRow);
stsMapFromStsMarker(&oldStsRow, &stsRow);
}
if (stsInfo2Exists)
{
/* Find the instance of the object in the stsInfo2 table */
sqlFreeResult(&sr);
- sprintf(query, "SELECT * FROM stsInfo2 WHERE identNo = '%d'", stsRow.identNo);
+ sqlSafef(query, sizeof query, "SELECT * FROM stsInfo2 WHERE identNo = '%d'", stsRow.identNo);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
int i;
char **cl;
cl = (char **)needMem(52*sizeof(char *));
for (i = 0; i < 52; ++i)
cl[i] = cloneString(row[i]);
info2Row = stsInfo2Load(row);
infoRow = stsInfoLoad(cl);
freeMem(cl);
}
}
else if (stsInfoExists)
{
/* Find the instance of the object in the stsInfo table */
sqlFreeResult(&sr);
- sprintf(query, "SELECT * FROM stsInfo WHERE identNo = '%d'", stsRow.identNo);
+ sqlSafef(query, sizeof query, "SELECT * FROM stsInfo WHERE identNo = '%d'", stsRow.identNo);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
infoRow = stsInfoLoad(row);
}
if (((stsInfo2Exists) || (stsInfoExists)) && (row != NULL))
{
printf("
\n");
htmlHorizontalLine();
if (stsRow.score == 1000)
printf("
This is the only location found for %s
\n",marker);
else
{
sqlFreeResult(&sr);
printf("
Other locations found for %s in the genome:
\n", marker);
printf("
\n");
- sprintf(query, "SELECT * FROM %s WHERE name = '%s' "
+ sqlSafef(query, sizeof query, "SELECT * FROM %s WHERE name = '%s' "
"AND (chrom != '%s' OR chromStart != %d OR chromEnd != %d)",
table, marker, seqName, start, end);
sr = sqlGetResult(conn,query);
hasBin = hOffsetPastBin(database, seqName, table);
while ((row = sqlNextRow(sr)) != NULL)
{
if (stsMapExists)
stsMapStaticLoad(row+hasBin, &stsRow);
else
/* Load and convert from original bed format */
{
struct stsMarker oldStsRow;
stsMarkerStaticLoad(row+hasBin, &oldStsRow);
stsMapFromStsMarker(&oldStsRow, &stsRow);
}
@@ -13854,42 +13855,42 @@
int start = cartInt(cart, "o");
int end = cartInt(cart, "t");
int hgsid = cartSessionId(cart);
struct stsMapMouse stsRow;
struct stsInfoMouse *infoRow;
char stsid[20];
int i;
struct psl *pslList = NULL, *psl;
int pslStart;
/* Print out non-sequence info */
sprintf(title, "STS Marker %s", marker);
cartWebStart(cart, database, "%s", title);
/* Find the instance of the object in the bed table */
-sprintf(query, "SELECT * FROM %s WHERE name = '%s' "
+sqlSafef(query, sizeof query, "SELECT * FROM %s WHERE name = '%s' "
"AND chrom = '%s' AND chromStart = %d "
"AND chromEnd = %d",
table, marker, seqName, start, end);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
stsMapMouseStaticLoad(row, &stsRow);
/* Find the instance of the object in the stsInfo table */
sqlFreeResult(&sr);
- sprintf(query, "SELECT * FROM stsInfoMouse WHERE identNo = '%d'", stsRow.identNo);
+ sqlSafef(query, sizeof query, "SELECT * FROM stsInfoMouse WHERE identNo = '%d'", stsRow.identNo);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
infoRow = stsInfoMouseLoad(row);
printf("
\n", tdb->longLabel);
-sprintf(query, "select * from %s where chrom = '%s' and chromStart = %d",
+sqlSafef(query, sizeof query, "select * from %s where chrom = '%s' and chromStart = %d",
tdb->table, seqName, start);
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
htmlHorizontalLine();
ensPhusionBlastStaticLoad(row+rowOffset, &el);
elname = cloneString(el.name);
if ((ptr = strchr(elname, '.')) != NULL)
{
*ptr = 0;
xenoChrom = ptr+1;
xenoDb = elname;
xenoOrg = hOrganism(xenoDb);
}
@@ -14834,39 +14835,39 @@
char *validateOrGetRsId(char *name, struct sqlConnection *conn)
/* If necessary, get the rsId from the affy120K or affy10K table,
given the affyId. rsId is more common, affy120K is next, affy10K least.
* returns "valid" if name is already a valid rsId,
new rsId if it is found in the affy tables, or
0 if no valid rsId is found */
{
char *rsId = cloneString(name);
struct affy120KDetails *a120K = NULL;
struct affy10KDetails *a10K = NULL;
char query[512];
if (strncmp(rsId,"rs",2)) /* is not a valid rsId, so it must be an affyId */
{
- safef(query, sizeof(query), /* more likely to be affy120K, so check first */
+ sqlSafef(query, sizeof(query), /* more likely to be affy120K, so check first */
"select * from affy120KDetails where affyId = '%s'", name);
a120K = affy120KDetailsLoadByQuery(conn, query);
if (a120K != NULL) /* found affy120K record */
rsId = cloneString(a120K->rsId);
affy120KDetailsFree(&a120K);
if (strncmp(rsId,"rs",2)) /* not a valid affy120K snp, might be affy10K */
{
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select * from affy10KDetails where affyId = '%s'", name);
a10K = affy10KDetailsLoadByQuery(conn, query);
if (a10K != NULL) /* found affy10K record */
rsId = cloneString(a10K->rsId);
affy10KDetailsFree(&a10K);
if (strncmp(rsId,"rs",2)) /* not valid affy10K snp */
return 0;
}
/* not all affy snps have valid rsIds, so return if it is invalid */
if (strncmp(rsId,"rs",2) || strlen(rsId)<4 || sameString(rsId,"rs0")) /* not a valid rsId */
return 0;
}
else
rsId = cloneString("valid");
return rsId;
@@ -14879,36 +14880,36 @@
0 if no valid rsId is found */
{
struct sqlConnection *hgFixed = sqlConnect("hgFixed");
char *rsId = validateOrGetRsId(name, hgFixed);
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[512];
struct dbSnpRs *snp = NULL;
char *dbOrg = cloneStringZ(database,2);
toUpperN(dbOrg,1); /* capitalize first letter */
if (rsId) /* a valid rsId exists */
{
if (sameString(rsId, "valid"))
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select * "
"from dbSnpRs%s "
"where rsId = '%s'", dbOrg, name);
else
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select * "
"from dbSnpRs%s "
"where rsId = '%s'", dbOrg, rsId);
snp = dbSnpRsLoadByQuery(hgFixed, query);
if (snp != NULL)
{
printf(" \n");
if(snp->avHetSE>0)
{
printf("");
printf("Average Heterozygosity: %f \n",snp->avHet);
printf("");
printf("Standard Error of Avg. Het.: %f \n", snp->avHetSE);
}
else
@@ -14930,58 +14931,58 @@
snp->valid);
// printf("Validation Status:%s \n",
// snp->valid);
printf("Allele1: %s \n",
snp->allele1);
printf("Allele2: %s \n",
snp->allele2);
printf("Sequence in Assembly: %s \n", snp->assembly);
printf("Alternate Sequence: %s \n", snp->alternate);
}
dbSnpRsFree(&snp);
}
sqlDisconnect(&hgFixed);
if (sameString(dbOrg,"Hg"))
{
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select source, type from snpMap where name = '%s'", name);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
printf("Variant Source: %s \n",row[0]);
printf("Variant Type: %s\n",row[1]);
}
sqlFreeResult(&sr);
hFreeConn(&conn);
}
return rsId;
}
void doSnpEntrezGeneLink(struct trackDb *tdb, char *name)
/* print link to EntrezGene for this SNP */
{
char *table = tdb->table;
if (hTableExists(database, "knownGene") && hTableExists(database, "refLink") &&
hTableExists(database, "mrnaRefseq") && hTableExists(database, table))
{
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[512];
int rowOffset;
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select distinct "
" rl.locusLinkID, "
" rl.name "
"from knownGene kg, "
" refLink rl, "
" %s snp, "
" mrnaRefseq mrs "
"where snp.chrom = kg.chrom "
" and kg.name = mrs.mrna "
" and mrs.refSeq = rl.mrnaAcc "
" and kg.txStart < snp.chromStart "
" and kg.txEnd > snp.chromEnd "
" and snp.name = '%s'", table, name);
rowOffset = hOffsetPastBin(database, seqName, table);
sr = sqlGetResult(conn, query);
@@ -15000,31 +15001,31 @@
/* Put up info on a SNP. */
{
char *snpTable = tdb->table;
struct snp snp;
struct snpMap snpMap;
int start = cartInt(cart, "o");
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset;
char *printId;
cartWebStart(cart, database, "Simple Nucleotide Polymorphism (SNP)");
printf("
Simple Nucleotide Polymorphism (SNP) %s
\n", itemName);
-sprintf(query,
+sqlSafef(query, sizeof query,
"select * "
"from %s "
"where chrom = '%s' "
" and chromStart = %d "
" and name = '%s'",
snpTable, seqName, start, itemName);
rowOffset = hOffsetPastBin(database, seqName, snpTable);
sr = sqlGetResult(conn, query);
if (sameString(snpTable,"snpMap"))
while ((row = sqlNextRow(sr)) != NULL)
{
snpMapStaticLoad(row+rowOffset, &snpMap);
bedPrintPos((struct bed *)&snpMap, 3, tdb);
}
else
@@ -15078,46 +15079,46 @@
tokens=cloneString(exceptionList);
lf=lineFileOnString("snpExceptions", TRUE, tokens);
tkz=tokenizerOnLineFile(lf);
while ((id=tokenizerNext(tkz))!=NULL)
{
if (firstException)
{
printf(" Note(s): \n",noteColor);
firstException=FALSE;
}
if (sameString(id,",")) /* is there a tokenizer that doesn't return separators? */
continue;
if (sameString(id,"18")||sameString(id,"19")||sameString(id,"20"))
multiplePositions=TRUE;
br=cloneString(" ");
- safef(query, sizeof(query), "select * from snpExceptions where exceptionId = %s", id);
+ sqlSafef(query, sizeof(query), "select * from snpExceptions where exceptionId = %s", id);
sr = sqlGetResult(conn, query);
/* exceptionId is a primary key; at most 1 record returned */
while ((row = sqlNextRow(sr))!=NULL)
{
snpExceptionsStaticLoad(row, &se);
printf(" %s \n",
noteColor,se.description);
}
}
printf("%s\n",br);
if (multiplePositions)
{
struct snp snp;
printf("Other Positions:
");
- safef(query, sizeof(query), "select * from snp where name='%s'", itemName);
+ sqlSafef(query, sizeof(query), "select * from snp where name='%s'", itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr))!=NULL)
{
snpStaticLoad(row+rowOffset, &snp);
if (differentString(chrom,snp.chrom) || chromStart!=snp.chromStart)
{
bedPrintPos((struct bed *)&snp, 3, tdb);
printf(" \n");
}
}
}
}
void printSnpInfo(struct snp snp)
/* print info on a snp */
@@ -15151,31 +15152,31 @@
if (hTableExists(database, snpSeqSetting))
safecpy(snpSeqTable, sizeof(snpSeqTable), snpSeqSetting);
else
return -1;
}
else
{
safef(snpSeqTable, sizeof(snpSeqTable), "%sSeq", tdb->table);
if (!hTableExists(database, snpSeqTable))
{
safecpy(snpSeqTable, sizeof(snpSeqTable), "snpSeq");
if (!hTableExists(database, snpSeqTable))
return -1;
}
}
-safef(query, sizeof(query), "select file_offset from %s where acc='%s'",
+sqlSafef(query, sizeof(query), "select file_offset from %s where acc='%s'",
snpSeqTable, snp->name);
sr = sqlGetResult(conn, query);
row = sqlNextRow(sr);
if (row == NULL)
return -1;
offset = sqlLongLong(row[0]);
sqlFreeResult(&sr);
hFreeConn(&conn);
return offset;
}
char *getSnpSeqFile(struct trackDb *tdb)
/* find location of snp.fa and test existence. */
{
@@ -15521,31 +15522,31 @@
char *snpTable = tdb->table;
struct snp snp;
int start = cartInt(cart, "o");
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset=hOffsetPastBin(database, seqName, snpTable);
int firstOne=1;
char *exception=0;
char *chrom="";
int chromStart=0;
cartWebStart(cart, database, "Simple Nucleotide Polymorphism (SNP)");
printf("
Simple Nucleotide Polymorphism (SNP) %s
\n", itemName);
-safef(query, sizeof(query), "select * from %s where chrom='%s' and "
+sqlSafef(query, sizeof(query), "select * from %s where chrom='%s' and "
"chromStart=%d and name='%s'", snpTable, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr))!=NULL)
{
snpStaticLoad(row+rowOffset, &snp);
if (firstOne)
{
exception=cloneString(snp.exception);
chrom = cloneString(snp.chrom);
chromStart = snp.chromStart;
bedPrintPos((struct bed *)&snp, 3, tdb);
printf(" \n");
firstOne=0;
}
printSnpInfo(snp);
@@ -15557,31 +15558,31 @@
doSnpEntrezGeneLink(tdb, itemName);
}
if (hTableExists(database, "snpExceptions") && differentString(exception,"0"))
writeSnpException(exception, itemName, rowOffset, chrom, chromStart, tdb);
printTrackHtml(tdb);
sqlFreeResult(&sr);
hFreeConn(&conn);
}
void doAffy120KDetails(struct trackDb *tdb, char *name)
/* print additional SNP details */
{
struct sqlConnection *conn = sqlConnect("hgFixed");
char query[1024];
struct affy120KDetails *snp = NULL;
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select affyId, rsId, baseA, baseB, sequenceA, sequenceB, "
" enzyme, minFreq, hetzyg, avHetSE, "
" NA04477, NA04479, NA04846, NA11036, NA11038, NA13056, "
" NA17011, NA17012, NA17013, NA17014, NA17015, NA17016, "
" NA17101, NA17102, NA17103, NA17104, NA17105, NA17106, "
" NA17201, NA17202, NA17203, NA17204, NA17205, NA17206, "
" NA17207, NA17208, NA17210, NA17211, NA17212, NA17213, "
" PD01, PD02, PD03, PD04, PD05, PD06, PD07, PD08, "
" PD09, PD10, PD11, PD12, PD13, PD14, PD15, PD16, "
" PD17, PD18, PD19, PD20, PD21, PD22, PD23, PD24 "
"from affy120KDetails "
"where affyId = %s", name);
snp = affy120KDetailsLoadByQuery(conn, query);
if (snp!=NULL)
{
@@ -15669,92 +15670,92 @@
void doCnpLocke(struct trackDb *tdb, char *itemName)
{
char *table = tdb->table;
struct cnpLocke thisItem;
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset = hOffsetPastBin(database, seqName, table);
int start = cartInt(cart, "o");
genericHeader(tdb, itemName);
printf("NCBI Clone Registry: %s \n", itemName);
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where chrom = '%s' and "
"chromStart=%d and name = '%s'", table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
cnpLockeStaticLoad(row+rowOffset, &thisItem);
bedPrintPos((struct bed *)&thisItem, 3, tdb);
printf(" Variation Type: %s\n",thisItem.variationType);
}
printTrackHtml(tdb);
sqlFreeResult(&sr);
hFreeConn(&conn);
}
void doCnpIafrate(struct trackDb *tdb, char *itemName)
{
char *table = tdb->table;
struct cnpIafrate cnpIafrate;
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset = hOffsetPastBin(database, seqName, table);
int start = cartInt(cart, "o");
genericHeader(tdb, itemName);
printf("NCBI Clone Registry: %s \n", itemName);
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where chrom = '%s' and "
"chromStart=%d and name = '%s'", table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
cnpIafrateStaticLoad(row+rowOffset, &cnpIafrate);
bedPrintPos((struct bed *)&cnpIafrate, 3, tdb);
printf(" Variation Type: %s\n",cnpIafrate.variationType);
printf(" Score: %g\n",cnpIafrate.score);
}
printTrackHtml(tdb);
sqlFreeResult(&sr);
hFreeConn(&conn);
}
void doCnpIafrate2(struct trackDb *tdb, char *itemName)
{
char *table = tdb->table;
struct cnpIafrate2 thisItem;
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset = hOffsetPastBin(database, seqName, table);
int start = cartInt(cart, "o");
genericHeader(tdb, itemName);
printf("NCBI Clone Registry: %s \n", itemName);
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where chrom = '%s' and "
"chromStart=%d and name = '%s'", table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
cnpIafrate2StaticLoad(row+rowOffset, &thisItem);
bedPrintPos((struct bed *)&thisItem, 3, tdb);
printf(" Cohort Type: %s\n",thisItem.cohortType);
if (strstr(thisItem.cohortType, "Control"))
{
printf(" Control Gain Count: %d\n",thisItem.normalGain);
printf(" Control Loss Count: %d\n",thisItem.normalLoss);
}
if (strstr(thisItem.cohortType, "Patient"))
{
@@ -15767,115 +15768,115 @@
hFreeConn(&conn);
}
void doDelHinds2(struct trackDb *tdb, char *itemName)
{
char *table = tdb->table;
struct delHinds2 thisItem;
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset = hOffsetPastBin(database, seqName, table);
int start = cartInt(cart, "o");
genericHeader(tdb, itemName);
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where chrom = '%s' and "
"chromStart=%d and name = '%s'", table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
delHinds2StaticLoad(row+rowOffset, &thisItem);
bedPrintPos((struct bed *)&thisItem, 3, tdb);
printf(" Frequency: %3.2f%%\n",thisItem.frequency);
}
printTrackHtml(tdb);
sqlFreeResult(&sr);
hFreeConn(&conn);
}
void doDelConrad2(struct trackDb *tdb, char *itemName)
{
char *table = tdb->table;
struct delConrad2 thisItem;
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset = hOffsetPastBin(database, seqName, table);
int start = cartInt(cart, "o");
genericHeader(tdb, itemName);
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where chrom = '%s' and "
"chromStart=%d and name = '%s'", table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
delConrad2StaticLoad(row+rowOffset, &thisItem);
bedPrintPos((struct bed *)&thisItem, 3, tdb);
printf(" HapMap individual: %s\n",thisItem.offspring);
printf(" HapMap population: %s\n",thisItem.population);
}
printTrackHtml(tdb);
sqlFreeResult(&sr);
hFreeConn(&conn);
}
void doCnpSebat(struct trackDb *tdb, char *itemName)
{
char *table = tdb->table;
struct cnpSebat cnpSebat;
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset = hOffsetPastBin(database, seqName, table);
int start = cartInt(cart, "o");
genericHeader(tdb, itemName);
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where chrom = '%s' and "
"chromStart=%d and name = '%s'", table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
cnpSebatStaticLoad(row+rowOffset, &cnpSebat);
bedPrintPos((struct bed *)&cnpSebat, 3, tdb);
printf(" Number of probes: %d\n",cnpSebat.probes);
printf(" Number of individuals: %d\n",cnpSebat.individuals);
}
printTrackHtml(tdb);
sqlFreeResult(&sr);
hFreeConn(&conn);
}
void doCnpSebat2(struct trackDb *tdb, char *itemName)
{
char *table = tdb->table;
struct cnpSebat2 cnpSebat2;
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset = hOffsetPastBin(database, seqName, table);
int start = cartInt(cart, "o");
genericHeader(tdb, itemName);
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where chrom = '%s' and "
"chromStart=%d and name = '%s'", table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
cnpSebat2StaticLoad(row+rowOffset, &cnpSebat2);
bedPrintPos((struct bed *)&cnpSebat2, 3, tdb);
printf(" Number of probes: %d\n",cnpSebat2.probes);
}
printTrackHtml(tdb);
sqlFreeResult(&sr);
hFreeConn(&conn);
}
@@ -15892,37 +15893,37 @@
printf("LTR Percent: %.1f %% \n", cnpSharp.LTRpercent*100);
printf("DNA Percent: %.1f %% \n", cnpSharp.DNApercent*100);
printf("Disease Percent: %.1f %% \n", cnpSharp.diseaseSpotsPercent*100);
}
void printCnpSharpSampleData(char *itemName)
{
struct sqlConnection *hgFixed1 = sqlConnect("hgFixed");
struct sqlConnection *hgFixed2 = sqlConnect("hgFixed");
char query[256], query2[1024];
char **row;
struct sqlResult *sr1, *sr2;
float sample, cutoff;
printf(" \n");
-safef(query, sizeof(query), "select distinct substring(sample,1,5) from cnpSharpCutoff order by sample");
+sqlSafef(query, sizeof(query), "select distinct substring(sample,1,5) from cnpSharpCutoff order by sample");
sr1 = sqlGetResult(hgFixed1, query);
while ((row = sqlNextRow(sr1)) != NULL)
{
char *pop=row[0];
printf("
");
- safef(query2, sizeof(query2),
+ sqlSafef(query2, sizeof(query2),
"select s1.sample, s1.gender, s1.value, c1.value, s2.value, c2.value "
"from cnpSharpSample s1, cnpSharpSample s2, cnpSharpCutoff c1, cnpSharpCutoff c2 "
"where s1.sample=s2.sample and s1.sample=c1.sample and s1.sample=c2.sample "
" and s1.batch=1 and s2.batch=2 and c1.batch=1 and c2.batch=2 and s1.bac='%s' "
" and s1.bac=s2.bac and s1.sample like '%s%%' order by s1.sample", itemName, pop);
sr2 = sqlGetResult(hgFixed2, query2);
while ((row = sqlNextRow(sr2)) != NULL)
{
if (sameString(row[1],"M")) printf("
");
else printf("
");
printf("%s
\n",row[0]);
}
printf("
\n");
sqlFreeResult(&sr2);
sr2 = sqlGetResult(hgFixed2, query2);
@@ -15983,31 +15984,31 @@
char *itemCopy = cloneString(itemName);
variantSignal = lastChar(itemName);
if (variantSignal == '*')
stripChar(itemCopy, '*');
if (variantSignal == '?')
stripChar(itemCopy, '?');
if (variantSignal == '#')
stripChar(itemCopy, '#');
genericHeader(tdb, itemCopy);
printf("NCBI Clone Registry: %s \n", itemCopy);
if (variantSignal == '*' || variantSignal == '?' || variantSignal == '#')
printf("Note this BAC was found to be variant. See references. \n");
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where chrom = '%s' and "
"chromStart=%d and name = '%s'", table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
cnpSharpStaticLoad(row+rowOffset, &cnpSharp);
bedPrintPos((struct bed *)&cnpSharp, 3, tdb);
printCnpSharpDetails(cnpSharp);
}
sqlFreeResult(&sr);
hFreeConn(&conn);
// printCnpSharpSampleData(itemName);
printTrackHtml(tdb);
}
@@ -16015,62 +16016,62 @@
void doCnpSharp2(struct trackDb *tdb, char *itemName)
{
char *table = tdb->table;
struct cnpSharp2 cnpSharp2;
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset = hOffsetPastBin(database, seqName, table);
int start = cartInt(cart, "o");
genericHeader(tdb, itemName);
printf("NCBI Clone Registry: %s \n", itemName);
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where chrom = '%s' and "
"chromStart=%d and name = '%s'", table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
cnpSharp2StaticLoad(row+rowOffset, &cnpSharp2);
bedPrintPos((struct bed *)&cnpSharp2, 3, tdb);
printf("Name: %s \n", cnpSharp2.name);
printf("Variation type: %s \n", cnpSharp2.variationType);
}
sqlFreeResult(&sr);
hFreeConn(&conn);
// printCnpSharpSampleData(itemName);
printTrackHtml(tdb);
}
void doDgv(struct trackDb *tdb, char *id)
/* Details for Database of Genomic Variants (updated superset of cnp*). */
{
struct dgv dgv;
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[512];
int rowOffset = hOffsetPastBin(database, seqName, tdb->table);
int start = cartInt(cart, "o");
int end = cartInt(cart, "t");
genericHeader(tdb, id);
printCustomUrl(tdb, id, FALSE);
-safef(query, sizeof(query), "select * from %s where name = '%s' "
+sqlSafef(query, sizeof(query), "select * from %s where name = '%s' "
"and chrom = '%s' and chromStart = %d and chromEnd = %d",
tdb->table, id, seqName, start, end);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
dgvStaticLoad(row+rowOffset, &dgv);
if (dgv.chromStart != dgv.thickStart ||
(dgv.chromEnd != dgv.thickEnd && dgv.thickEnd != dgv.chromStart))
{
printf("Variant Position: "
"%s:%d-%d \n",
hgTracksPathAndSettings(), database,
dgv.chrom, dgv.thickStart+1, dgv.thickEnd,
dgv.chrom, dgv.thickStart+1, dgv.thickEnd);
printBand(dgv.chrom, dgv.thickStart, dgv.thickEnd, FALSE);
@@ -16110,57 +16111,57 @@
void doAffy120K(struct trackDb *tdb, char *itemName)
/* Put up info on an Affymetrix SNP. */
{
char *table = tdb->table;
struct snp snp;
int start = cartInt(cart, "o");
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset;
cartWebStart(cart, database, "Single Nucleotide Polymorphism (SNP)");
printf("
Single Nucleotide Polymorphism (SNP) %s
\n", itemName);
-sprintf(query, "select * "
+sqlSafef(query, sizeof query, "select * "
"from affy120K "
"where chrom = '%s' "
" and chromStart = %d "
" and name = '%s'",
seqName, start, itemName);
rowOffset = hOffsetPastBin(database, seqName, table);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
snpStaticLoad(row+rowOffset, &snp);
bedPrintPos((struct bed *)&snp, 3, tdb);
}
doAffy120KDetails(tdb, itemName);
printTrackHtml(tdb);
sqlFreeResult(&sr);
hFreeConn(&conn);
}
void doAffy10KDetails(struct trackDb *tdb, char *name)
/* print additional SNP details */
{
struct sqlConnection *conn = sqlConnect("hgFixed");
char query[1024];
struct affy10KDetails *snp=NULL;
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select affyId, rsId, tscId, baseA, baseB, "
"sequenceA, sequenceB, enzyme "
/** minFreq, hetzyg, and avHetSE are waiting for additional data from Affy **/
/* " , minFreq, hetzyg, avHetSE "*/
"from affy10KDetails "
"where affyId = '%s'", name);
snp = affy10KDetailsLoadByQuery(conn, query);
if (snp!=NULL)
{
printf(" \n");
printf("Sample Prep Enzyme: XbaI \n");
/** minFreq, hetzyg, and avHetSE are waiting for additional data from Affy **/
/* printf("Minimum Allele Frequency: %.3f \n",snp->minFreq);*/
/* printf("Heterozygosity: %.3f \n",snp->hetzyg);*/
/* printf("Average Heterozygosity: %.3f \n",snp->avHetSE);*/
@@ -16196,60 +16197,60 @@
void doAffy10K(struct trackDb *tdb, char *itemName)
/* Put up info on an Affymetrix SNP. */
{
char *table = tdb->table;
struct snp snp;
int start = cartInt(cart, "o");
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
int rowOffset;
cartWebStart(cart, database, "Single Nucleotide Polymorphism (SNP)");
printf("
Single Nucleotide Polymorphism (SNP) %s
\n", itemName);
-sprintf(query, "select * "
+sqlSafef(query, sizeof query, "select * "
"from affy10K "
"where chrom = '%s' "
" and chromStart = %d "
" and name = '%s'",
seqName, start, itemName);
rowOffset = hOffsetPastBin(database, seqName, table);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
snpStaticLoad(row+rowOffset, &snp);
bedPrintPos((struct bed *)&snp, 3, tdb);
}
doAffy10KDetails(tdb, itemName);
printTrackHtml(tdb);
sqlFreeResult(&sr);
hFreeConn(&conn);
}
void printSnpOrthoSummary(struct trackDb *tdb, char *rsId, char *observed)
/* helper function for printSnp125Info */
{
char *orthoTable = snp125OrthoTable(tdb, NULL);
if (isNotEmpty(orthoTable) && hTableExists(database, orthoTable))
{
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[512];
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select chimpAllele from %s where name='%s'", orthoTable, rsId);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
printf("Summary: %s>%s (chimp allele displayed first, "
"then '>', then human alleles) \n", row[0], observed);
sqlFreeResult(&sr);
hFreeConn(&conn);
}
}
#define FOURBLANKCELLS "
"
void printSnpAlleleRows(struct snp125 *snp, int version)
/* Print the UCSC ref allele (and dbSNP if it differs), as row(s) of a
* 6-column table. */
@@ -16316,38 +16317,38 @@
void printSnpOrthoRows(struct trackDb *tdb, struct snp125 *snp)
/* If a chimp+macaque ortho table was specified, print out the orthos
* (if any), as rows of a 6-column table. */
{
int speciesCount = 0;
char *orthoTable = snp125OrthoTable(tdb, &speciesCount);
if (isNotEmpty(orthoTable) && hTableExists(database, orthoTable))
{
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[1024];
if (speciesCount == 2)
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select chimpChrom, chimpStart, chimpEnd, chimpAllele, chimpStrand, "
"macaqueChrom, macaqueStart, macaqueEnd, macaqueAllele, macaqueStrand "
"from %s where chrom='%s' and bin=%d and chromStart=%d and name='%s'",
orthoTable, seqName, binFromRange(snp->chromStart, snp->chromEnd),
snp->chromStart, snp->name);
else
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select chimpChrom, chimpStart, chimpEnd, chimpAllele, chimpStrand, "
"orangChrom, orangStart, orangEnd, orangAllele, orangStrand, "
"macaqueChrom, macaqueStart, macaqueEnd, macaqueAllele, macaqueStrand "
"from %s where chrom='%s' and bin=%d and chromStart=%d and name='%s'",
orthoTable, seqName, binFromRange(snp->chromStart, snp->chromEnd),
snp->chromStart, snp->name);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
char *chimpChrom = row[0];
int chimpStart = sqlUnsigned(row[1]);
int chimpEnd = sqlUnsigned(row[2]);
char *chimpAllele = row[3];
char *chimpStrand = row[4];
char *chimpDb = trackDbSetting(tdb, "chimpDb");
@@ -16460,33 +16461,33 @@
}
char *getSymbolForGeneName(char *geneTable, char *geneId)
/* Given a gene track and gene accession, look up the symbol if we know where to look
* and if we find it, return a string with both symbol and acc. */
{
struct dyString *dy = dyStringNew(32);
char buf[256];
char *sym = NULL;
if (sameString(geneTable, "knownGene") || sameString(geneTable, "refGene"))
{
struct sqlConnection *conn = hAllocConn(database);
char query[256];
query[0] = '\0';
if (sameString(geneTable, "knownGene"))
- safef(query, sizeof(query), "select geneSymbol from kgXref where kgID = '%s'", geneId);
+ sqlSafef(query, sizeof(query), "select geneSymbol from kgXref where kgID = '%s'", geneId);
else if (sameString(geneTable, "refGene"))
- safef(query, sizeof(query), "select name from refLink where mrnaAcc = '%s'", geneId);
+ sqlSafef(query, sizeof(query), "select name from refLink where mrnaAcc = '%s'", geneId);
sym = sqlQuickQuery(conn, query, buf, sizeof(buf)-1);
hFreeConn(&conn);
}
if (sym != NULL)
dyStringPrintf(dy, "%s (%s)", sym, geneId);
else
dyStringAppend(dy, geneId);
return dyStringCannibalize(&dy);
}
#define firstTwoColumnsPctS "
%s
%s
"
void getSnp125RefCodonAndSnpPos(struct snp125 *snp, struct genePred *gene, int exonIx,
int *pSnpCodonPos, char refCodon[4], char *pRefAA)
/* Given a single-base snp and a coding gene/exon containing it, determine the snp's position
@@ -16694,49 +16695,49 @@
}
}
}
void printSnp125NearGenes(struct sqlConnection *conn, struct snp125 *snp, char *geneTable,
char *geneTrack)
/* Search upstream and downstream of snp for neigh */
{
struct sqlResult *sr;
char query[512];
char **row;
int snpStart = snp->chromStart, snpEnd = snp->chromEnd;
int nearCount = 0;
int maxDistance = 10000;
/* query to the left: */
-safef(query, sizeof(query), "select name,txEnd,strand from %s "
+sqlSafef(query, sizeof(query), "select name,txEnd,strand from %s "
"where chrom = '%s' and txStart < %d and txEnd > %d",
geneTable, snp->chrom, snpStart, snpStart - maxDistance);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
char *gene = row[0];
char *geneName = getSymbolForGeneName(geneTable, gene);
int end = sqlUnsigned(row[1]);
char *strand = row[2];
boolean isRc = strand[0] == '-';
printf(firstTwoColumnsPctS "%s (%d bases %sstream)
\n",
geneTrack, geneName, snpMisoLinkFromFunc(isRc ? "near-gene-5" : "near-gene-3"),
(snpStart - end + 1), (isRc ? "up" : "down"));
nearCount++;
}
sqlFreeResult(&sr);
/* query to the right: */
-safef(query, sizeof(query), "select name,txStart,strand from %s "
+sqlSafef(query, sizeof(query), "select name,txStart,strand from %s "
"where chrom = '%s' and txStart < %d and txEnd > %d",
geneTable, snp->chrom, snpEnd + maxDistance, snpEnd);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
char *gene = row[0];
char *geneName = getSymbolForGeneName(geneTable, gene);
int start = sqlUnsigned(row[1]);
char *strand = row[2];
boolean isRc = strand[0] == '-';
printf(firstTwoColumnsPctS "%s (%d bases %sstream)\n",
geneTrack, geneName, snpMisoLinkFromFunc(isRc ? "near-gene-3" : "near-gene-5"),
(start - snpEnd + 1), (isRc ? "down" : "up"));
nearCount++;
}
@@ -16793,31 +16794,31 @@
struct slName *gt;
boolean first = TRUE;
for (gt = geneTracks; gt != NULL; gt = gt->next)
if (sqlTableExists(conn, gt->name))
{
if (first)
{
printf(" UCSC's predicted function relative to selected gene tracks:\n");
printf("
\n");
}
struct genePred *geneList = getGPsWithFrames(conn, gt->name, snp->chrom,
snp->chromStart, snp->chromEnd);
struct genePred *gene;
char query[256];
char buf[256];
- safef(query, sizeof(query), "select shortLabel from trackDb where tableName='%s'",
+ sqlSafef(query, sizeof(query), "select shortLabel from trackDb where tableName='%s'",
gt->name);
char *shortLabel = sqlQuickQuery(conn, query, buf, sizeof(buf)-1);
if (shortLabel == NULL) shortLabel = gt->name;
for (gene = geneList; gene != NULL; gene = gene->next)
printSnp125FunctionInGene(snp, gt->name, shortLabel, gene);
if (geneList == NULL)
printSnp125NearGenes(conn, snp, gt->name, shortLabel);
first = FALSE;
}
if (! first)
printf("
\n");
hFreeConn(&conn);
}
char *dbSnpFuncFromInt(unsigned char funcCode)
@@ -16865,33 +16866,33 @@
for (tbl = tableList; tbl != NULL; tbl = tbl->next)
{
if (!sqlTableExists(conn, tbl->name))
continue;
char setting[512];
safef(setting, sizeof(setting), "codingAnnoLabel_%s", tbl->name);
char *label = trackDbSettingOrDefault(tdb, setting, NULL);
if (label == NULL && endsWith(tbl->name, "DbSnp"))
label = "dbSNP";
else
label = tbl->name;
boolean hasBin = hIsBinned(database, tbl->name);
boolean hasCoords = (sqlFieldIndex(conn, tbl->name, "chrom") != -1);
int rowOffset = hasBin + (hasCoords ? 3 : 0);
dyStringClear(query);
- dyStringPrintf(query, "select * from %s where name = '%s'", tbl->name, snp->name);
+ sqlDyStringPrintf(query, "select * from %s where name = '%s'", tbl->name, snp->name);
if (hasCoords)
- dyStringPrintf(query, " and chrom = '%s' and chromStart = %d", seqName, snp->chromStart);
+ sqlDyStringPrintf(query, " and chrom = '%s' and chromStart = %d", seqName, snp->chromStart);
struct sqlResult *sr = sqlGetResult(conn, query->string);
char **row;
boolean first = TRUE;
while ((row = sqlNextRow(sr)) != NULL)
{
if (first)
{
printf(" Coding annotations by %s: \n", label);
first = FALSE;
}
struct snp125CodingCoordless *anno = snp125CodingCoordlessLoad(row+rowOffset);
int i;
boolean gotRef = (anno->funcCodes[0] == 8);
for (i = 0; i < anno->alleleCount; i++)
{
@@ -17072,59 +17073,59 @@
{
char *exceptionsTableSetting = trackDbSetting(tdb, "snpExceptions");
char exceptionsTable[128];
if (exceptionsTableSetting)
safecpy(exceptionsTable, sizeof(exceptionsTable), exceptionsTableSetting);
else
safef(exceptionsTable, sizeof(exceptionsTable), "%sExceptions", tdb->table);
char *excDescTable = getExcDescTable(tdb);
if (hTableExists(database, exceptionsTable) && hTableExists(database, excDescTable))
{
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[1024];
int start = cartInt(cart, "o");
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select description, %s.exception from %s, %s "
"where chrom = \"%s\" and chromStart = %d and name = \"%s\" "
"and %s.exception = %s.exception",
excDescTable, excDescTable, exceptionsTable,
seqName, start, itemName, excDescTable, exceptionsTable);
sr = sqlGetResult(conn, query);
boolean gotExc = FALSE;
while ((row = sqlNextRow(sr))!=NULL)
gotExc |= writeOneSnpException(row[1], row[0], gotExc);
sqlFreeResult(&sr);
hFreeConn(&conn);
}
}
static void writeSnpExceptionFromColumn(struct trackDb *tdb, struct snp132Ext *snp)
/* Hash the contents of exception description table, and for each exception listed
* in snp->exceptions, print out its description. */
{
char *excDescTable = getExcDescTable(tdb);
if (hTableExists(database, excDescTable))
{
static struct hash *excDesc = NULL;
if (excDesc == NULL)
{
excDesc = hashNew(0);
struct sqlConnection *conn = hAllocConn(database);
char query[512];
- safef(query, sizeof(query), "select exception,description from %s", excDescTable);
+ sqlSafef(query, sizeof(query), "select exception,description from %s", excDescTable);
struct sqlResult *sr = sqlGetResult(conn, query);
char **row;
while ((row = sqlNextRow(sr))!=NULL)
hashAdd(excDesc, row[0], cloneString(row[1]));
sqlFreeResult(&sr);
hFreeConn(&conn);
}
struct slName *excList = slNameListFromComma(snp->exceptions), *exc;
boolean gotExc = FALSE;
for (exc = excList; exc != NULL; exc = exc->next)
{
char *desc = hashFindVal(excDesc, exc->name);
gotExc |= writeOneSnpException(exc->name, desc, gotExc);
}
}
@@ -17156,31 +17157,31 @@
else
snp->strand[0] = '?';
snp->strand[1] = '\0';
snp->observed = cloneString(snp125->observed);
return snp;
}
void checkForHgdpGeo(struct sqlConnection *conn, struct trackDb *tdb, char *itemName, int start)
{
char *hgdpGeoTable = "hgdpGeo"; // make this a trackDb setting
if (!hTableExists(database, hgdpGeoTable))
return;
struct sqlResult *sr;
char **row;
char query[512];
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where name = '%s' and chrom = '%s' and chromStart = %d",
hgdpGeoTable, itemName, seqName, start);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
struct hgdpGeo geo;
hgdpGeoStaticLoad(row+1, &geo);
char title[1024];
safef(title, sizeof(title), "Human Genome Diversity Project SNP"
"",
hgdpPngFilePath(itemName));
jsBeginCollapsibleSection(cart, tdb->track, "hgdpGeo", title, FALSE);
printf("Note: These annotations are taken directly from the "
"HGDP Selection Browser, "
"and may indicate the allele on the opposite strand from that given above. \n");
@@ -17191,74 +17192,74 @@
printf("
\n");
hgdpGeoImg(&geo);
printf("
\n");
jsEndCollapsibleSection();
}
sqlFreeResult(&sr);
}
void checkForHapmap(struct sqlConnection *conn, struct trackDb *tdb, char *itemName)
{
boolean isPhaseIII = sameString(trackDbSettingOrDefault(tdb, "hapmapPhase", "II"), "III");
boolean gotHapMap = FALSE;
char query[512];
if (!isPhaseIII && sqlTableExists(conn, "hapmapAllelesSummary"))
{
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select count(*) from hapmapAllelesSummary where name = '%s'", itemName);
if (sqlQuickNum(conn, query) > 0)
gotHapMap = TRUE;
}
else
{
int i;
for (i = 0; hapmapPhaseIIIPops[i] != NULL; i++)
{
char table[HDB_MAX_TABLE_STRING];
safef(table, sizeof(table), "hapmapSnps%s", hapmapPhaseIIIPops[i]);
if (sqlTableExists(conn, table))
{
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select count(*) from %s where name = '%s'", table, itemName);
if (sqlQuickNum(conn, query) > 0)
{
gotHapMap = TRUE;
break;
}
}
}
}
struct trackDb *hsTdb = hashFindVal(trackHash, "hapmapSnps");
if (gotHapMap && hsTdb != NULL)
{
printf("
\n", row2[2]);
}
else
{
printf("%s\n",lfs->lfNames[i]);
}
sqlFreeResult(&sr2);
@@ -18533,33 +18534,33 @@
hFreeConn(&conn1);
}
void fillCghTable(int type, char *tissue, boolean bold)
/* Get the requested records from the database and print out HTML table */
{
char query[256];
char currName[64];
int rowOffset;
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr = NULL;
char **row;
struct cgh *cghRow;
if (tissue)
- sprintf(query, "type = %d AND tissue = '%s' ORDER BY name, chromStart", type, tissue);
+ sqlSafef(query, sizeof query, "type = %d AND tissue = '%s' ORDER BY name, chromStart", type, tissue);
else
- sprintf(query, "type = %d ORDER BY name, chromStart", type);
+ sqlSafef(query, sizeof query, "type = %d ORDER BY name, chromStart", type);
sr = hRangeQuery(conn, "cgh", seqName, winStart, winEnd, query, &rowOffset);
while ((row = sqlNextRow(sr)))
{
cghRow = cghLoad(row);
if (strcmp(currName,cghRow->name))
{
if (bold)
printf("\n
\n
%s
\n",cghRow->name);
else
printf("
\n
\n
%s
\n",cghRow->name);
strcpy(currName,cghRow->name);
}
if (bold)
printf("
%.6f
\n",cghRow->score);
else
@@ -18581,31 +18582,31 @@
char **row;
int celeraVersion = 0;
int i = 0;
cartWebStart(cart, database, "%s", tdb->longLabel);
if (sameString(database, "hg15"))
celeraVersion = 3;
else
celeraVersion = 4;
if (cgiVarExists("o"))
{
int start = cgiInt("o");
int rowOffset = hOffsetPastBin(database, seqName, tdb->table);
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select * from %s where chrom = '%s' and chromStart = %d and name= '%s'",
tdb->table, seqName, start, dupName);
sr = sqlGetResult(conn, query);
i = 0;
while ((row = sqlNextRow(sr)))
{
if (i > 0)
htmlHorizontalLine();
celeraDupPositiveStaticLoad(row+rowOffset, &dup);
printf("Duplication Name: %s \n", dup.name);
bedPrintPos((struct bed *)(&dup), 3, tdb);
if (!sameString(dup.name, dup.fullName))
printf("Full Descriptive Name: %s \n", dup.fullName);
if (dup.bpAlign > 0)
{
@@ -18683,31 +18684,31 @@
char oChrom[64];
int oStart;
int dupId;
int rowOffset;
int start = cgiInt("o");
int end = cgiInt("t");
char *alignUrl = NULL;
if (sameString("hg18", database))
alignUrl = "http://humanparalogy.gs.washington.edu/build36";
else if (sameString("hg17", database))
alignUrl = "http://humanparalogy.gs.washington.edu";
else if (sameString("hg15", database) || sameString("hg16", database))
alignUrl = "http://humanparalogy.gs.washington.edu/jab/der_oo33";
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
parseSuperDupsChromPointPos(dupName, oChrom, &oStart, &dupId);
- dyStringPrintf(query, "select * from %s where chrom = '%s' and ",
+ sqlDyStringPrintf(query, "select * from %s where chrom = '%s' and ",
tdb->table, seqName);
if (rowOffset > 0)
hAddBinToQuery(start, end, query);
if (dupId >= 0)
dyStringPrintf(query, "uid = %d and ", dupId);
dyStringPrintf(query, "chromStart = %d and otherStart = %d",
start, oStart);
sr = sqlGetResult(conn, query->string);
while ((row = sqlNextRow(sr)))
{
genomicSuperDupsStaticLoad(row+rowOffset, &dup);
bedPrintPos((struct bed *)(&dup), 4, tdb);
printf("Other Position: "
""
"%s:%d-%d \n",
@@ -18771,31 +18772,31 @@
/* Print out non-sequence info */
cartWebStart(cart, database, "%s", tissue);
/* Print general range info */
printf("
UCSF Comparative Genomic Hybridizations - %s
\n", tissue);
printf("\n
\n");
printf("
Chromosome:
%s
\n",seqName);
printf("
Start window:
%d
\n",winStart);
printf("
End window:
%d
\n",winEnd);
printf("
\n");
printf("\n");
/* Find the names of all of the clones in this range */
printf("
\n");
printf("
Cell Line
");
-sprintf(query, "SELECT spot from cgh where chrom = '%s' AND "
+sqlSafef(query, sizeof query, "SELECT spot from cgh where chrom = '%s' AND "
"chromStart <= '%d' AND chromEnd >= '%d' AND "
"tissue = '%s' AND type = 3 GROUP BY spot ORDER BY chromStart",
seqName, winEnd, winStart, tissue);
sr = sqlMustGetResult(conn, query);
while ((row = sqlNextRow(sr)))
printf("
Spot %s
",row[0]);
printf("
\n");
sqlFreeResult(&sr);
/* Find the relevant tissues type records in the range */
fillCghTable(3, tissue, FALSE);
printf("
\n");
/* Find the relevant tissue average records in the range */
fillCghTable(2, tissue, TRUE);
@@ -18824,58 +18825,58 @@
/* Print out non-sequence info */
sprintf(title, "MCN Breakpoints - %s",name);
cartWebStart(cart, database, "%s", title);
/* Print general range info */
/*printf("
\n");
/* Find all of the breakpoints in this range for this name*/
-sprintf(query, "SELECT * FROM mcnBreakpoints WHERE chrom = '%s' AND "
+sqlSafef(query, sizeof query, "SELECT * FROM mcnBreakpoints WHERE chrom = '%s' AND "
"chromStart = %d and chromEnd = %d AND name = '%s'",
seqName, start, end, name);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)))
{
printf("\n");
mcnRecord = mcnBreakpointsLoad(row);
printf("
\n");
cartFooter();
bedFreeList(&bedList);
cutterFreeList(&cut);
hFreeConn(&conn);
exit(0);
}
static void doCutters(char *item)
/* Print info about a restriction enzyme. */
{
struct sqlConnection *conn;
struct cutter *cut = NULL;
char query[100];
char *doGetBed = cgiOptionalString("doGetBed");
char *c = cgiOptionalString("c");
char *l = cgiOptionalString("l");
char *r = cgiOptionalString("r");
conn = hAllocConn("hgFixed");
if (doGetBed)
doCuttersEnzymeList(conn, doGetBed, c, l, r);
-safef(query, sizeof(query), "select * from cutters where name=\'%s\'", item);
+sqlSafef(query, sizeof(query), "select * from cutters where name=\'%s\'", item);
cut = cutterLoadByQuery(conn, query);
cartWebStart(cart, database, "Restriction Enzymes from REBASE");
if (cut)
{
char *o = cgiOptionalString("o");
char *t = cgiOptionalString("t");
struct slName *isoligs = cutterIsoligamers(cut);
printf("Enzyme Name: %s \n", cut->name);
/* Display position only if click came from hgTracks. */
if (c && o && t)
{
int left = atoi(o);
int right = atoi(t);
printPosOnChrom(c, left, right, NULL, FALSE, cut->name);
}
@@ -21561,31 +21557,31 @@
if (isoligs)
{
struct slName *cur;
puts("Isoligamers: ");
for (cur = isoligs; cur->next != NULL; cur = cur->next)
printf("%s, ", hgcPathAndSettings(), CUTTERS_TRACK_NAME, cur->name, cur->name);
printf("%s \n", hgcPathAndSettings(), CUTTERS_TRACK_NAME, cur->name, cur->name);
slFreeList(&isoligs);
}
if (cut->numRefs > 0)
{
int i, count = 1;
char **row;
struct sqlResult *sr;
puts("References: \n");
- safef(query, sizeof(query), "select * from rebaseRefs");
+ sqlSafef(query, sizeof(query), "select * from rebaseRefs");
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
int refNum = atoi(row[0]);
for (i = 0; i < cut->numRefs; i++)
{
if (refNum == cut->refs[i])
printf("%d. %s \n", count++, row[1]);
}
}
sqlFreeResult(&sr);
}
if (c && o && t)
{
puts(" Download BED of enzymes in this browser range: ");
@@ -21598,31 +21594,31 @@
hFreeConn(&conn);
}
static void doAnoEstTcl(struct trackDb *tdb, char *item)
/* Print info about AnoEst uniquely-clustered item. */
{
struct sqlConnection *conn = hAllocConn(database);
int start = cartInt(cart, "o");
genericHeader(tdb, item);
printCustomUrl(tdb, item, TRUE);
genericBedClick(conn, tdb, item, start, 12);
if (hTableExists(database, "anoEstExpressed"))
{
char query[512];
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select 1 from anoEstExpressed where name = '%s'", item);
if (sqlQuickNum(conn, query))
puts("Expressed: yes ");
else
puts("Expressed: no ");
}
hFreeConn(&conn);
printTrackHtml(tdb);
}
void mammalPsgTableRow(char *test, char *description, float pVal, unsigned isFdrSignificant)
/* print single row of the overview table for mammal PSG track */
{
char *start = "";
char *end = "";
@@ -21641,31 +21637,31 @@
start,pVal,end);
}
}
void doMammalPsg(struct trackDb *tdb, char *itemName)
/* create details page for mammalPsg track */
{
struct mammalPsg *mammalPsg = NULL;
char query[512];
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char *bayesianFiguresUrl = "../images/mammalPsg";
genericHeader(tdb, itemName);
-sprintf(query, "select * from %s where name = '%s'", tdb->table, itemName);
+sqlSafef(query, sizeof query, "select * from %s where name = '%s'", tdb->table, itemName);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
mammalPsg = mammalPsgLoad(row);
else
errAbort("Can't find item '%s'", itemName);
sqlFreeResult(&sr);
/* first print the same thing that you would print for ordinary bed track */
bedPrintPos((struct bed *) mammalPsg,12,tdb);
/* rows showing the results of individual likelihood ratio tests */
printf("
Likelihood ratio tests for positive selection:
\n");
printf("
\n");
printf("
Test
Description
P-value
");
@@ -21698,31 +21694,31 @@
hFreeConn(&conn);
}
void doDless(struct trackDb *tdb, char *itemName)
/* create details page for DLESS */
{
struct dless *dless = NULL;
char query[512];
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
boolean approx;
enum {CONS, GAIN, LOSS} elementType;
genericHeader(tdb, itemName);
-sprintf(query, "select * from %s where name = '%s'", tdb->table, itemName);
+sqlSafef(query, sizeof query, "select * from %s where name = '%s'", tdb->table, itemName);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
dless = dlessLoad(row);
else
errAbort("Can't find item '%s'", itemName);
sqlFreeResult(&sr);
approx = sameString(dless->condApprox, "approx");
if (sameString(dless->type, "conserved"))
elementType = CONS;
else if (sameString(dless->type, "gain"))
elementType = GAIN;
else
elementType = LOSS;
@@ -21792,31 +21788,31 @@
int tEnd = psl->tEnd;
char tName[256];
struct dnaSeq *tSeq;
char *tables[4] = {"luGene", "refGene", "mgcGenes", "luGene2"};
/* open file to write to */
trashDirFile(&indexTn, "index", "index", ".html");
trashDirFile(&bodyTn, "body", "body", ".html");
body = mustOpen(bodyTn.forCgi, "w");
/* get query genes struct info*/
for(i = 0; i < 4; i++)
{
if(sqlTableExists(conn, tables[i]))
{
- sprintf(query, "SELECT * FROM %s WHERE name = '%s'"
+ sqlSafef(query, sizeof query, "SELECT * FROM %s WHERE name = '%s'"
"AND chrom = '%s' AND txStart <= %d "
"AND txEnd >= %d",
tables[i], geneName, psl->qName, qStart, qEnd);
sr = sqlMustGetResult(conn, query);
if((row = sqlNextRow(sr)) != NULL)
{
int hasBin = 0;
if(hOffsetPastBin(database, psl->qName, tables[i]))
hasBin=1;
gene = genePredLoad(row+hasBin);
break;
}
else
sqlFreeResult(&sr);
}
@@ -21907,31 +21903,31 @@
int start = cgiInt("cStart");
int end = cgiInt("cEnd");
struct psl *psl = NULL;
struct dnaSeq *qSeq = NULL;
char *db = cgiString("db");
char name[64];
char query[256], fullTable[64];
char **row;
boolean hasBin;
struct sqlResult *sr = NULL;
struct sqlConnection *conn = hAllocConn(database);
hFindSplitTable(database, chrom, pslTable, fullTable, &hasBin);
-sprintf(query, "SELECT * FROM %s WHERE "
+sqlSafef(query, sizeof query, "SELECT * FROM %s WHERE "
"tName = '%s' AND tStart = %d "
"AND tEnd = %d",
pslTable, chrom, start, end);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if(row != NULL)
{
psl = pslLoad(row+hasBin);
}
else
{
errAbort("No alignment infomation\n");
}
qSeq = loadGenomePart(db, psl->qName, psl->qStart, psl->qEnd);
sprintf(name, "%s in %s(%d-%d)", item,psl->qName, psl->qStart, psl->qEnd);
@@ -21947,31 +21943,31 @@
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr = NULL;
char **row, table[256], query[256], *parts[6];
struct putaInfo *info = NULL;
struct psl *psl = NULL;
int start = cartInt(cart, "o"), end = cartInt(cart, "t");
char *db = cgiString("db");
char *name = cartString(cart, "i"), *chr = cartString(cart, "c");
char pslTable[256];
char otherString[256], *tempName = NULL;
int partCount;
sprintf(table, "putaInfo");
sprintf(pslTable,"potentPsl");
cartWebStart(cart, database, "Putative Coding or Pseudo Fragments");
-sprintf(query, "SELECT * FROM %s WHERE name = '%s' "
+sqlSafef(query, sizeof query, "SELECT * FROM %s WHERE name = '%s' "
"AND chrom = '%s' AND chromStart = %d "
"AND chromEnd = %d",
table, name, chr, start, end);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if(row != NULL)
{
info = putaInfoLoad(row+1);
}
else
{
errAbort("Can't find information for %s in data base\n", name);
}
@@ -22014,31 +22010,31 @@
if(info->strand[0] == '+')
printf("%d ",k+1);
else
printf("%d ", info->blockCount - k);
}
}
printf(" \n");
}
/* show genome sequence */
hgcAnchorSomewhere("htcGeneInGenome", cgiEncode(info->name), tdb->track, seqName);
printf("View DNA for this putative fragment \n");
/* show the detail alignment */
-sprintf(query, "SELECT * FROM %s WHERE "
+sqlSafef(query, sizeof query, "SELECT * FROM %s WHERE "
"tName = '%s' AND tStart = %d "
"AND tEnd = %d AND strand = '%c%c'",
pslTable, info->chrom, info->chromStart, info->chromEnd, parts[2][0], info->strand[0]);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if(row != NULL)
{
psl = pslLoad(row+1);
sprintf(otherString, "&db=%s&pslTable=%s&chrom=%s&cStart=%d&cEnd=%d&strand=%s&qStrand=%s",
database, pslTable, info->chrom,info->chromStart, info->chromEnd, info->strand, parts[2]);
hgcAnchorSomewhere("potentPsl", cgiEncode(parts[0]), otherString, info->chrom);
printf(" View details of parts of alignment .\n");
}
sqlFreeResult(&sr);
putaInfoFree(&info);
@@ -22080,73 +22076,73 @@
struct sqlResult *sr, *sr2, *sr3, *sr4;
char **row;
char query[256], query2[256], query3[256], query4[256];
int rowOffset = hOffsetPastBin(database, seqName, table);
int start = cartInt(cart, "o");
genericHeader(tdb, itemName);
printf("Item: %s \n", itemName);
printf("Outside Link: ");
printf(" %s \n", itemName);
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where chrom = '%s' and "
"chromStart=%d and name = '%s'", table, seqName, start, itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
dvBedStaticLoad(row+rowOffset, &dvBed);
bedPrintPos((struct bed *)&dvBed, 3, tdb);
}
sqlFreeResult(&sr);
-safef(query2, sizeof(query2), "select * from dv where varId = '%s' ", itemName);
+sqlSafef(query2, sizeof(query2), "select * from dv where varId = '%s' ", itemName);
sr2 = sqlGetResult(conn, query2);
while ((row = sqlNextRow(sr2)) != NULL)
{
/* not using static load */
dv = dvLoad(row);
printf("Swiss-prot ID: %s \n", dv->spID);
printf("Start: %d \n", dv->start);
printf("Length: %d \n", dv->len);
printf("Original: %s \n", dv->orig);
printf("Variant: %s \n", dv->variant);
dvFree(&dv);
}
sqlFreeResult(&sr2);
-safef(query3, sizeof(query3), "select * from dvXref2 where varId = '%s' ", itemName);
+sqlSafef(query3, sizeof(query3), "select * from dvXref2 where varId = '%s' ", itemName);
char *protDbName = hPdbFromGdb(database);
struct sqlConnection *protDbConn = hAllocConn(protDbName);
sr3 = sqlGetResult(protDbConn, query3);
while ((row = sqlNextRow(sr3)) != NULL)
{
dvXref2 = dvXref2Load(row);
if (sameString("MIM", dvXref2->extSrc))
{
printf("OMIM: ");
printf(" %s \n", dvXref2->extAcc);
/* nested query here */
if (hTableExists(database, "omimTitle"))
{
- safef(query4, sizeof(query4), "select * from omimTitle where omimId = '%s' ", dvXref2->extAcc);
+ sqlSafef(query4, sizeof(query4), "select * from omimTitle where omimId = '%s' ", dvXref2->extAcc);
sr4 = sqlGetResult(conn, query4);
while ((row = sqlNextRow(sr4)) != NULL)
{
omimTitle = omimTitleLoad(row);
printf("%s\n", omimTitle->title);
omimTitleFree(&omimTitle);
}
}
printf(" \n");
}
dvXref2Free(&dvXref2);
}
sqlFreeResult(&sr3);
hFreeConn(&protDbConn);
@@ -22190,157 +22186,154 @@
}
if (label == NULL)
label = ""; /* no label */
printf("%s - %s\n", label, url, link->attrAcc);
}
}
void doOreganno(struct trackDb *tdb, char *itemName)
{
char *table = tdb->table;
struct oreganno *r = NULL;
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[256];
-char *escName = NULL;
char *prevLabel = NULL;
int i = 0, listStarted = 0;
//int start = cartInt(cart, "o");
genericHeader(tdb, itemName);
/* postion, band, genomic size */
-escName = sqlEscapeString(itemName);
-safef(query, sizeof(query),
- "select * from %s where name = '%s'", table, escName);
+sqlSafef(query, sizeof(query),
+ "select * from %s where name = '%s'", table, itemName);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
r = oregannoLoad(row);
printf("ORegAnno ID: %s \n", r->id);
#if 0 // all the same as the ID for now
printf("ORegAnno name: %s \n", r->name);
#endif
printf("Strand: %s \n", r->strand);
bedPrintPos((struct bed *)r, 3, tdb);
/* start html list for attributes */
printf("
");
}
sqlFreeResult(&sr);
if (sameString(table, "oregannoOther"))
{
printf("Attributes as described from other species \n");
}
/* fetch and print the attributes */
for (i=0; i < oregannoAttrSize; i++)
{
int used = 0;
char *tab;
if (sameString(table, "oregannoOther"))
tab = cloneString("oregannoOtherAttr");
else
tab = cloneString("oregannoAttr");
/* names are quote safe, come from oregannoUi.c */
- safef(query, sizeof(query), "select * from %s where id = '%s' and attribute = '%s'", tab, r->id, oregannoAttributes[i]);
+ sqlSafef(query, sizeof(query), "select * from %s where id = '%s' and attribute = '%s'", tab, r->id, oregannoAttributes[i]);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
struct oregannoAttr attr;
used++;
if (used == 1)
{
if (!prevLabel || differentString(prevLabel, oregannoAttrLabel[i]))
{
if (listStarted == 0)
listStarted = 1;
else
printf("");
printf("
%s:
\n", oregannoAttrLabel[i]);
freeMem(prevLabel);
prevLabel = cloneString(oregannoAttrLabel[i]);
}
}
oregannoAttrStaticLoad(row, &attr);
printf("%s ", attr.attrVal);
printf(" \n");
}
freeMem(tab);
if (sameString(table, "oregannoOther"))
tab = cloneString("oregannoOtherLink");
else
tab = cloneString("oregannoLink");
- safef(query, sizeof(query), "select * from %s where id = '%s' and attribute = '%s'", tab, r->id, oregannoAttributes[i]);
+ sqlSafef(query, sizeof(query), "select * from %s where id = '%s' and attribute = '%s'", tab, r->id, oregannoAttributes[i]);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
struct oregannoLink link;
used++;
if (used == 1)
{
if (!prevLabel || differentString(prevLabel, oregannoAttrLabel[i]))
{
if (listStarted == 0)
listStarted = 1;
else
printf("
\n");
- safef(query, sizeof(query), "select T, N, M from %s where %s = '%s' ", cliniTable, key, item);
+ sqlSafef(query, sizeof(query), "select T, N, M from %s where %s = '%s' ", cliniTable, key, item);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
printf("
");
printf("
%s
", row[0]);
printf("
%s
", row[1]);
printf("
%s
", row[2]);
printf("
");
}
printf("
\n");
sqlFreeResult(&sr);
/* times */
printf(" Times: \n");
printf("
\n");
printf("
Type
Binary
Value
\n");
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select overallBinary, overallTime, diseaseBinary, diseaseTime, "
"allrecBinary, allrecTime, distrecBinary, distrecTime from %s where %s = '%s' ",
cliniTable, key, item);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
printf("
Overall
%s
%s
", row[0], row[1]);
printf("
Disease
%s
%s
", row[2], row[3]);
printf("
Allrec
%s
%s
", row[4], row[5]);
printf("
Distrec
%s
%s
", row[6], row[7]);
}
printf("
\n");
sqlFreeResult(&sr);
/* affyChipId */
printf(" ");
- safef(query, sizeof(query), "select affyChipId from %s where %s = '%s' ", cliniTable, key, item);
+ sqlSafef(query, sizeof(query), "select affyChipId from %s where %s = '%s' ", cliniTable, key, item);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
printf("Affy Chip ID: %s\n", row[0]);
}
printf("
\n");
sqlFreeResult(&sr);
return;
}
else if ( sameString(table, "cnvLungBroadv2"))
{
cliniTable = "tspLungClinical";
key = "tumorID";
}
else
return;
htmlHorizontalLine();
-safef(query, sizeof(query),
+sqlSafef(query, sizeof(query),
"select * from %s where %s = '%s' ", cliniTable, key,item);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
startSr = sr;
int numFields = sqlCountColumns(sr);
int i;
char *fieldName=NULL, *value=NULL;
for (i=0; i< numFields; i++)
{
fieldName = sqlFieldName(sr);
value = row[i];
printf("%s: %s \n", fieldName, value);
@@ -23710,31 +23697,31 @@
struct dyString *dy = dyStringNew(1024);
struct sqlConnection *conn = hAllocConn(database);
struct itemConf *cf;
char confTable[128];
/* create name for confidence table containing posterior probability and
false discovery rate (FDR). */
safef(confTable, sizeof(confTable), "%sConf", tdb->table);
if (sqlTableExists(conn, confTable))
{
/* print the posterior probability and FDR if available */
struct sqlResult *sr;
char query[256], **row;
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select * from %s where id = '%s'", confTable, item);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
cf = itemConfLoad(row);
dyStringPrintf(dy, "Posterior Probability: %.4g \n", cf->probability);
dyStringPrintf(dy, "False Discovery Rate (FDR): %.2f \n", cf->fdr);
itemConfFree(&cf);
}
sqlFreeResult(&sr);
}
hFreeConn(&conn);
genericClickHandlerPlus(tdb, item, NULL, dy->string);
dyStringFree(&dy);
}
@@ -23748,31 +23735,31 @@
if (isNotEmpty(ncbiAccXref) && hTableExists(database, ncbiAccXref))
{
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char *cloneName = cloneString(item);
char *postUnderscore = strchr(cloneName, '_');
char query[512];
/* In kiddEichlerDiscG248, all clone names have a WIBR2-\w+_ prefix
* before the G248\w+ clone name given in the files used to make this
* table, e.g. WIBR2-1962P18_G248P85919H9,transchrm_chr4 -- skip that
* prefix. Then strip all kiddEichlerDisc* names' ,.* suffixes. */
if (startsWith("WIBR2-", cloneName) && postUnderscore != NULL)
cloneName = postUnderscore+1;
chopPrefixAt(cloneName, ',');
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select cloneAcc, endF, endR from %s where name = '%s'",
ncbiAccXref, cloneName);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
if (isNotEmpty(row[0]))
printf("Clone Report and Sequence (NCBI Nucleotide): "
"%s \n",
getEntrezNucleotideUrl(row[0]), row[0]);
char *endUrlFormat = trackDbSetting(tdb, "pairedEndUrlFormat");
/* Truncate cloneName to get library name: ABC* are followed by _,
* G248 are not. */
char *libId = cloneName;
if (startsWith("G248", libId))
libId[strlen("G248")] = '\0';
@@ -23796,42 +23783,41 @@
sqlFreeResult(&sr);
hFreeConn(&conn);
}
}
void doKiddEichlerDisc(struct trackDb *tdb, char *item)
/* Discordant clone end mappings from Kidd..Eichler 2008. */
{
struct sqlConnection *conn = hAllocConn(database);
char query[512];
struct sqlResult *sr;
char **row;
boolean hasBin;
struct bed *bed;
boolean firstTime = TRUE;
-char *escapedName = sqlEscapeString(item);
int start = cartInt(cart, "o");
genericHeader(tdb, item);
if (! startsWith(KIDD_EICHLER_DISC_PREFIX, tdb->table))
errAbort("track tableName must begin with "KIDD_EICHLER_DISC_PREFIX
" but instead it is %s", tdb->table);
hasBin = hOffsetPastBin(database, seqName, tdb->table);
/* We don't need to add bin to this because name is indexed: */
-safef(query, sizeof(query), "select * from %s where name = '%s' "
+sqlSafef(query, sizeof(query), "select * from %s where name = '%s' "
"and chrom = '%s' and chromStart = %d",
- tdb->table, escapedName, seqName, start);
+ tdb->table, item, seqName, start);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
if (firstTime)
firstTime = FALSE;
else
htmlHorizontalLine();
bed = bedLoadN(row+hasBin, 12);
int lastBlk = bed->blockCount - 1;
int endForUrl = (bed->chromStart + bed->chromStarts[lastBlk] +
bed->blockSizes[lastBlk]);
char *endFudge = trackDbSetting(tdb, "endFudge");
if (endFudge && !strstr(bed->name, "OEA"))
endForUrl += atoi(endFudge);
char sampleName[16];
@@ -23853,74 +23839,72 @@
}
void doBedDetail(struct trackDb *tdb, struct customTrack *ct, char *itemName)
/* generate the detail page for a custom track of bedDetail type */
{
char *table;
struct bedDetail *r = NULL;
struct sqlConnection *conn;
struct sqlResult *sr;
char **row;
char query[256];
char *chrom = cartString(cart,"c"); /* don't assume name is unique */
int start = cgiInt("o");
int end = cgiInt("t");
int bedPart = 4;
-char *escName = NULL;
if (ct == NULL)
{
char *words[3];
int cnt = chopLine(cloneString(tdb->type), words);
if (cnt > 1)
bedPart = atoi(words[1]) - 2;
table = tdb->table;
conn = hAllocConn(database);
genericHeader(tdb, itemName);
}
else
{
table = ct->dbTableName;
conn = hAllocConn(CUSTOM_TRASH);
bedPart = ct->fieldCount - 2;
/* header handled by custom track handler */
}
/* postion, band, genomic size */
-escName = sqlEscapeString(itemName);
-safef(query, sizeof(query),
- "select * from %s where chrom = '%s' and chromStart = %d and chromEnd = %d and name = '%s'", table, chrom, start, end, escName);
+sqlSafef(query, sizeof(query),
+ "select * from %s where chrom = '%s' and chromStart = %d and chromEnd = %d and name = '%s'",
+ table, chrom, start, end, itemName);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
r = bedDetailLoadWithGaps(row, bedPart+2);
bedPrintPos((struct bed*)r, bedPart, tdb);
if (r->id != NULL)
{
if (!sameString("qPcrPrimers", table))
printf("ID: %s \n", r->id);
printCustomUrl(tdb, r->id, TRUE);
}
if (isNotEmpty(r->description))
printf("%s \n", r->description);
}
sqlFreeResult(&sr);
/* do not print this for custom tracks, they do this later */
if (ct == NULL)
printTrackHtml(tdb);
bedDetailFree(&r);
-freeMem(escName);
hFreeConn(&conn);
}
struct trackDb *tdbForTableArg()
/* get trackDb for track passed in table arg */
{
char *table = cartString(cart, "table");
struct trackDb *tdb = hashFindVal(trackHash, table);
if (tdb == NULL)
errAbort("no trackDb entry for %s", table);
return tdb;
}
void doGeneReviews(struct trackDb *tdb, char *itemName)
/* generate the detail page for geneReviews */
@@ -23939,33 +23923,33 @@
}
void prGeneReviews(struct sqlConnection *conn, char *itemName)
/* print GeneReviews associated to this item
Note: this print function has been replaced by addGeneReviewToBed.pl
which print the same information to the field 5 of bigBed file
*/
{
struct sqlResult *sr;
char **row;
char query[512];
int i;
char *clickMsg = "Click link(s) below to search GeneReviews and GeneTests";
boolean firstTime = TRUE;
-if (!sqlTablesExist(conn, "geneReviewsRefGene")) return;
+if (!sqlTableExists(conn, "geneReviewsRefGene")) return;
-safef(query, sizeof(query), "select grShort, diseaseID, diseaseName from geneReviewsRefGene where geneSymbol='%s'", itemName);
+sqlSafef(query, sizeof(query), "select grShort, diseaseID, diseaseName from geneReviewsRefGene where geneSymbol='%s'", itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
char *grShort = *row++;
char *diseaseID = *row++;
char *diseaseName = *row++;
if (firstTime)
{
printf(" GeneReview(s) available for %s: (%s) ",itemName,clickMsg);
firstTime = FALSE;
printf("
");
// #123456789-123456789-123456789-123456789-123456789-123456789-
printf("Short name Disease ID GeneTests disease name ");
@@ -23984,33 +23968,33 @@
} /* end while */
printf("
");
sqlFreeResult(&sr);
} /* end of prGeneReviews */
void prGRShortRefGene(char *itemName)
/* print GeneReviews short label associated to this refGene item */
{
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char **row;
char query[512];
boolean firstTime = TRUE;
-if (!sqlTablesExist(conn, "geneReviewsRefGene")) return;
+if (!sqlTableExists(conn, "geneReviewsRefGene")) return;
-safef(query, sizeof(query), "select grShort, diseaseName from geneReviewsRefGene where geneSymbol='%s'", itemName);
+sqlSafef(query, sizeof(query), "select grShort, diseaseName from geneReviewsRefGene where geneSymbol='%s'", itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
char *grShort = *row++;
char *diseaseName = *row++;
if (firstTime)
{
printf("Related GeneReview(s) and GeneTests disease(s): ");
firstTime = FALSE;
printf("%s", grShort, grShort);
printf(" (");
printf("%s", diseaseName, diseaseName);
printf(")");
} else {
printf(", ");