Skip to content

Commit

Permalink
Add bpp threshold of 10 to sequence track rendering (#1560)
Browse files Browse the repository at this point in the history
* Add bpp threshold of 10 to sequence track rendering

* Update trackViewport.js

* update

Co-authored-by: Jim Robinson <[email protected]>
  • Loading branch information
turner and jrobinso authored Nov 3, 2022
1 parent 668c454 commit 03d9c41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions js/sequenceTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -163,7 +165,6 @@ class SequenceTrack {
]
}


contextMenuItemList(clickState) {
const viewport = clickState.viewport
if (viewport.referenceFrame.bpPerPixel <= 1) {
Expand Down Expand Up @@ -214,7 +215,6 @@ class SequenceTrack {
}
}


translateSequence(seq) {

const threeFrame = [[], [], []]
Expand All @@ -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)
Expand Down Expand Up @@ -381,7 +383,7 @@ class SequenceTrack {

}

export {defaultSequenceTrackOrder}
export {defaultSequenceTrackOrder, bppFeatureFetchThreshold}

export default SequenceTrack

Expand Down
4 changes: 2 additions & 2 deletions js/trackViewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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") {
Expand Down

0 comments on commit 03d9c41

Please sign in to comment.