3a5ceb6cf9b3a4869e57ab621d1143fbd0573a5a braney Wed Nov 23 17:01:52 2016 -0800 implements blat results to custom track using bigPsl. Requires hg.conf variable useBlatBigPsl=on, otherwise old behavior exists diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c index 631adc8..9a2ed6f 100644 --- src/hg/hgc/hgc.c +++ src/hg/hgc/hgc.c @@ -243,30 +243,31 @@ #include "gwasCatalog.h" #include "parClick.h" #include "mdb.h" #include "yaleGencodeAssoc.h" #include "itemDetailsHtml.h" #include "trackVersion.h" #include "numtsClick.h" #include "geneReviewsClick.h" #include "bigBed.h" #include "bigPsl.h" #include "bedTabix.h" #include "longRange.h" #include "hmmstats.h" #include "aveStats.h" #include "trix.h" +#include "bPlusTree.h" static char *rootDir = "hgcData"; #define LINESIZE 70 /* size of lines in comp seq feature */ struct cart *cart; /* User's settings. */ char *seqName; /* Name of sequence we're working on. */ int winStart, winEnd; /* Bounds of sequence. */ char *database; /* Name of mySQL database. */ char *organism; /* Colloquial name of organism. */ char *genome; /* common name, e.g. Mouse, Human */ char *scientificName; /* Scientific name of organism. */ struct hash *trackHash; /* A hash of all tracks - trackDb valued */ @@ -2960,58 +2961,77 @@ { struct psl* psl; printf("
\n"); printf("#match\tmisMatches\trepMatches\tnCount\tqNumInsert\tqBaseInsert\ttNumInsert\tBaseInsert\tstrand\tqName\tqSize\tqStart\tqEnd\ttName\ttSize\ttStart\ttEnd\tblockCount\tblockSizes\tqStarts\ttStarts\n"); for (psl = pslList; psl != NULL; psl = psl->next) { pslTabOut(psl, stdout); } printf("\n"); } void genericBigPslClick(struct sqlConnection *conn, struct trackDb *tdb, char *item, int start, int end) /* Handle click in big psl track. */ { -struct psl* pslList; +struct psl* pslList = NULL; char *fileName = bbiNameFromSettingOrTable(tdb, conn, tdb->table); struct bbiFile *bbi = bigBedFileOpen(fileName); struct lm *lm = lmInit(0); int ivStart = start, ivEnd = end; if (start == end) { // item is an insertion; expand the search range from 0 bases to 2 so we catch it: ivStart = max(0, start-1); ivEnd++; } +boolean showAll = trackDbSettingOn(tdb, "showAll"); unsigned seqTypeField = bbExtraFieldIndex(bbi, "seqType"); -struct bigBedInterval *bb, *bbList = bigBedIntervalQuery(bbi, seqName, ivStart, ivEnd, 0, lm); +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); + 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) { - bigBedIntervalToRow(bb, seqName, startBuf, endBuf, bedRow, 4); - struct bed *bed = bedLoadN(bedRow, 4); - if (sameString(bed->name, item)) + bbiCachedChromLookup(bbi, bb->chromId, lastChromId, chromName, sizeof(chromName)); + + lastChromId=bb->chromId; + bigBedIntervalToRow(bb, chromName, startBuf, endBuf, bedRow, 4); + if (sameString(bedRow[3], item)) { - bb->next = NULL; - break; + struct psl *psl= pslFromBigPsl(chromName, bb, seqTypeField, NULL, NULL); + slAddHead(&pslList, psl); } } -pslList = pslFromBigPsl(seqName, bb, seqTypeField, NULL, NULL); printf("