From 03d9c410171902cfb9b4d8ed67d23e455f28b23b Mon Sep 17 00:00:00 2001 From: Douglass Turner Date: Thu, 3 Nov 2022 02:20:09 -0400 Subject: [PATCH] Add bpp threshold of 10 to sequence track rendering (#1560) * Add bpp threshold of 10 to sequence track rendering * Update trackViewport.js * update Co-authored-by: Jim Robinson <933148+jrobinso@users.noreply.github.com> --- js/sequenceTrack.js | 10 ++++++---- js/trackViewport.js | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/js/sequenceTrack.js b/js/sequenceTrack.js index 86ff1919a..caf13cebd 100755 --- a/js/sequenceTrack.js +++ b/js/sequenceTrack.js @@ -111,6 +111,8 @@ const FRAME_HEIGHT = 25 const FRAME_BORDER = 5 const BP_PER_PIXEL_THRESHOLD = 1 / 10 +const bppFeatureFetchThreshold = 10 + class SequenceTrack { constructor(config, browser) { @@ -163,7 +165,6 @@ class SequenceTrack { ] } - contextMenuItemList(clickState) { const viewport = clickState.viewport if (viewport.referenceFrame.bpPerPixel <= 1) { @@ -214,7 +215,6 @@ class SequenceTrack { } } - translateSequence(seq) { const threeFrame = [[], [], []] @@ -241,9 +241,11 @@ class SequenceTrack { } async getFeatures(chr, start, end, bpPerPixel) { + start = Math.floor(start) end = Math.floor(end) - if (bpPerPixel && bpPerPixel > 1) { + + if (bpPerPixel && bpPerPixel > bppFeatureFetchThreshold) { return null } else { const sequence = await this.browser.genome.sequence.getSequence(chr, start, end) @@ -381,7 +383,7 @@ class SequenceTrack { } -export {defaultSequenceTrackOrder} +export {defaultSequenceTrackOrder, bppFeatureFetchThreshold} export default SequenceTrack diff --git a/js/trackViewport.js b/js/trackViewport.js index 3aa3879f5..cb0d0c563 100644 --- a/js/trackViewport.js +++ b/js/trackViewport.js @@ -8,6 +8,7 @@ import Viewport from "./viewport.js" import {DOMUtils, FileUtils} from "../node_modules/igv-utils/src/index.js" import C2S from "./canvas2svg.js" import GenomeUtils from "./genome/genome.js" +import {bppFeatureFetchThreshold} from "./sequenceTrack.js"; const NOT_LOADED_MESSAGE = 'Error loading track data' @@ -90,7 +91,7 @@ class TrackViewport extends Viewport { } } - if (this.trackView.track && "sequence" === this.trackView.track.type && this.referenceFrame.bpPerPixel > 1) { + if (this.trackView.track && "sequence" === this.trackView.track.type && this.referenceFrame.bpPerPixel > bppFeatureFetchThreshold) { $(this.canvas).remove() this.canvas = undefined //this.featureCache = undefined @@ -533,7 +534,6 @@ class TrackViewport extends Viewport { } async getFeatures(track, chr, start, end, bpPerPixel) { - if (this.featureCache && this.featureCache.containsRange(chr, start, end, bpPerPixel)) { return this.featureCache.features } else if (typeof track.getFeatures === "function") {