From 320532abb92928432bd2cd7e1b534f3a480cedb6 Mon Sep 17 00:00:00 2001 From: wilsonGen <103169735+wilsonGen@users.noreply.github.com> Date: Mon, 14 Aug 2023 13:56:51 +0800 Subject: [PATCH] added setReadsToHighlight() method to AlignmentTrack (#1660) --- js/bam/bamTrack.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/js/bam/bamTrack.js b/js/bam/bamTrack.js index a5397bab0..76d950a8d 100644 --- a/js/bam/bamTrack.js +++ b/js/bam/bamTrack.js @@ -795,6 +795,9 @@ class AlignmentTrack { this.hideSmallIndels = config.hideSmallIndels this.indelSizeThreshold = config.indelSizeThreshold || 1 + this.readsToHighlight = config.readsToHighlight || [] + this.highlightedReadsOutlineColor = config.highlightedReadsOutlineColor || "#00ff00" + this.hasPairs = false // Until proven otherwise this.hasSupplemental = false } @@ -803,6 +806,13 @@ class AlignmentTrack { this.top = (0 === coverageTrack.height || false === showCoverage) ? 0 : (5 + coverageTrack.height) } + setReadsToHighlight(readsToHighlight) { + if (!Array.isArray(readsToHighlight) ||!readsToHighlight.every(i => typeof i === "string")) { + throw new Error("AlignmentTrack.setReadsToHighlight() only accept array of strings") + } + this.readsToHighlight = readsToHighlight || [] + } + /** * Compute the pixel height required to display all content. * @@ -1079,11 +1089,13 @@ class AlignmentTrack { const strokeOutline = alignment.mq <= 0 || this.highlightedAlignmentReadNamed === alignment.readName || - isSoftClip + isSoftClip || + this.readsToHighlight.includes(alignment.readName) let blockOutlineColor = outlineColor if (this.highlightedAlignmentReadNamed === alignment.readName) blockOutlineColor = 'red' else if (isSoftClip) blockOutlineColor = 'rgb(50,50,50)' + else if (this.readsToHighlight.includes(alignment.readName)) blockOutlineColor = this.highlightedReadsOutlineColor const lastBlockPositiveStrand = (true === alignment.strand && b === blocks.length - 1) const lastBlockReverseStrand = (false === alignment.strand && b === 0)