Skip to content

Commit 0c9fa3b

Browse files
committed
minor refactor
1 parent 22b5186 commit 0c9fa3b

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

js/feature/render/renderFeature.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,8 @@ function renderFeature(feature, bpStart, xScale, pixelHeight, ctx, options) {
8585
const xRight = Math.min(pixelWidth, coord.px1)
8686
const width = xRight - xLeft
8787

88-
// DUGLA HACK
89-
// ctx.fillStyle = '#cefa6e'
9088
ctx.fillRect(xLeft, py, width, h)
91-
// ctx.fillStyle = color
92-
// Arrows
93-
// Do not draw if strand is not +/-
89+
9490
if (direction !== 0) {
9591
ctx.fillStyle = "white"
9692
ctx.strokeStyle = "white"
@@ -114,9 +110,9 @@ function renderFeature(feature, bpStart, xScale, pixelHeight, ctx, options) {
114110
IGVGraphics.strokeLine(ctx, x - direction * 2, cy + 2, x, cy)
115111
}
116112

117-
// console.log(`${ feature.name } exons ${ feature.exons.length }`)
113+
for (let i = 0; i < feature.exons.length; i++) {
118114

119-
for (const exon of feature.exons) {
115+
const exon = feature.exons[ i ]
120116

121117
// draw the exons
122118
let ePx = Math.round((exon.start - bpStart) / xScale)
@@ -171,7 +167,10 @@ function renderFeature(feature, bpStart, xScale, pixelHeight, ctx, options) {
171167
if (exon.readingFrame !== undefined) {
172168
const width = Math.max(1, Math.ceil(1 / options.bpPerPixel))
173169
if (width >= aminoAcidSequenceRenderThreshold) {
174-
renderAminoAcidSequence(ctx, exon, bpStart, options.bpPerPixel, py, h, color, feature.strand)
170+
171+
const leftExon = 0 === i ? undefined : feature.exons[ i - 1]
172+
const riteExon = feature.exons.length - 1 === i ? undefined : feature.exons[ i + 1]
173+
renderAminoAcidSequence(ctx, feature.strand, leftExon, exon, riteExon, bpStart, options.bpPerPixel, py, h, color)
175174
}
176175
}
177176

@@ -200,8 +199,7 @@ function renderFeature(feature, bpStart, xScale, pixelHeight, ctx, options) {
200199
}
201200
}
202201

203-
function renderAminoAcidSequence(ctx, exon, bpStart, bpPerPixel, y, height, featureColor, strand) {
204-
202+
function renderAminoAcidSequence(ctx, strand, leftExon, exon, riteExon, bpStart, bpPerPixel, y, height, featureColor) {
205203

206204
const phase = (3 - exon.readingFrame) % 3
207205

0 commit comments

Comments
 (0)