Skip to content

Commit

Permalink
added setReadsToHighlight() method to AlignmentTrack (#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonGen authored Aug 14, 2023
1 parent 2a12406 commit f7dcd97
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion js/bam/bamTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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.
*
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f7dcd97

Please sign in to comment.