");
for (j = 0; j <= op->size; j++)
{
printf("");
@@ -1891,31 +1891,31 @@
struct tigrCmrGene *tigr;
char query[512];
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char *dupe, *words[16];
char **row;
int wordCount;
int rowOffset;
/* int start = cartInt(cart, "o"), num = 0; */
genericHeader(tdb,tigrName);
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
- sprintf(query, "select * from %s where name = '%s'", tdb->table, tigrName);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s'", tdb->table, tigrName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
tigr = tigrCmrGeneLoad(row);
if (tigr != NULL)
{
printf("TIGR locus name: %s \n",tigrName);
printf("TIGR gene description: %s \n",tigr->tigrCommon);
printf("Alternate TIGR gene name: ");
if (strlen(tigr->tigrGene) >0) {
printf("%s \n",tigr->tigrGene);
}
else {
printf("None ");
}
@@ -1955,31 +1955,31 @@
{
struct jgiGene *jgi;
char query[512];
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char *dupe, *words[16];
char **row;
int wordCount;
int rowOffset;
genericHeader(tdb,jgiName);
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
- sprintf(query, "select * from %s where name = '%s'", tdb->table, jgiName);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s'", tdb->table, jgiName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
jgi = jgiGeneLoad(row+rowOffset);
printf("JGI locus name: %s \n",jgiName);
printf("JGI gene symbol: %s \n",jgi->jgiSymbol);
printf("JGI gene description: %s \n",jgi->jgiDescription);
printf("JGI gene id: "
"",
jgi->jgiGeneId);
printf("%s \n", jgi->jgiGeneId);
printf("GC content: %.0f %% \n",jgi->jgiGc);
printf(" Position: "
"",
@@ -2006,41 +2006,41 @@
struct sqlResult *sr;
char *dupe, *words[16];
char **row;
int wordCount;
int rowOffset;
char *description;
int start = cartInt(cart, "o");
spConn = sqlConnect(UNIPROT_DB_NAME);
genericHeader(tdb,hitName);
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
- sprintf(query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d", tdb->table, hitName,seqName,start);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d", tdb->table, hitName,seqName,start);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
pfamHit = lowelabPfamHitsLoad(row+rowOffset);
- safef(query, sizeof(query), "select description from proteome.pfamDesc where pfamAC='%s'", pfamHit->pfamAC);
+ sqlSafef(query, sizeof(query), "select description from proteome.pfamDesc where pfamAC='%s'", pfamHit->pfamAC);
if (!sqlTableExists(spConn,"proteome.pfamDesc"))
{
- safef(query, sizeof(query),
+ sqlSafef(query, sizeof(query),
"select extDbRef.extAcc1 from extDbRef,extDb "
"where extDbRef.acc = '%s' "
"and extDbRef.extDb = extDb.id "
"and extDb.val = '%s'"
, pfamHit->pfamAC,pfamHit->pfamID);
}
description = sqlQuickString(spConn, query);
if (description == NULL)
description = cloneString("n/a");
printf("",
pfamHit->pfamAC );
printf("%s - %s
\n", pfamHit->pfamAC, description);
freez(&description);
@@ -2083,31 +2083,31 @@
char *dupe, *words[16];
char **row;
int wordCount;
int rowOffset;
int bedSize = 0;
genericHeader(tdb, tigrOperonName);
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
if (wordCount > 1)
bedSize = atoi(words[1]);
if (bedSize < 3) bedSize = 3;
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
- sprintf(query, "select * from %s where name = '%s'", tdb->table, tigrOperonName);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s'", tdb->table, tigrOperonName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
tigrOperon = bedLoadN(row+rowOffset, bedSize);
printf("Operon name: %s \n",tigrOperonName);
printf(" Position: "
"",
hgTracksPathAndSettings(), database, tigrOperon->chrom, tigrOperon->chromStart + 1, tigrOperon->chromEnd);
printf("%s:%d-%d \n", tigrOperon->chrom, tigrOperon->chromStart + 1, tigrOperon->chromEnd);
printf("Strand: %s \n", tigrOperon->strand);
printf("Genomic size: %d nt \n", (tigrOperon->chromEnd - tigrOperon->chromStart));
if (tigrOperon->next != NULL)
printf(" \n");
}
@@ -2118,31 +2118,31 @@
/* Print table */
printf("", HG_COL_BORDER);
printf("\n");
printf("\n", HG_COL_INSIDE);
printf("\n");
/* Print table column heading */
printf("\n");
printf("Gene 1 | \n");
printf("Gene 2 | \n");
printf("Confidence | \n");
printf("Number of Conserved Genomes | \n");
printf(" \n");
- sprintf(query, "select * from lowelabTIGROperonScore where name = '%s'", tigrOperonName);
+ sqlSafef(query, sizeof query, "select * from lowelabTIGROperonScore where name = '%s'", tigrOperonName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
tigrOperonScore = lowelabTIGROperonScoreLoad(row);
printf("\n");
printf("%s | \n", tigrOperonScore->gene1);
printf("%s | \n", tigrOperonScore->gene2);
printf("%d | \n", tigrOperonScore->confidence);
printf("%d | \n", tigrOperonScore->ortholog_link, tigrOperonScore->ortholog);
printf(" \n");
tigrOperonScore = tigrOperonScore->next;
}
@@ -2176,31 +2176,31 @@
char *dupe, *words[16];
char **row;
int wordCount;
int rowOffset;
int bedSize = 0;
genericHeader(tdb, arkinOperonName);
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
if (wordCount > 1)
bedSize = atoi(words[1]);
if (bedSize < 3) bedSize = 3;
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
- sprintf(query, "select * from %s where name = '%s'", tdb->table, arkinOperonName);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s'", tdb->table, arkinOperonName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
arkinOperon = bedLoadN(row+rowOffset, bedSize);
printf("Arkin operon name: %s \n",arkinOperonName);
printf(" Position: "
"",
hgTracksPathAndSettings(), database, arkinOperon->chrom, arkinOperon->chromStart + 1, arkinOperon->chromEnd);
printf("%s:%d-%d \n", arkinOperon->chrom, arkinOperon->chromStart + 1, arkinOperon->chromEnd);
printf("Strand: %s \n", arkinOperon->strand);
printf("Genomic size: %d nt \n", (arkinOperon->chromEnd - arkinOperon->chromStart));
if (arkinOperon->next != NULL)
printf(" \n");
}
@@ -2211,31 +2211,31 @@
/* Print table */
printf("", HG_COL_BORDER);
printf("\n");
printf("\n", HG_COL_INSIDE);
printf("\n");
/* Print table column heading */
printf("\n");
printf("Gene 1 | \n");
printf("Gene 2 | \n");
printf("Probability of the Same Operon | \n");
printf("Gene neighbor score | \n");
printf(" \n");
- sprintf(query, "select * from lowelabArkinOperonScore where name = '%s'", arkinOperonName);
+ sqlSafef(query, sizeof query, "select * from lowelabArkinOperonScore where name = '%s'", arkinOperonName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
arkinOperonScore = lowelabArkinOperonScoreLoad(row);
printf("\n");
printf("%s | \n", arkinOperonScore->gene1);
printf("%s | \n", arkinOperonScore->gene2);
printf("%0.3f | \n", arkinOperonScore->prob);
printf("%0.3f | \n", arkinOperonScore->gnMinus);
printf(" \n");
arkinOperonScore = arkinOperonScore->next;
}
@@ -2270,31 +2270,31 @@
struct sqlResult *sr;
char **row;
int rowOffset;
int start = cartInt(cart, "o");
int end = cartInt(cart, "t");
char *chrom = cartString(cart, "c");
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
if (wordCount > 1)
bedSize = atoi(words[1]);
if (bedSize < 3) bedSize = 3;
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
- sprintf(query, "select distinct * from %s where name = '%s' and chrom = '%s' and chromStart = %d and chromEnd = %d",
+ sqlSafef(query, sizeof query, "select distinct * from %s where name = '%s' and chrom = '%s' and chromStart = %d and chromEnd = %d",
tdb->table, targetName, chrom, start, end);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
blastpTrack = bedLoadN(row+rowOffset, bedSize);
freez(&dupe);
sqlFreeResult(&sr);
return blastpTrack;
}
void printQueryGeneInfo(struct sqlConnection *conn, struct bed *blastpTrack, char *queryName, unsigned int *querySeqLength, char *queryTable)
/* Get and print blastp query gene info */
{
@@ -2304,55 +2304,55 @@
int geneCount;
char **buffer = NULL;
char *targetGeneName[2];
struct minGeneInfo* ginfo;
char blastpHits[] = "blastpHits";
unsigned int queryStart = 0;
unsigned int queryEnd = 0;
parseDelimitedString(blastpTrack->name, ':', targetGeneName, 2);
if (hTableExists(database, queryTable) && hTableExists(database, blastpHits))
{
/* Get query gene from refSeq */
- sprintf(query, "select count(*) from %s where chrom = '%s' and strand = '%s' and cdsStart <= %u and cdsEnd >= %u",
+ sqlSafef(query, sizeof query, "select count(*) from %s where chrom = '%s' and strand = '%s' and cdsStart <= %u and cdsEnd >= %u",
queryTable, blastpTrack->chrom, blastpTrack->strand, blastpTrack->chromStart, blastpTrack->chromEnd);
srRefSeq = sqlGetResult(conn, query);
if ((row = sqlNextRow(srRefSeq)) != NULL)
{
geneCount = atoi(row[0]);
sqlFreeResult(&srRefSeq);
if (geneCount == 1)
{
- sprintf(query, "select name, cdsStart, cdsEnd from %s where chrom = '%s' and strand = '%s' and cdsStart <= %u and cdsEnd >= %u",
+ sqlSafef(query, sizeof query, "select name, cdsStart, cdsEnd from %s where chrom = '%s' and strand = '%s' and cdsStart <= %u and cdsEnd >= %u",
queryTable, blastpTrack->chrom, blastpTrack->strand, blastpTrack->chromStart, blastpTrack->chromEnd);
srRefSeq = sqlGetResult(conn, query);
if ((row = sqlNextRow(srRefSeq)) != NULL)
{
strcpy(queryName, row[0]);
queryStart = strtoul(row[1], buffer, 10);
queryEnd = strtoul(row[2], buffer, 10);
}
sqlFreeResult(&srRefSeq);
}
else
{
/* Check blastpHits if more than 1 query gene is found within the region */
- sprintf(query, "select a.name, a.cdsStart, a.cdsEnd from %s a, %s b where a.chrom = '%s' and a.strand = '%s' and a.cdsStart <= %u and a.cdsEnd >= %u and a.name = b.query and b.target like '%%%s'",
+ sqlSafef(query, sizeof query, "select a.name, a.cdsStart, a.cdsEnd from %s a, %s b where a.chrom = '%s' and a.strand = '%s' and a.cdsStart <= %u and a.cdsEnd >= %u and a.name = b.query and b.target like '%%%s'",
queryTable, blastpHits,
blastpTrack->chrom, blastpTrack->strand, blastpTrack->chromStart, blastpTrack->chromEnd, targetGeneName[0]);
srRefSeq = sqlGetResult(conn, query);
if ((row = sqlNextRow(srRefSeq)) != NULL)
{
strcpy(queryName, row[0]);
queryStart = strtoul(row[1], buffer, 10);
queryEnd = strtoul(row[2], buffer, 10);
}
sqlFreeResult(&srRefSeq);
}
if ((queryStart == 0) && (queryEnd == 0))
printf("Query gene not found for %s at %s:%u-%u\n", blastpTrack->name, blastpTrack->chrom, blastpTrack->chromStart, blastpTrack->chromEnd);
else
@@ -2383,55 +2383,55 @@
sqlFreeResult(&srRefSeq);
free(targetGeneName[0]);
free(targetGeneName[1]);
}
struct slName* getAllClades(struct sqlConnection *conn)
/* Get all available clades in database */
{
char query[512];
struct sqlResult *srDb;
char **rowDb;
struct slName *list = NULL;
char clade[50];
- sprintf(query, "select label from %s.clade", cfgOption("central.db"));
+ sqlSafef(query, sizeof query, "select label from %s.clade", cfgOption("central.db"));
srDb = sqlGetResult(conn, query);
while ((rowDb = sqlNextRow(srDb)) != NULL)
{
strcpy(clade, rowDb[0]);
slNameAddTail(&list, clade);
}
sqlFreeResult(&srDb);
return list;
}
struct blastTab* loadBlastpHits(struct sqlConnection *conn, char* queryName)
/* Load all blastp hits of the given query gene into a list */
{
char query[512];
struct sqlResult *srBlastpHits = NULL;
struct blastTab *list = NULL;
struct blastTab *blastpHits;
char **row;
char blastpHitsTable[] = "blastpHits";
if (hTableExists(database, blastpHitsTable))
{
- sprintf(query, "select * from %s where query = '%s'", blastpHitsTable, queryName);
+ sqlSafef(query, sizeof query, "select * from %s where query = '%s'", blastpHitsTable, queryName);
srBlastpHits = sqlGetResult(conn, query);
while ((row = sqlNextRow(srBlastpHits)) != NULL)
{
blastpHits = blastTabLoad(row);
slAddTail(&list, blastpHits);
}
}
if (srBlastpHits != NULL)
sqlFreeResult(&srBlastpHits);
return list;
}
void printBlastpResult(struct sqlConnection *conn, struct blastTab *blastpHitsList, unsigned int querySeqLength)
/* Print Blastp result of given clade */
{
@@ -2500,82 +2500,82 @@
printf("\n");
printf("%s | \n", blastpTarget[1], tChrom, tStart, tEnd, genome);
if (cladePortionCount == 1)
printf("%s | \n", clades[0]);
else if (cladePortionCount == 2)
printf("%s %s | \n", clades[0], clades[1]);
/* Get target gene position from refSeq */
strcpy(refSeq, blastpTarget[0]);
strcat(refSeq, ".");
if (hDbExists(blastpTarget[0]))
{
if (hTableExists(blastpTarget[0], "lookup"))
{
- sprintf(query, "select lookupValue from %s.lookup where lookupCode = 'annotRev'", blastpTarget[0]);
+ sqlSafef(query, sizeof query, "select lookupValue from %s.lookup where lookupCode = 'annotRev'", blastpTarget[0]);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
strcat(refSeq, row[0]);
findTable = TRUE;
sqlFreeResult(&sr);
}
}
else if (hTableExists(blastpTarget[0], "refSeq"))
{
strcat(refSeq, "refSeq");
findTable = TRUE;
}
if (findTable)
{
- sprintf(query, "select chrom, cdsStart, cdsEnd from %s where name = '%s'",
+ sqlSafef(query, sizeof query, "select chrom, cdsStart, cdsEnd from %s where name = '%s'",
refSeq, blastpTarget[1]);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
hitStart = strtoul(row[1], buffer, 10) + blastpHits->tStart * 3 + 1;
hitEnd = strtoul(row[1], buffer, 10) + blastpHits->tEnd * 3;
printf("%s | \n",
row[0], hitStart, hitEnd, blastpTarget[0], blastpTarget[1]);
}
else
printf("%s | \n", blastpTarget[1]);
sqlFreeResult(&sr);
}
else
printf("%s | \n", blastpTarget[1]);
}
else
printf("%s | \n", blastpTarget[1]);
/* Get target gene product annotation */
if (hDbExists(blastpTarget[0]))
{
if (hTableExists(blastpTarget[0], "lookup"))
{
- sprintf(query, "select lookupValue from %s.lookup where lookupCode = 'annotRevXra'", blastpTarget[0]);
+ sqlSafef(query, sizeof query, "select lookupValue from %s.lookup where lookupCode = 'annotRevXra'", blastpTarget[0]);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
strcpy(xraTable, row[0]);
sqlFreeResult(&sr);
}
else
strcpy(product, "N/A");
- sprintf(query, "select product from %s.%s where name = '%s'", blastpTarget[0], xraTable, blastpTarget[1]);
+ sqlSafef(query, sizeof query, "select product from %s.%s where name = '%s'", blastpTarget[0], xraTable, blastpTarget[1]);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
strcpy(product, row[0]);
sqlFreeResult(&sr);
}
else
strcpy(product, "N/A");
}
else
{
ginfo = getGbProtCodeInfo(conn, blastpTarget[0], blastpTarget[1]);
if (ginfo != NULL && ginfo->product != NULL && differentString(ginfo->product,"none"))
strcpy(product, ginfo->product);
else
@@ -2616,31 +2616,31 @@
char queryTable[50];
unsigned int querySeqLength = 0;
struct sqlConnection *conn = hAllocConn(database);
struct bed *blastpTrack;
struct blastTab *blastpHitsList;
char query[512];
struct sqlResult *sr;
char **row;
cartWebStart(cart, database, "%s", "BlastP Alignment Hits");
blastpTrack = getBlastpTrackRecord(conn, tdb, targetName);
if (hTableExists(database, "lookup"))
{
- sprintf(query, "select lookupValue from lookup where lookupCode = 'annotRev'");
+ sqlSafef(query, sizeof query, "select lookupValue from lookup where lookupCode = 'annotRev'");
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
strcpy(queryTable, row[0]);
sqlFreeResult(&sr);
}
}
else
strcpy(queryTable, "refSeq");
printQueryGeneInfo(conn, blastpTrack, queryName, &querySeqLength, queryTable);
blastpHitsList = loadBlastpHits(conn, queryName);
printBlastpResult(conn, blastpHitsList, querySeqLength);
@@ -2657,31 +2657,31 @@
char queryTable[50];
unsigned int querySeqLength = 0;
struct sqlConnection *conn = hAllocConn(database);
struct bed *blastpTrack;
struct blastTab *blastpHitsList;
char query[512];
struct sqlResult *sr;
char **row;
cartWebStart(cart, database, "%s", "Homologs Within Genome by BlastP Search");
blastpTrack = getBlastpTrackRecord(conn, tdb, targetName);
if (hTableExists(database, "lookup"))
{
- sprintf(query, "select lookupValue from lookup where lookupCode = 'annotRev'");
+ sqlSafef(query, sizeof query, "select lookupValue from lookup where lookupCode = 'annotRev'");
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
strcpy(queryTable, row[0]);
sqlFreeResult(&sr);
}
}
else
strcpy(queryTable, "refSeq");
printQueryGeneInfo(conn, blastpTrack, queryName, &querySeqLength, queryTable);
blastpHitsList = loadSelfBlastpHits(conn, queryName, 1);
printBlastpResult(conn, blastpHitsList, querySeqLength);
@@ -2699,55 +2699,55 @@
char **row;
int seqCount;
char **buffer = NULL;
char *targetGeneName[2];
char blastxHits[] = "blastxHits";
unsigned int queryStart = 0;
unsigned int queryEnd = 0;
parseDelimitedString(blastxTrack->name, ':', targetGeneName, 2);
if (hTableExists(database, queryTable) && hTableExists(database, blastxHits))
{
/* Get query sequence from query table */
- sprintf(query, "select count(*) from %s where chrom = '%s' and chromStart <= %u and chromEnd >= %u",
+ sqlSafef(query, sizeof query, "select count(*) from %s where chrom = '%s' and chromStart <= %u and chromEnd >= %u",
queryTable, blastxTrack->chrom, blastxTrack->chromStart, blastxTrack->chromEnd);
srQuerySeq = sqlGetResult(conn, query);
if ((row = sqlNextRow(srQuerySeq)) != NULL)
{
seqCount = atoi(row[0]);
sqlFreeResult(&srQuerySeq);
if (seqCount == 1)
{
- sprintf(query, "select name, chromStart, chromEnd from %s where chrom = '%s' and chromStart <= %u and chromEnd >= %u",
+ sqlSafef(query, sizeof query, "select name, chromStart, chromEnd from %s where chrom = '%s' and chromStart <= %u and chromEnd >= %u",
queryTable, blastxTrack->chrom, blastxTrack->chromStart, blastxTrack->chromEnd);
srQuerySeq = sqlGetResult(conn, query);
if ((row = sqlNextRow(srQuerySeq)) != NULL)
{
strcpy(queryName, row[0]);
queryStart = strtoul(row[1], buffer, 10);
queryEnd = strtoul(row[2], buffer, 10);
}
sqlFreeResult(&srQuerySeq);
}
else
{
/* Check blastxHits if more than 1 query sequence is found within the region */
- sprintf(query, "select a.name, a.chromStart, a.chromEnd from %s a, %s b where a.chrom = '%s' and a.chromStart <= %u and a.chromEnd >= %u and a.name = b.query and b.target like '%%%s'",
+ sqlSafef(query, sizeof query, "select a.name, a.chromStart, a.chromEnd from %s a, %s b where a.chrom = '%s' and a.chromStart <= %u and a.chromEnd >= %u and a.name = b.query and b.target like '%%%s'",
queryTable, blastxHits,
blastxTrack->chrom, blastxTrack->chromStart, blastxTrack->chromEnd, targetGeneName[0]);
srQuerySeq = sqlGetResult(conn, query);
if ((row = sqlNextRow(srQuerySeq)) != NULL)
{
strcpy(queryName, row[0]);
queryStart = strtoul(row[1], buffer, 10);
queryEnd = strtoul(row[2], buffer, 10);
}
sqlFreeResult(&srQuerySeq);
}
if ((queryStart == 0) && (queryEnd == 0))
printf("Query sequence not found for %s at %s:%u-%u\n", blastxTrack->name, blastxTrack->chrom, blastxTrack->chromStart, blastxTrack->chromEnd);
else
@@ -2788,42 +2788,42 @@
struct blastTab *blastxHits;
struct sqlResult *srQuery = NULL;
struct bed *queryTrack = NULL;
char **rowQuery;
int rowOffset;
char **row;
char blastxHitsTable[] = "blastxHits";
unsigned int queryStart = 0;
unsigned int queryEnd = 0;
unsigned int qStart = 0;
unsigned int qEnd = 0;
if (hTableExists(database, queryTable) && hTableExists(database, blastxHitsTable))
{
rowOffset = hOffsetPastBin(database, seqName, queryTable);
- sprintf(query, "select * from %s where name = '%s'", queryTable, queryName);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s'", queryTable, queryName);
srQuery = sqlGetResult(conn, query);
if ((rowQuery = sqlNextRow(srQuery)) != NULL)
{
queryTrack = bedLoadN(rowQuery+rowOffset, 6);
queryStart = blastxTrack->chromStart - queryTrack->chromStart + 1;
queryEnd = blastxTrack->chromEnd - queryTrack->chromStart;
}
sqlFreeResult(&srQuery);
srQuery = NULL;
- sprintf(query, "select * from %s where query = '%s'", blastxHitsTable, queryName);
+ sqlSafef(query, sizeof query, "select * from %s where query = '%s'", blastxHitsTable, queryName);
srBlastxHits = sqlGetResult(conn, query);
while ((row = sqlNextRow(srBlastxHits)) != NULL)
{
blastxHits = blastTabLoad(row);
if (blastxHits->qStart < blastxHits->qEnd)
{
qStart = blastxHits->qStart;
qEnd = blastxHits->qEnd;
}
else
{
qStart = blastxHits->qEnd;
qEnd = blastxHits->qStart;
}
if (((qStart <= queryStart) && (qEnd >= queryEnd)) ||
@@ -2905,31 +2905,31 @@
cladePortionCount = parseDelimitedString(clade, '-', clades, 2);
printf(" \n");
printf("%s | \n", blastxTarget[1], tChrom, tStart, tEnd, genome);
if (cladePortionCount == 1)
printf("%s | \n", clades[0]);
else if (cladePortionCount == 2)
printf("%s %s | \n", clades[0], clades[1]);
/* Get target gene position from refSeq */
strcpy(refSeq, blastxTarget[0]);
strcat(refSeq, ".refSeq");
if (hDbExists(blastxTarget[0]) && hTableExists(blastxTarget[0], "refSeq"))
{
- sprintf(query, "select chrom, cdsStart, cdsEnd from %s where name = '%s'",
+ sqlSafef(query, sizeof query, "select chrom, cdsStart, cdsEnd from %s where name = '%s'",
refSeq, blastxTarget[1]);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
targetProteinStart = strtoul(row[1], buffer, 10);
targetProteinEnd = strtoul(row[2], buffer, 10);
hitStart = targetProteinStart + blastxHits->tStart * 3 + 1;
hitEnd = targetProteinStart + blastxHits->tEnd * 3;
printf("%s | \n",
row[0], hitStart, hitEnd, blastxTarget[0], blastxTarget[1]);
}
else
printf("%s | \n", blastxTarget[1]);
sqlFreeResult(&sr);
}
@@ -3126,31 +3126,31 @@
int pairCount = 0;
boolean forwardPrimer = TRUE;
genericHeader(tdb, primerName);
if (startsWith("Asn", primerName))
forwardPrimer = FALSE;
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
if (wordCount > 1)
bedSize = atoi(words[1]);
if (bedSize < 3) bedSize = 3;
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
- sprintf(query, "select * from %s where name = '%s'", tdb->table, primerName);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s'", tdb->table, primerName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
primer = bedLoadN(row+rowOffset, bedSize);
printf("Primer name: %s \n",primerName);
printf(" Position: "
"",
hgTracksPathAndSettings(), database, primer->chrom, primer->chromStart + 1, primer->chromEnd);
printf("%s:%d-%d \n", primer->chrom, primer->chromStart + 1, primer->chromEnd);
printf("Strand: %s \n", primer->strand);
printf("Genomic size: %d nt
\n", (primer->chromEnd - primer->chromStart));
sequence = hDnaFromSeq(database, primer->chrom, primer->chromStart, primer->chromEnd, dnaUpper);
if (sequence != NULL)
@@ -3181,52 +3181,52 @@
/* Print table column heading */
printf(" \n");
printf("Primer Name | \n");
printf("Primer Type | \n");
printf("Primer Sequence | \n");
printf("PCR Region | \n");
printf("PCR Length (bp) | \n");
printf("PCR Region GC Content (%%) | \n");
printf(" \n");
memset(query, 0, 512);
if (strcmp(primer->strand, "+") == 0)
{
if (hTableExists(database, "genomePcrPrimers"))
- sprintf(query, "select *, 'Array PCR' primerType from genomePcrPrimers where chrom = '%s' and chromStart > %d and strand = '-'", primer->chrom, primer->chromEnd);
+ sqlSafef(query, sizeof query, "select *, 'Array PCR' primerType from genomePcrPrimers where chrom = '%s' and chromStart > %d and strand = '-'", primer->chrom, primer->chromEnd);
if (hTableExists(database, "goldRTprimers"))
{
if (strcmp(query, "") != 0)
- sprintf(query, "%s union ", query);
- sprintf(query, "%sselect *, 'GOLD RT' primerType from goldRTprimers where chrom = '%s' and chromStart > %d and strand = '-'",
+ sqlSafef(query, sizeof query, "%s union ", query);
+ sqlSafef(query, sizeof query, "%sselect *, 'GOLD RT' primerType from goldRTprimers where chrom = '%s' and chromStart > %d and strand = '-'",
query, primer->chrom, primer->chromEnd);
}
- sprintf(query, "%s order by chromStart", query);
+ sqlSafef(query, sizeof query, "%s order by chromStart", query);
}
else
{
if (hTableExists(database, "genomePcrPrimers"))
- sprintf(query, "select *, 'Array PCR' primerType from genomePcrPrimers where chrom = '%s' and chromEnd < %d and strand = '+'", primer->chrom, primer->chromStart);
+ sqlSafef(query, sizeof query, "select *, 'Array PCR' primerType from genomePcrPrimers where chrom = '%s' and chromEnd < %d and strand = '+'", primer->chrom, primer->chromStart);
if (hTableExists(database, "goldRTprimers"))
{
if (strcmp(query, "") != 0)
- sprintf(query, "%s union ", query);
- sprintf(query, "%sselect *, 'GOLD RT' primerType from goldRTprimers where chrom = '%s' and chromEnd < %d and strand = '+'",
+ sqlSafef(query, sizeof query, "%s union ", query);
+ sqlSafef(query, sizeof query, "%sselect *, 'GOLD RT' primerType from goldRTprimers where chrom = '%s' and chromEnd < %d and strand = '+'",
query, primer->chrom, primer->chromStart);
}
- sprintf(query, "%s order by chromStart desc", query);
+ sqlSafef(query, sizeof query, "%s order by chromStart desc", query);
}
sr = sqlGetResult(conn, query);
while (((row = sqlNextRow(sr)) != NULL) && (pairCount < 6))
{
if ((forwardPrimer && startsWith("Asn", row[4])) || (!forwardPrimer && startsWith("Sn", row[4])))
{
printf("\n");
printf(""
"",
hgTracksPathAndSettings(), database, row[1], atoi(row[2]) + 1, atoi(row[3]));
printf("%s | \n", row[4]);
printf("%s | \n", row[7]);
sequence = hDnaFromSeq(database, row[1], atoi(row[2]), atoi(row[3]), dnaUpper);
@@ -3321,31 +3321,31 @@
struct sqlResult *sr;
char **row;
struct rnaHybridization *rnaHyb;
char rnaHybridizationTable[] = "rnaHybridization";
char tRNATable[] = "tRNAs";
char jgiTable[] = "jgiGene";
char *saveTableName;
int i;
cartWebStart(cart, database, "%s", "RNAHybridization Sites");
if (hTableExists(database, rnaHybridizationTable))
{
/* Get query gene from refSeq */
- sprintf(query, "select * from %s where name='%s'", rnaHybridizationTable, itemName);
+ sqlSafef(query, sizeof query, "select * from %s where name='%s'", rnaHybridizationTable, itemName);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
rnaHyb = rnaHybridizationLoad(row);
printf("Hybridization Site:
");
/* print hybridization site */
printf("");
printf("Pattern 5%s3 ", rnaHyb->patternSeq);
printf("         ");
for(i=0;imatchLength;i++)
printf("|");
printf(" ");
@@ -3412,52 +3412,52 @@
void doarCOGs(struct trackDb *tdb, char *itemName)
{
char query[512];
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char *dupe, *words[16];
char **row;
int wordCount;
int rowOffset;
struct arCOGs *infoload;
int start = cartInt(cart, "o");
int end = cartInt(cart, "t");
- sprintf(query, "select * from mgCommonDb.arcogdesc where name = '%s'", itemName);
- //sprintf(query, "select * from %s where query = '%s'", blastpHitsTable, queryName);
+ sqlSafef(query, sizeof query, "select * from mgCommonDb.arcogdesc where name = '%s'", itemName);
+ //sqlSafef(query, sizeof query, "select * from %s where query = '%s'", blastpHitsTable, queryName);
struct sqlResult *srarcogdesc = sqlGetResult(conn, query);
struct arcogdesc *description = NULL;
while ((row = sqlNextRow(srarcogdesc)) != NULL)
{
struct arcogdesc *element;
element = arcogdescLoad(row);
slAddTail(&description, element);
}
sqlFreeResult(&srarcogdesc);
genericHeader(tdb,itemName);
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
rowOffset = hOffsetPastBin(database,seqName, tdb->table);
- sprintf(query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d and chromEnd = '%d';", tdb->table, itemName,seqName,start, end);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d and chromEnd = '%d';", tdb->table, itemName,seqName,start, end);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
infoload = arCOGsLoad(row+rowOffset);
printf("Name: %s \n", infoload->name);
printf("Description: %s \n", description->description);
printf("Code: %s \n", description->code);
printf("Gene: %s \n", infoload->gene);
printf("Position: "
"",
hgTracksPathAndSettings(), database, infoload->chrom, infoload->chromStart + 1, infoload->chromEnd);
printf("%s:%d-%d \n", infoload->chrom, infoload->chromStart + 1, infoload->chromEnd);
printf("Strand: %s \n", infoload->strand);
printf("Genomic size: %d nt \n", (infoload->chromEnd - infoload->chromStart));
@@ -3484,31 +3484,31 @@
int start = cartInt(cart, "o");
int end = cartInt(cart, "t");
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
if (wordCount > 1)
bedSize = atoi(words[1]);
if (bedSize < 3) bedSize = 3;
genericHeader(tdb,itemName);
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
rowOffset = hOffsetPastBin(database,seqName, tdb->table);
- sprintf(query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d and chromEnd = '%d';", tdb->table, itemName,seqName,start, end);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d and chromEnd = '%d';", tdb->table, itemName,seqName,start, end);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
infoload = bedLoadN(row+rowOffset, bedSize);
printf("Name: %s\n", infoload->name);
printf(" List of Orthologs ",database,infoload->name);
printf("Position: "
"",
hgTracksPathAndSettings(), database, infoload->chrom, infoload->chromStart + 1, infoload->chromEnd);
printf("%s:%d-%d \n", infoload->chrom, infoload->chromStart + 1, infoload->chromEnd);
printf("Strand: %s \n", infoload->strand);
printf("Genomic size: %d nt \n", (infoload->chromEnd - infoload->chromStart));
if (infoload->next != NULL)
printf(" \n");
@@ -3526,51 +3526,51 @@
char *dupe, *words[16];
char **row;
int wordCount;
int rowOffset;
struct cddInfo *infoload;
int bedSize = 0;
int start = cartInt(cart, "o");
int end = cartInt(cart, "t");
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
if (wordCount > 1)
bedSize = atoi(words[1]);
if (bedSize < 3) bedSize = 3;
- sprintf(query, "select * from mgCommonDb.cddDesc where accession = '%s'", itemName);
- //sprintf(query, "select * from %s where query = '%s'", blastpHitsTable, queryName);
+ sqlSafef(query, sizeof query, "select * from mgCommonDb.cddDesc where accession = '%s'", itemName);
+ //sqlSafef(query, sizeof query, "select * from %s where query = '%s'", blastpHitsTable, queryName);
struct sqlResult *srCddDesc = sqlGetResult(conn, query);
struct cddDesc *description = NULL;
while ((row = sqlNextRow(srCddDesc)) != NULL)
{
struct cddDesc *element;
element = cddDescLoad(row);
slAddTail(&description, element);
}
sqlFreeResult(&srCddDesc);
genericHeader(tdb,itemName);
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
rowOffset = hOffsetPastBin(database,seqName, tdb->table);
- sprintf(query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d and chromEnd = '%d';", tdb->table, itemName,seqName,start, end);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d and chromEnd = '%d';", tdb->table, itemName,seqName,start, end);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
infoload = cddInfoLoad(row+rowOffset);
printf("Name: %s \n", infoload->fullname);
printf("Accession: %s",
infoload->name, infoload->NCBInum);
printf(" Link to NCBI Site \n");
printf("E-value: %0.0e \n", infoload->evalue);
printf("Description: %s \n", description->name);
printf("Protein Identity: %u%% \n", infoload->percentident);
printf("Percent Length: %u%% \n", infoload->percentlength);
printf("Position: "
"",
hgTracksPathAndSettings(), database, infoload->chrom, infoload->chromStart + 1, infoload->chromEnd);
@@ -3594,31 +3594,31 @@
char *dupe, *words[16];
char **row;
int wordCount;
int rowOffset;
struct megablastInfo *infoload;
int start = cartInt(cart, "o");
int end = cartInt(cart, "t");
genericHeader(tdb,itemName);
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
rowOffset = hOffsetPastBin(database,seqName, tdb->table);
- sprintf(query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d and chromEnd = '%d';", tdb->table, itemName,seqName,start, end);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d and chromEnd = '%d';", tdb->table, itemName,seqName,start, end);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
infoload = megablastInfoLoad(row+rowOffset);
printf("Name: %s \n", infoload->name);
printf("Accession: %s",
infoload->name, infoload->name);
printf(" Link to NCBI Site \n");
printf("Description: %s \n", infoload->fullname);
printf("E-value: %0.0e", infoload->evalue);
#ifdef LISTUI
printf(" Sort by E-value",database);
#endif
printf(" \n");
printf("Protein Identity: %u%%\n", infoload->percentident);
@@ -3655,31 +3655,31 @@
int start = cartInt(cart, "o");
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
if (wordCount > 1)
bedSize = atoi(words[1]);
if (bedSize < 3) bedSize = 3;
genericHeader(tdb,itemName);
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
- sprintf(query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d;", tdb->table, itemName,seqName,start);
+ sqlSafef(query, sizeof query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d;", tdb->table, itemName,seqName,start);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
infoload = alignInfoLoad(row+rowOffset);
printf("Name: %s ", infoload->name);
linkToOtherBrowserTitle(infoload->orgn, infoload->alignChrom, infoload->alignChromStart + 1, infoload->alignChromEnd, "Aligned Feature");
//printf("",
//hgTracksPathAndSettings(), infoload->orgn, infoload->alignChrom, infoload->alignChromStart + 1, infoload->alignChromEnd);
printf("Link to Feature \n" );
printf("Position: "
"",
hgTracksPathAndSettings(), database, infoload->chrom, infoload->chromStart + 1, infoload->chromEnd);
printf("%s:%d-%d \n", infoload->chrom, infoload->chromStart + 1, infoload->chromEnd);
@@ -3708,31 +3708,31 @@
char **row;
int wordCount;
int rowOffset;
int bedSize = 0;
int pairCount = 0;
genericHeader(tdb, crisprName);
dupe = cloneString(tdb->type);
wordCount = chopLine(dupe, words);
if (wordCount > 1)
bedSize = atoi(words[1]);
if (bedSize < 3) bedSize = 3;
rowOffset = hOffsetPastBin(database, seqName, tdb->table);
- safef(query, ArraySize(query), "select * from %s where name = '%s'", tdb->table, crisprName);
+ sqlSafef(query, ArraySize(query), "select * from %s where name = '%s'", tdb->table, crisprName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
crispr = bedLoadN(row+rowOffset, bedSize);
printf("Name: %s \n", crisprName);
printf("Position: "
"",
hgTracksPathAndSettings(), database, crispr->chrom, crispr->chromStart + 1, crispr->chromEnd);
printf("%s:%d-%d \n", crispr->chrom, crispr->chromStart + 1, crispr->chromEnd);
printf("Strand: %s \n", crispr->strand);
printf("Genomic size: %d nt
\n", (crispr->chromEnd - crispr->chromStart));
printf("Number of spacers: %u
\n", crispr->blockCount - 1);
sequence = hDnaFromSeq(database, crispr->chrom, crispr->chromStart, crispr->chromEnd, dnaUpper);
if (sequence != NULL)
| | |