2af949e966b17c1cf0855c9877c1b25a81c63be5
max
Tue Mar 27 13:57:04 2012 -0700
moving link to top of table
diff --git src/hg/hgc/pubs.c src/hg/hgc/pubs.c
index 5ff910b..5d346af 100644
--- src/hg/hgc/pubs.c
+++ src/hg/hgc/pubs.c
@@ -1,704 +1,706 @@
/* pubs.c - display details of publiations literature track (pubsxxx tables) */
#include "common.h"
#include "jksql.h"
#include "hdb.h"
#include "hgc.h"
#include "hgColors.h"
#include "trackDb.h"
#include "web.h"
#include "hash.h"
#include "obscure.h"
#include "common.h"
#include "string.h"
//include "hgTrackUi.h"
// cgi var to activate debug output
static int pubsDebug = 0;
// internal section types in mysql table
static char* pubsSecNames[] ={
"header", "abstract",
"intro", "methods",
"results", "discussion",
"conclusions", "ack",
"refs", "unknown" };
//
// whether a checkbox is checked by default, have to correspond to pubsSecNames
static int pubsSecChecked[] ={
1, 1,
1, 1,
1, 1,
1, 0,
0, 1 };
static char* pubsSequenceTable;
static char* mangleUrl(char* url)
/* add publisher specific parameters to url and return new url*/
{
if (!stringIn("sciencedirect.com", url))
return url;
// cgi param to add the "UCSC matches" sciverse application to elsevier's sciencedirect
char* sdAddParam = "?svAppaddApp=298535";
char* longUrl = catTwoStrings(url, sdAddParam);
char* newUrl = replaceChars(longUrl, "article", "svapps");
return newUrl;
}
static void printFilterLink(char* pslTrack, char* articleId)
/* print a link to hgTracks with an additional cgi param to activate the single article filter */
{
int start = cgiInt("o");
int end = cgiInt("t");
- printf(" ",
+ printf(" ",
hgTracksPathAndSettings(), database, seqName, start+1, end, articleId, pslTrack);
- char startBuf[64], endBuf[64];
- sprintLongWithCommas(startBuf, start + 1);
- sprintLongWithCommas(endBuf, end);
- printf("Show these sequence matches individually on genome browser");
+ printf("Show these sequence matches individually on genome browser
\n");
}
static void printLimitWarning(struct sqlConnection *conn, char* markerTable,
char* item, int itemLimit, char* sectionList)
{
char query[4000];
safef(query, sizeof(query), "SELECT COUNT(*) from %s WHERE markerId='%s' AND section in (%s) ", markerTable, item, sectionList);
if (sqlNeedQuickNum(conn, query) > itemLimit)
{
printf("This marker is mentioned more than %d times
\n", itemLimit);
printf("The results would take too long to load in your browser and are "
"therefore limited to %d articles.
\n", itemLimit); } } static void printMarkerSnippets(struct sqlConnection *conn, char* articleTable, char* markerTable, char* item) { /* do not show more snippets than this limit */ int itemLimit=1000; printSectionCheckboxes(); char* sectionList = makeSqlMarkerList(); printLimitWarning(conn, markerTable, item, itemLimit, sectionList); printf("
", snippets); printf("
%s
\n", authors); printf("%s\n", url, title); printf("%s", cit); if (strlen(pmid)!=0 && strcmp(pmid, "0")) printf(", PMID%s\n", pmid, pmid); printf("
\n"); printf("%s
\n", abstract); sqlFreeResult(&sr); return articleId; } static struct hash* getSeqIdHash(struct sqlConnection* conn, char* trackTable, \ char* articleId, char *item, char* seqName, int start) /* return a hash with the sequence IDs for a given chain of BLAT matches */ { char query[512]; /* check first if the column exists (some debugging tables on hgwdev don't have seqIds) */ safef(query, sizeof(query), "SHOW COLUMNS FROM %s LIKE 'seqIds';", trackTable); char* seqIdPresent = sqlQuickString(conn, query); if (!seqIdPresent) { return NULL; } /* get sequence-Ids for feature that was clicked (item&startPos are unique) and return as hash*/ safef(query, sizeof(query), "SELECT seqIds,'' FROM %s WHERE name='%s' " "and chrom='%s' and chromStart=%d;", trackTable, item, seqName, start); if (pubsDebug) printf("%s"); - printFilterLink(pslTable, articleId); - } webEndSectionTables(); sqlFreeResult(&sr); return foundSkippedRows; } static void printSeqInfo(struct sqlConnection* conn, char* trackTable, char* pslTable, char* articleId, char* item, char* seqName, int start, bool fileDesc, bool fasta) /* print sequences, split into two sections * two sections: one for sequences that were clicked, one for all others*/ { struct hash* clickedSeqs = getSeqIdHash(conn, trackTable, articleId, item, seqName, start); bool skippedRows; if (clickedSeqs) skippedRows = printSeqSection(articleId, "Sequences used to construct this feature", \ fileDesc, conn, clickedSeqs, 1, fasta, pslTable); else skippedRows=1; if (skippedRows) printSeqSection(articleId, "Other Sequences in this article", \ fileDesc, conn, clickedSeqs, 0, fasta, pslTable); printf("
Copyright 2012 Elsevier B.V. All rights reserved.
");
freeHash(&clickedSeqs);
}
static void printTrackVersion(struct trackDb *tdb, struct sqlConnection* conn, char* item)
{
char versionString[256];
char dateReference[256];
char headerTitle[512];
/* see if hgFixed.trackVersion exists */
boolean trackVersionExists = hTableExists("hgFixed", "trackVersion");
if (trackVersionExists)
{
char query[256];
safef(query, sizeof(query), \
"SELECT version,dateReference FROM hgFixed.trackVersion "
"WHERE db = '%s' AND name = 'pubs' ORDER BY updateTime DESC limit 1", database);
struct sqlResult *sr = sqlGetResult(conn, query);
char **row;
/* in case of NULL result from the table */
versionString[0] = 0;
while ((row = sqlNextRow(sr)) != NULL)
{
safef(versionString, sizeof(versionString), "version %s",
row[0]);
safef(dateReference, sizeof(dateReference), "%s",
row[1]);
}
sqlFreeResult(&sr);
}
else
{
versionString[0] = 0;
dateReference[0] = 0;
}
if (versionString[0])
safef(headerTitle, sizeof(headerTitle), "%s - %s", item, versionString);
else
safef(headerTitle, sizeof(headerTitle), "%s", item);
genericHeader(tdb, headerTitle);
}
static void printPositionAndSize(int start, int end, bool showSize)
{
printf("Position: "
"",
hgTracksPathAndSettings(), database, seqName, start+1, end);
char startBuf[64], endBuf[64];
sprintLongWithCommas(startBuf, start + 1);
sprintLongWithCommas(endBuf, end);
printf("%s:%s-%s
\n", seqName, startBuf, endBuf);
long size = end - start;
sprintLongWithCommas(startBuf, size);
if (showSize)
printf("Genomic Size: %s
\n", startBuf);
}
static bioSeq *getSeq(struct sqlConnection *conn, char *table, char *id)
/* copied from otherOrgs.c */
{
char query[512];
struct sqlResult *sr;
char **row;
bioSeq *seq = NULL;
safef(query, sizeof(query),
"select sequence from %s where annotId = '%s'", table, id);
sr = sqlGetResult(conn, query);
if ((row = sqlNextRow(sr)) != NULL)
{
AllocVar(seq);
seq->name = cloneString(id);
seq->dna = cloneString(row[0]);
seq->size = strlen(seq->dna);
}
sqlFreeResult(&sr);
return seq;
}
void pubsAli(struct sqlConnection *conn, char *pslTable, char *seqTable, char *item)
/* this is just a ripoff from htcCdnaAli, similar to markd's transMapAli */
{
bioSeq *oSeq = NULL;
writeFramesetType();
puts("");
printf("