From 1c22b346eabec2f422086f52e35e8d3bb8259f15 Mon Sep 17 00:00:00 2001 From: Adam Novak Date: Thu, 14 Aug 2025 15:20:46 -0400 Subject: [PATCH 1/4] Add nicer selected region markings --- src/util/tubemap.js | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/util/tubemap.js b/src/util/tubemap.js index 5a1b5671..34ca52f8 100644 --- a/src/util/tubemap.js +++ b/src/util/tubemap.js @@ -3716,7 +3716,7 @@ function drawRuler() { ticks = separatedTicks; // plot ticks highlighting the region - ticks_region.forEach((tick) => drawRulerMarkingRegion(tick[0], tick[1])); + drawRulerMarkingRegion(ticks_region); // draw horizontal line for each interval @@ -3797,14 +3797,38 @@ function drawRulerMarking(sequencePosition, xCoordinate, align) { .attr("stroke", "black") } -function drawRulerMarkingRegion(sequencePosition, xCoordinate) { +function drawRulerMarkingRegion(ticks_region) { + // Each tick is a base coordinate and an image coordinate + ticks_region.forEach((tick) => drawRulerMarkingEndpoint(tick[0], tick[1])); + + let lineY = minYCoordinate - NODE_MARGIN - 6; + svg - .append("circle") - .attr("cx", xCoordinate + 3) - .attr("cy", minYCoordinate - 13) - .attr("r", 10) - .attr("opacity", 0.5) - .attr("fill", "yellow") + .append("line") + .attr("x1", ticks_region[0][1]) + .attr("y1", lineY) + .attr("x2", ticks_region[1][1]) + .attr("y2", lineY) + .attr("stroke-width", 4) + .attr("stroke", "#FFFE3A"); +} + +function drawRulerMarkingEndpoint(sequencePosition, xCoordinate) { + + let pointX = xCoordinate; + let pointY = minYCoordinate - NODE_MARGIN - 1; + let arrowWidth = 8; + let arrowHeight = 10; + + svg + .append("path") + .attr("d", `M${pointX - arrowWidth} ${pointY - arrowHeight}` + + ` L${pointX} ${pointY}` + + ` L${pointX + arrowWidth} ${pointY - arrowHeight}` + ) + .attr("stroke-width", 0) + .attr("fill", "#FFFE3A") + .attr("stroke", "none") .style("pointer-events", "none"); } From 5efbd4ef20c259eb25e2b3b7f822aff785c3eeb9 Mon Sep 17 00:00:00 2001 From: Adam Novak Date: Thu, 14 Aug 2025 15:40:53 -0400 Subject: [PATCH 2/4] Go back to being able to pull start positions needed for rulers for Lancet examples --- src/server.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/server.mjs b/src/server.mjs index 3b6feaf2..2385eb60 100644 --- a/src/server.mjs +++ b/src/server.mjs @@ -1424,6 +1424,11 @@ function processRegionFile(req, res, next) { console.log("Rename " + subpathName + " to " + arr[0] + " and mark start as " + arr[1]); p.name = arr[0]; p.indexOfFirstBase = arr[1]; + } else if (p.name === arr[0]) { + // We might be looking at a pre-extracted region that predates real + // subpath support (like the Lancet paper data), in which case we + // need to grab the real start point from the regions file. + p.indexOfFirstBase = arr[1]; } }); }); From 3157ee8ee79093bc8c2c55c22f22b25ae80244db Mon Sep 17 00:00:00 2001 From: Adam Novak Date: Wed, 20 Aug 2025 18:14:13 -0400 Subject: [PATCH 3/4] Support not actually having ticks to connect --- src/util/tubemap.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/util/tubemap.js b/src/util/tubemap.js index 34ca52f8..822d8a08 100644 --- a/src/util/tubemap.js +++ b/src/util/tubemap.js @@ -3715,7 +3715,7 @@ function drawRuler() { }); ticks = separatedTicks; - // plot ticks highlighting the region + // plot ticks highlighting the region (if it is filled in) drawRulerMarkingRegion(ticks_region); // draw horizontal line for each interval @@ -3797,20 +3797,27 @@ function drawRulerMarking(sequencePosition, xCoordinate, align) { .attr("stroke", "black") } +/// Draw ruler markings for the given requested region. +/// +/// The requested region should be an array of 2 items, each of which is an +/// array of a sequence position and an image X coordinate. If the array is not +/// 2 items, no connecting line is drawn. function drawRulerMarkingRegion(ticks_region) { // Each tick is a base coordinate and an image coordinate ticks_region.forEach((tick) => drawRulerMarkingEndpoint(tick[0], tick[1])); let lineY = minYCoordinate - NODE_MARGIN - 6; - svg - .append("line") - .attr("x1", ticks_region[0][1]) - .attr("y1", lineY) - .attr("x2", ticks_region[1][1]) - .attr("y2", lineY) - .attr("stroke-width", 4) - .attr("stroke", "#FFFE3A"); + if (ticks_region && ticks_region.length == 2) { + svg + .append("line") + .attr("x1", ticks_region[0][1]) + .attr("y1", lineY) + .attr("x2", ticks_region[1][1]) + .attr("y2", lineY) + .attr("stroke-width", 4) + .attr("stroke", "#FFFE3A"); + } } function drawRulerMarkingEndpoint(sequencePosition, xCoordinate) { From 2330b7185ffbff19df7780dac5de185ffe3508e2 Mon Sep 17 00:00:00 2001 From: Adam Novak Date: Wed, 20 Aug 2025 18:28:33 -0400 Subject: [PATCH 4/4] Make equaler --- src/util/tubemap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/tubemap.js b/src/util/tubemap.js index 822d8a08..da8aab03 100644 --- a/src/util/tubemap.js +++ b/src/util/tubemap.js @@ -3808,7 +3808,7 @@ function drawRulerMarkingRegion(ticks_region) { let lineY = minYCoordinate - NODE_MARGIN - 6; - if (ticks_region && ticks_region.length == 2) { + if (ticks_region && ticks_region.length === 2) { svg .append("line") .attr("x1", ticks_region[0][1])