8f9e939cc256fdaaf7bda199bd9099538bfc6fb7
braney
Mon Jan 23 13:46:52 2017 -0800
print out extra fields from bigPsl
diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 9486106..20c8590 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -1526,31 +1526,31 @@
char *idUrl = replaceInUrl(url, idForUrl, cart, database, seqName, winStart,
winEnd, tdb->track, encode);
printf("%s", idUrl, itemName);
}
printf("\n");
freeMem(slIds);
//freeMem(idNames);
}
int extraFieldsStart(struct trackDb *tdb, int fieldCount, struct asObject *as)
/* return the index of the first extra field */
{
int start = 0;
char *type = cloneString(tdb->type);
char *word = nextWord(&type);
-if (word && (sameWord(word,"bed") || sameWord(word,"bigBed") || sameWord(word,"bigGenePred")))
+if (word && (sameWord(word,"bed") || sameWord(word,"bigBed") || sameWord(word,"bigGenePred") || sameWord(word,"bigPsl")))
{
if (NULL != (word = nextWord(&type)))
start = sqlUnsigned(word);
else // custom beds and bigBeds may not have full type "begBed 9 +"
start = max(0,slCount(as->columnList) - fieldCount);
}
return start;
}
struct slPair* getExtraFields(struct trackDb *tdb, char **fields, int fieldCount)
/* return the extra field names and their values as a list of slPairs. */
{
struct asObject *as = asForDb(tdb, database);
if (as == NULL)
return NULL;
@@ -2990,30 +2990,56 @@
struct bigBedInterval *bb, *bbList;
// If showAll is on, show all alignments with this qName, not just the
// selected one.
if (showAll)
{
int fieldIx;
struct bptFile *bpt = bigBedOpenExtraIndex(bbi, "name", &fieldIx);
struct lm *lm = lmInit(0);
bbList = bigBedNameQuery(bbi, bpt, fieldIx, item, lm);
}
else
bbList = bigBedIntervalQuery(bbi, seqName, ivStart, ivEnd, 0, lm);
+/* print out extra fields */
+boolean firstTime = TRUE;
+for (bb = bbList; bb != NULL; bb = bb->next)
+ {
+ char *restFields[256];
+ int restCount = chopTabs(cloneString(bb->rest), restFields);
+ if (sameString(restFields[0], item))
+ {
+ int bedSize = 25;
+ int restBedFields = bedSize - 3;
+ if (restCount > restBedFields)
+ {
+ if (firstTime)
+ {
+ printf(" %s Extra fields:
", item);
+ firstTime = FALSE;
+ };
+
+ char **extraFields = (restFields + restBedFields);
+ int extraFieldCount = restCount - restBedFields;
+ int printCount = extraFieldsPrint(tdb,NULL,extraFields, extraFieldCount);
+ printCount += 0;
+ }
+ }
+ }
+
char *bedRow[32];
char startBuf[16], endBuf[16];
int lastChromId = -1;
char chromName[bbi->chromBpt->keySize+1];
for (bb = bbList; bb != NULL; bb = bb->next)
{
bbiCachedChromLookup(bbi, bb->chromId, lastChromId, chromName, sizeof(chromName));
lastChromId=bb->chromId;
bigBedIntervalToRow(bb, chromName, startBuf, endBuf, bedRow, 4);
if (sameString(bedRow[3], item))
{
struct psl *psl= pslFromBigPsl(chromName, bb, seqTypeField, NULL, NULL);