Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 1-based coords in GeneTrack #394

Merged
merged 2 commits into from
Nov 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified screenshots/pileup_blocks-mismatch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/pileup_deletions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/pileup_gene-utf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/pileup_inserts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/pileup_loose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/pileup_small-letters-mismatch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/pileup_wide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/structuralvariants_base.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 7 additions & 8 deletions src/main/GeneTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ var bedtools = require('./bedtools'),


// Draw an arrow in the middle of the visible portion of range.
// TODO: right-facing arrows!
function drawArrow(ctx: CanvasRenderingContext2D,
clampedScale: (x: number)=>number,
range: Interval,
tipY: number,
strand: Strand) {
var x1 = clampedScale(range.start),
x2 = clampedScale(range.stop);
var x1 = clampedScale(1 + range.start),
x2 = clampedScale(1 + range.stop);

// it's off-screen or there's not enough room to draw it legibly.
if (x2 - x1 <= 2 * style.GENE_ARROW_SIZE) return;
Expand All @@ -56,7 +55,7 @@ function drawGeneName(ctx: CanvasRenderingContext2D,
gene: Gene,
textIntervals: Interval[]) {
var p = gene.position,
centerX = 0.5 * (clampedScale(p.start()) + clampedScale(p.stop()));
centerX = 0.5 * (clampedScale(1 + p.start()) + clampedScale(1 + p.stop()));
var name = gene.name || gene.id;
var textWidth = ctx.measureText(name).width;
var textInterval = new Interval(centerX - 0.5 * textWidth,
Expand Down Expand Up @@ -142,15 +141,15 @@ class GeneTrack extends React.Component {
ctx.strokeStyle = style.GENE_COLOR;
ctx.fillStyle = style.GENE_COLOR;

canvasUtils.drawLine(ctx, clampedScale(gene.position.start()), geneLineY + 0.5,
clampedScale(gene.position.stop()), geneLineY + 0.5);
canvasUtils.drawLine(ctx, clampedScale(1 + gene.position.start()), geneLineY + 0.5,
clampedScale(1 + gene.position.stop()), geneLineY + 0.5);

// TODO: only compute all these intervals when data becomes available.
var exons = bedtools.splitCodingExons(gene.exons, gene.codingRegion);
exons.forEach(exon => {
ctx.fillRect(sc(exon.start),
ctx.fillRect(sc(1 + exon.start),
geneLineY - 3 * (exon.isCoding ? 2 : 1),
sc(exon.stop + 1) - sc(exon.start),
sc(exon.stop + 2) - sc(1 + exon.start),
6 * (exon.isCoding ? 2 : 1));
});

Expand Down