13b584581e6d7b1860e0cab97adc3594b1899308
braney
Mon Aug 7 12:05:10 2023 -0700
add instaPort to bigBed support
diff --git src/hg/hgc/bigBedClick.c src/hg/hgc/bigBedClick.c
index 20bdd03..0140cb5 100644
--- src/hg/hgc/bigBedClick.c
+++ src/hg/hgc/bigBedClick.c
@@ -2,30 +2,31 @@
/* Copyright (C) 2013 The Regents of the University of California
* See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */
#include "common.h"
#include "wiggle.h"
#include "cart.h"
#include "hgc.h"
#include "hCommon.h"
#include "hgColors.h"
#include "bigBed.h"
#include "hui.h"
#include "subText.h"
#include "web.h"
#include "chromAlias.h"
+#include "instaPort.h"
static void bigGenePredLinks(char *track, char *item)
/* output links to genePred driven sequence dumps */
{
printf("
Links to sequence:
\n");
printf("\n");
puts("- \n");
hgcAnchorSomewhere("htcTranslatedPredMRna", item, "translate", seqName);
printf("Translated Protein from genomic DNA\n");
puts("
\n");
puts("- \n");
hgcAnchorSomewhere("htcGeneMrna", item, track, seqName);
printf("Predicted mRNA \n");
puts("
\n");
@@ -360,51 +361,55 @@
/* Handle click in generic bigBed track. */
{
char *chrom = cartString(cart, "c");
/* Open BigWig file and get interval list. */
struct bbiFile *bbi = bigBedFileOpenAlias(fileName, chromAliasFindAliases);
struct lm *lm = lmInit(0);
int ivStart = start, ivEnd = end;
char *itemForUrl = item;
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++;
}
-struct bigBedInterval *bbList = bigBedIntervalQuery(bbi, chrom, ivStart, ivEnd, 0, lm);
+char *instaFile = cloneString(trackDbSetting(tdb, "instaPortUrl"));
+struct hash *chainHash = NULL;
+struct bigBedInterval *bbList = NULL;
+if (instaFile)
+ bbList = instaIntervals(instaFile, bbi, chrom, ivStart, ivEnd, &chainHash);
+else
+ bbList = bigBedIntervalQuery(bbi, chrom, ivStart, ivEnd, 0, lm);
/* Get bedSize if it's not already defined. */
if (bedSize == 0)
{
bedSize = bbi->definedFieldCount;
}
char *scoreFilter = cartOrTdbString(cart, tdb, "scoreFilter", NULL);
int minScore = 0;
if (scoreFilter)
minScore = atoi(scoreFilter);
/* Find particular item in list - matching start, and item if possible. */
boolean found = FALSE;
boolean firstTime = TRUE;
struct bigBedInterval *bb;
for (bb = bbList; bb != NULL; bb = bb->next)
{
- if (!(bb->start == start && bb->end == end))
- continue;
if (bedSize > 3)
{
char *name = cloneFirstWordByDelimiterNoSkip(bb->rest, '\t');
boolean match = (isEmpty(name) && isEmpty(item)) || sameOk(name, item);
freez(&name);
if (!match)
continue;
}
found = TRUE;
if (firstTime)
printf("
\n");
int seq1Seq2Fields = 0;
// check for seq1 and seq2 in columns 7+8 (eg, pairedTagAlign)
boolean seq1Seq2 = sameOk(trackDbSetting(tdb, BASE_COLOR_USE_SEQUENCE), "seq1Seq2");
@@ -425,32 +430,43 @@
restBedFields = bedSize - 3;
if (restCount > restBedFields)
{
extraFields = (restFields + restBedFields);
extraFieldCount = restCount - restBedFields;
extraFieldPairs = getExtraFields(tdb, extraFields, extraFieldCount);
}
}
int bbFieldCount = bigBedIntervalToRow(bb, chrom, startBuf, endBuf, fields,
bedSize+seq1Seq2Fields);
if (bbFieldCount != bedSize+seq1Seq2Fields)
{
errAbort("Disagreement between trackDb field count (%d) and %s fieldCount (%d)",
bedSize, fileName, bbFieldCount);
}
- struct bed *bed = bedLoadN(fields, bedSize);
- if (bedSize >= 6 && scoreFilter && bed->score < minScore)
+ struct bed *bed = NULL;
+ if (instaFile)
+ {
+ if ((bed = instaBed(bbi, chainHash, bb)) == NULL)
+ errAbort("can't port %s",fields[3]);
+ }
+ else
+ {
+ bed = bedLoadN(fields, bedSize);
+ }
+ if ((bed == NULL) || (bedSize >= 6 && scoreFilter && bed->score < minScore))
+ continue;
+ if (!(bed->chromStart == start && bed->chromEnd == end))
continue;
// if there are extra fields, load them up because we may want to use them in URL:
itemForUrl = getIdInUrl(tdb, item);
printCustomUrlWithFields(tdb, bed->name, bed->name, item == itemForUrl, extraFieldPairs);
if (itemForUrl)
printIframe(tdb, itemForUrl);
bedPrintPos(bed, bedSize, tdb);
// display seq1 and seq2
if (seq1Seq2 && bedSize+seq1Seq2Fields == 8)
printf("Sequence 1 | Sequence 2 |
"
" %s | %s |
", fields[6], fields[7]);
else if (restCount > 0)