9f6d2ecec7b6362e055b19017c34ce823ed0a993 max Mon Dec 5 18:33:18 2011 -0800 patches to t2g to make it work even if no article/sequence table exist diff --git src/hg/hgc/t2g.c src/hg/hgc/t2g.c index f1b334d..2d7e8ed 100644 --- src/hg/hgc/t2g.c +++ src/hg/hgc/t2g.c @@ -34,34 +34,39 @@ { abstract = "(No abstract found for this article. Please use the link to the fulltext above.)"; } docId = cloneString(row[0]); printf("

%s

\n", row[3]); printf("%s\n", row[1], row[2]); printf("

%s

\n", row[4]); printf("

%s

\n", abstract); } sqlFreeResult(&sr); return docId; } struct hash* getSeqIdHash(struct sqlConnection* conn, char* trackTable, char* docId, char *item, char* seqName, int start) { - /* get sequence-Ids for feature that was clicked (item&startPos are unique) and return as hash */ - // there must be an easier way to do this... - // couldn't find a function that splits a string and converts it to a list 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 (t2gDebug) puts(query); char* seqIdCoordString = sqlQuickString(conn, query); char* seqIdCoords[1024]; int partCount = chopString(seqIdCoordString, ",", seqIdCoords, ArraySize(seqIdCoords)); int i; struct hash *seqIdHash = NULL; seqIdHash = newHash(0); for (i=0; i>%s
%s
", annotId, seq); } else { printf("\n", HG_COL_LOCAL_TABLE); if (showDesc) printf("%s\n", fileDesc); //printf("%s\n", snippet); printf("%s\n", snippet); @@ -177,31 +182,35 @@ } printf("\n"); webEndSectionTables(); sqlFreeResult(&sr); return foundSkippedRows; } void printSeqInfo(struct sqlConnection* conn, char* trackTable, char* docId, 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, docId, item, seqName, start); bool skippedRows; + if (clickedSeqs) skippedRows = printSeqSection(docId, "Sequences used to construct this feature", fileDesc, conn, clickedSeqs, 1, fasta); + else + skippedRows=1; + if (skippedRows) printSeqSection(docId, "Other Sequences in this article", fileDesc, conn, clickedSeqs, 0, fasta); //else //printf("

No more sequences

"); if (endsWith(trackTable, "Elsevier")) printf("

Article information and excerpts are Copyright 2011 Elsevier B.V. All rights reserved.

"); freeHash(&clickedSeqs); } void printTrackVersion(struct trackDb *tdb, struct sqlConnection* conn, char* item) { char versionString[256]; char dateReference[256]; char headerTitle[512];