Skip to content

Commit

Permalink
Changelog and reformat additions
Browse files Browse the repository at this point in the history
  • Loading branch information
dnil committed Oct 25, 2024
1 parent dcac8f7 commit 49c49f5
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 81 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ About changelog [here](https://keepachangelog.com/en/1.0.0/)
- `--force` flag prints a warning to stderr when overwriting an existing sample.
- `gens delete sample` command
- Height ordering for variants track.
### Changed
- Prettier for code formatting
### Fixed
- Pan able to exit chrosome when using genome build 17
- Pan able to exit chromosome when using genome build 37
- `--force` flag `update_one` call not being called properly
- Incorrect total sample count on home page.
- Some typos and documentation.
- Labels often not being visible on larger variants.


## [2.3]
### Added
- Link out to Scout: introduce config variable for base URL
Expand Down Expand Up @@ -104,7 +107,6 @@ About changelog [here](https://keepachangelog.com/en/1.0.0/)
- Reinstated tooltips to display additional information on genetic elements
### Changed
- Use popper for positioning tooltips
- Prettier for code formatting
### Fixed

## [1.2.0]
Expand Down
2 changes: 1 addition & 1 deletion assets/js/gens.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export function initCanvases({
}

// Make hard link and copy link to clipboard
export function copyPermalink (genomeBuild, region) {
export function copyPermalink(genomeBuild, region) {
// create element and add url to it
const tempElement = document.createElement("input");
const loc = window.location;
Expand Down
122 changes: 71 additions & 51 deletions assets/js/interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class InteractiveCanvas extends BaseScatterTrack {
yStart: 2.0, // Start value for y axis
yEnd: -2.0, // End value for y axis
step: 0.5, // Step value for drawing ticks along y-axis
color: "#000000" // Viz color
color: "#000000", // Viz color
};

// Setup draw canvas
Expand Down Expand Up @@ -229,41 +229,51 @@ export class InteractiveCanvas extends BaseScatterTrack {
});
}
// reset dragging behaviour
this.markingRegion = false
this.drag = false
})
this.markingRegion = false;
this.drag = false;
});
// when user asks for Y zoom
this.staticCanvas.addEventListener('zoomY', event => {
this.staticCanvas.addEventListener("zoomY", (event) => {
// clear with old coord context
this.clearStaticContent()
this.clearStaticContent();
// also needs to clear for track draw
if (event.detail.direction === 'out') {
this.log2.yStart += 1
this.log2.yEnd -= 1
if (event.detail.direction === "out") {
this.log2.yStart += 1;
this.log2.yEnd -= 1;
if (this.log2.yStart > 2) {
this.log2.step = 1
this.log2.step = 1;
}
}
if (event.detail.direction === 'in' && this.log2.yStart > 1) {
this.log2.yStart -= 1
this.log2.yEnd += 1
if (event.detail.direction === "in" && this.log2.yStart > 1) {
this.log2.yStart -= 1;
this.log2.yEnd += 1;
if (this.log2.yStart <= 2) {
this.log2.step = 0.5
this.log2.step = 0.5;
}
}
// then draw new with new coords
this.drawStaticContent()
drawTrack({ ...readInputField(), force: true, displayLoading: false, drawTitle: false })
})
this.drawStaticContent();
drawTrack({
...readInputField(),
force: true,
displayLoading: false,
drawTitle: false,
});
});
}

// clear static content
async clearStaticContent () {
const linePadding = 2
const staticContext = this.staticCanvas.getContext('2d')
async clearStaticContent() {
const linePadding = 2;
const staticContext = this.staticCanvas.getContext("2d");
// Fill background colour
staticContext.fillStyle = '#F7F9F9'
staticContext.fillRect(0, 0, this.staticCanvas.width, this.staticCanvas.height)
staticContext.fillStyle = "#F7F9F9";
staticContext.fillRect(
0,
0,
this.staticCanvas.width,
this.staticCanvas.height,
);
// Make content area visible
// content window
staticContext.clearRect(
Expand All @@ -273,14 +283,19 @@ export class InteractiveCanvas extends BaseScatterTrack {
this.staticCanvas.height,
);
// area for ticks above content area
staticContext.clearRect(0, 0, this.staticCanvas.width, this.y + linePadding)
staticContext.clearRect(
0,
0,
this.staticCanvas.width,
this.y + linePadding,
);
// Transfer image to visible canvas
staticContext.drawImage(this.drawCanvas, 0, 0)
staticContext.drawImage(this.drawCanvas, 0, 0);
}

// Draw static content for interactive canvas
async drawStaticContent () {
const staticContext = this.staticCanvas.getContext('2d')
async drawStaticContent() {
const staticContext = this.staticCanvas.getContext("2d");
// Draw rotated y-axis legends
drawRotatedText(
staticContext,
Expand Down Expand Up @@ -464,33 +479,38 @@ export class InteractiveCanvas extends BaseScatterTrack {
.catch((error) => {
this.allowDraw = true;

// Transfer image to visible canvas
this.blitInteractiveCanvas({ start, end })
// Draw chromosome title on the content canvas as a blitting
// work around
this.titleYPos = result.y_pos - this.titleMargin
if (drawTitle) {
this.titleBbox !== null && this.blitChromName(
{ textPosition: this.titleBbox, clearOnly: true })
this.titleBbox = this.drawTitle(`Chromosome ${result.chrom}`)
this.blitChromName({ textPosition: this.titleBbox })
}
// Transfer image to visible canvas
this.blitInteractiveCanvas({ start, end });
// Draw chromosome title on the content canvas as a blitting
// work around
this.titleYPos = result.y_pos - this.titleMargin;
if (drawTitle) {
this.titleBbox !== null &&
this.blitChromName({
textPosition: this.titleBbox,
clearOnly: true,
});
this.titleBbox = this.drawTitle(`Chromosome ${result.chrom}`);
this.blitChromName({ textPosition: this.titleBbox });
}

return result
}).then((result) => {
if (displayLoading) {
this.loadingDiv.style.display = 'none'
} else {
document.getElementsByTagName('body')[0].style.cursor = 'auto'
}
this.allowDraw = true
}).catch(error => {
this.allowDraw = true
return result;
})
.then((result) => {
if (displayLoading) {
this.loadingDiv.style.display = "none";
} else {
document.getElementsByTagName("body")[0].style.cursor = "auto";
}
this.allowDraw = true;
})
.catch((error) => {
this.allowDraw = true;

this.inputField.dispatchEvent(
new CustomEvent('error', { detail: { error: error } })
)
})
this.inputField.dispatchEvent(
new CustomEvent("error", { detail: { error: error } }),
);
});
}

drawTitle(title) {
Expand Down
50 changes: 23 additions & 27 deletions assets/js/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { get } from "./fetch.js";
import { CHROMOSOMES } from "./track.js";
import { chromSizes } from "./helper.js";

function redrawEvent ({ region, exclude = [], ...kwargs }) {
return new CustomEvent(
'draw', { detail: { region: region, exclude: exclude, ...kwargs } }
)
function redrawEvent({ region, exclude = [], ...kwargs }) {
return new CustomEvent("draw", {
detail: { region: region, exclude: exclude, ...kwargs },
});
}

function drawEventManager ({ target, throttleTime }) {
function drawEventManager({ target, throttleTime }) {
const tracks = [
...target.querySelectorAll(".track-container"),
target.querySelector("#cytogenetic-ideogram"),
Expand Down Expand Up @@ -221,28 +221,24 @@ export function zoomOut() {
}

// Handle zoom in Y button click
export function zoomInY () {
console.log('dispatching zoom in Y')
const zoomYEvent = new CustomEvent(
'zoomY', { detail: { direction: 'in' } }
)
document.getElementById('interactive-static').dispatchEvent(zoomYEvent)
export function zoomInY() {
console.log("dispatching zoom in Y");
const zoomYEvent = new CustomEvent("zoomY", { detail: { direction: "in" } });
document.getElementById("interactive-static").dispatchEvent(zoomYEvent);
}

// Handle zoom out Y button click
export function zoomOutY () {
console.log('dispatching zoom out Y')
const zoomYEvent = new CustomEvent(
'zoomY', { detail: { direction: 'out' } }
)
document.getElementById('interactive-static').dispatchEvent(zoomYEvent)
export function zoomOutY() {
console.log("dispatching zoom out Y");
const zoomYEvent = new CustomEvent("zoomY", { detail: { direction: "out" } });
document.getElementById("interactive-static").dispatchEvent(zoomYEvent);
}

// Dispatch dispatch an event to draw a given region
// Redraw events can be limited to certain tracks or include all tracks
class KeyLogger {
// Records keypress combinations
constructor (bufferSize = 10) {
constructor(bufferSize = 10) {
// Setup variables
this.bufferSize = bufferSize;
this.lastKeyTime = Date.now();
Expand Down Expand Up @@ -270,7 +266,7 @@ class KeyLogger {
});
}

recentKeys (timeWindow) {
recentKeys(timeWindow) {
// get keys pressed within a window of time.
const currentTime = Date.now();
return this.keyBuffer.filter(
Expand Down Expand Up @@ -327,14 +323,14 @@ document.addEventListener("keyevent", (event) => {
case "d":
panTracks("right", 0.7);
break;
case '?':
case 'W':
zoomInY()
break
case 'S':
case '_':
zoomOutY()
break
case "?":
case "W":
zoomInY();
break;
case "S":
case "_":
zoomOutY();
break;
case "ArrowUp":
case "w":
case "+":
Expand Down

0 comments on commit 49c49f5

Please sign in to comment.