Skip to content

Commit 9562de1

Browse files
committed
Bug fix: Save Image - GroupBy graphical elements now save properly
1 parent dd0345d commit 9562de1

File tree

3 files changed

+81
-7
lines changed

3 files changed

+81
-7
lines changed

dev/issues/git-1886.html

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Git Issue - 1886</title>
7+
</head>
8+
<body>
9+
10+
<header>
11+
<h1>Git Issue - 1886</h1>
12+
</header>
13+
14+
<main>
15+
<div id="igvDiv" style="padding-top: 50px;padding-bottom: 20px; height: auto"></div>
16+
</main>
17+
18+
<script type="module">
19+
20+
import igv from "../../js/index.js"
21+
22+
const config =
23+
{
24+
"version": "3.0.5",
25+
"showSampleNames": false,
26+
"reference": {
27+
"id": "hg19",
28+
"name": "Human (GRCh37/hg19)",
29+
"fastaURL": "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg19/hg19.fasta",
30+
"indexURL": "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg19/hg19.fasta.fai",
31+
"cytobandURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/database/cytoBand.txt.gz",
32+
"aliasURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/bigZips/hg19.chromAlias.txt",
33+
"twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/bigZips/hg19.2bit",
34+
"chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/bigZips/hg19.chrom.sizes",
35+
"chromosomeOrder": "chr1,chr2,chr3,chr4,chr5,chr6,chr7,chr8,chr9,chr10,chr11,chr12,chr13,chr14,chr15,chr16,chr17,chr18,chr19,chr20,chr21,chr22,chrX,chrY"
36+
},
37+
"locus": "chr3:86,924,605-86,924,924",
38+
"roi": [],
39+
"tracks": [
40+
{
41+
"type": "sequence",
42+
"order": -9007199254740991
43+
},
44+
{
45+
"sourceType": "gcs",
46+
"type": "alignment",
47+
"url": "gs://genomics-public-data/platinum-genomes/bam/NA12889_S1.bam",
48+
"indexURL": "gs://genomics-public-data/platinum-genomes/bam/NA12889_S1.bam.bai",
49+
"name": "NA12889",
50+
"order": 0,
51+
"colorBy": "unexpectedPair"
52+
},
53+
{
54+
"name": "Refseq Genes",
55+
"format": "refgene",
56+
"id": "hg19_genes",
57+
"url": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/database/ncbiRefSeq.txt.gz",
58+
"indexed": false,
59+
"order": 1000000,
60+
"infoURL": "https://www.ncbi.nlm.nih.gov/gene/?term=$$",
61+
"type": "annotation",
62+
"height": 70
63+
}
64+
]
65+
}
66+
67+
igv.createBrowser(document.getElementById('igvDiv'), config)
68+
.then(browser => {
69+
console.log(`browser ${ browser.guid } is good to go`)
70+
})
71+
72+
</script>
73+
</body>
74+
</html>

js/bam/alignmentTrack.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ class AlignmentTrack extends TrackBase {
304304
if (this.groupBy && groupName) {
305305

306306
ctx.save()
307+
307308
ctx.font = '400 12px sans-serif'
308309
const textMetrics = ctx.measureText(groupName)
309310
const w = textMetrics.width + 10
@@ -314,14 +315,10 @@ class AlignmentTrack extends TrackBase {
314315
ctx.textAlign = "center"
315316
ctx.fillStyle = 'white'
316317
ctx.strokeStyle = 'lightGray'
317-
ctx.beginPath()
318-
ctx.roundRect(x, baselineY - textMetrics.actualBoundingBoxAscent - 5, w, h, 2)
319-
ctx.fill()
320-
ctx.stroke()
318+
IGVGraphics.roundRect(ctx, x, baselineY - textMetrics.actualBoundingBoxAscent - 5, w, h, 2, 1, 1)
321319

322320
ctx.fillStyle = 'black'
323321
ctx.fillText(groupName, x + w / 2, baselineY)
324-
325322
IGVGraphics.dashedLine(ctx, 0, alignmentY, pixelWidth, alignmentY)
326323

327324
ctx.restore()
@@ -1229,7 +1226,7 @@ class AlignmentTrack extends TrackBase {
12291226
const y = clickState.y
12301227
const offsetY = y - this.top
12311228
const genomicLocation = clickState.genomicLocation
1232-
1229+
12331230
if(features.packedGroups) {
12341231
let minGroupY = Number.MAX_VALUE
12351232
for (let group of features.packedGroups.values()) {

js/trackViewport.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ class TrackViewport extends Viewport {
475475

476476
context.saveWithTranslationAndClipRect(id, x, y, width, height, yClipOffset)
477477

478-
let {start, bpPerPixel} = this.referenceFrame
478+
const {start, bpPerPixel} = this.referenceFrame
479+
const pixelXOffset = Math.round((start - this.referenceFrame.start) / bpPerPixel)
479480

480481
const config =
481482
{
@@ -486,6 +487,8 @@ class TrackViewport extends Viewport {
486487
pixelTop: yClipOffset,
487488
pixelWidth: width,
488489
pixelHeight: height,
490+
pixelXOffset,
491+
pixelShift: pixelXOffset,
489492
bpStart: start,
490493
bpEnd: start + (width * bpPerPixel),
491494
bpPerPixel,

0 commit comments

Comments
 (0)