fbdc691703e4bc2d98fcdb2014fe6fa19771c104 braney Fri Feb 10 17:05:10 2017 -0800 make building a custom track with blat results an option on the hgBlat page. Add some features to bigPsl click support to get the same kind of UI that hgBlat provides. diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c index be8b9f3..9c58a17 100644 --- src/hg/hgc/hgc.c +++ src/hg/hgc/hgc.c @@ -244,30 +244,31 @@ #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" +#include "customFactory.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 */ @@ -2969,41 +2970,54 @@ char *item, int start, int end) /* Handle click in big psl track. */ { 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 showEvery = sameString(item, "PrintAllSequences"); boolean showAll = trackDbSettingOn(tdb, "showAll"); unsigned seqTypeField = bbExtraFieldIndex(bbi, "seqType"); -struct bigBedInterval *bb, *bbList; +struct bigBedInterval *bb, *bbList = NULL; // If showAll is on, show all alignments with this qName, not just the // selected one. -if (showAll) +if (showEvery) + { + struct bbiChromInfo *chrom, *chromList = bbiChromList(bbi); + for (chrom = chromList; chrom != NULL; chrom = chrom->next) + { + char *chromName = chrom->name; + int start = 0, end = chrom->size; + int itemsLeft = 0; // Zero actually means no limit.... + struct bigBedInterval *intervalList = bigBedIntervalQuery(bbi, chromName, + start, end, itemsLeft, lm); + slCat(&bbList, intervalList); + } + } +else 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 */ 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; @@ -3017,39 +3031,45 @@ } } 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)) + if (showEvery || sameString(bedRow[3], item)) { struct psl *psl= pslFromBigPsl(chromName, bb, seqTypeField, NULL, NULL); slAddHead(&pslList, psl); } } +char *sort = cartUsualString(cart, "sort", pslSortList[0]); +pslSortListByVar(&pslList, sort); + +if (showEvery) + printf("
"); if (startsWith("chr", pslList->tName)) printf("BROWSER | SIZE IDENTITY CHROMOSOME STRAND START END QUERY START END TOTAL\n"); else printf("BROWSER | SIZE IDENTITY SCAFFOLD STRAND START END QUERY START END TOTAL\n"); printf("-----------------------------------------------------------------------------------------------------\n"); for (isClicked = 1; isClicked >= 0; isClicked -= 1) { for (psl = pslList; psl != NULL; psl = psl->next) { if (isPslToPrintByClick(psl, startFirst, isClicked)) { char otherString[512]; + char *qName = itemIn; + if (sameString(itemIn, "PrintAllSequences")) + qName = psl->qName; safef(otherString, sizeof(otherString), "%d&aliTable=%s", psl->tStart, tableName); printf("browser | ", hgTracksPathAndSettings(), database, psl->tName, psl->tStart+1, psl->tEnd); - hgcAnchorWindow(hgcCommand, itemIn, psl->tStart, psl->tEnd, otherString, psl->tName); + hgcAnchorWindow(hgcCommand, qName, psl->tStart, psl->tEnd, otherString, psl->tName); printf("%5d %5.1f%% %9s %s %9d %9d %20s %5d %5d %5d", psl->match + psl->misMatch + psl->repMatch, 100.0 - pslCalcMilliBad(psl, TRUE) * 0.1, skipChr(psl->tName), psl->strand, psl->tStart + 1, psl->tEnd, psl->qName, psl->qStart+1, psl->qEnd, psl->qSize); printf("\n"); } } } printf(""); } void printAlignmentsExtra(struct psl *pslList, int startFirst, char *hgcCommand, char *hgcCommandInWindow, char *tableName, char *itemIn) /* Print list of mRNA alignments with special "in window" alignment function. */ @@ -25111,30 +25135,111 @@ while (*c != 0) { if ((*c=='&') || (*c=='<')) doNotBreak = TRUE; if (*c==';' || (*c =='>')) doNotBreak = FALSE; printf("%c", *c); if (i % distance == 0 && ! doNotBreak) printf("