Skip to content

Commit

Permalink
Make clicking on introns in gene glyph select the mRNA (#460)
Browse files Browse the repository at this point in the history
* Hightlight mRNA on intron hover and tooltip fix

* refactor

* Fix BoxGlyph drawTooltip to work with GeneGlyph

* Fix lint

---------

Co-authored-by: Garrett Stevens <[email protected]>
  • Loading branch information
shashankbrgowda and garrettjstevens authored Nov 4, 2024
1 parent fe0721f commit 37c5e03
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function drawTooltip(
if (!position) {
return
}
const { layoutIndex, layoutRow } = position
const { featureRow, layoutIndex, layoutRow } = position
const { bpPerPx, displayedRegions, offsetPx } = lgv
const displayedRegion = displayedRegions[layoutIndex]
const { refName, reversed } = displayedRegion
Expand All @@ -191,7 +191,7 @@ function drawTooltip(
coord: reversed ? max : min,
regionNumber: layoutIndex,
})?.offsetPx ?? 0) - offsetPx
const top = layoutRow * apolloRowHeight
const top = (layoutRow + featureRow) * apolloRowHeight
const widthPx = length / bpPerPx

const featureType = `Type: ${feature.type}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,32 @@ function getFeatureFromLayout(
): AnnotationFeature | undefined {
const featureInThisRow: AnnotationFeature[] = featuresForRow(feature)[row]
for (const f of featureInThisRow) {
let featureObj
if (bp >= f.min && bp <= f.max && f.parent) {
return f
featureObj = f
}
if (!featureObj) {
continue
}
if (
featureObj.type === 'CDS' &&
featureObj.parent &&
featureObj.parent.type === 'mRNA'
) {
const { cdsLocations } = featureObj.parent
for (const cdsLoc of cdsLocations) {
for (const loc of cdsLoc) {
if (bp >= loc.min && bp <= loc.max) {
return featureObj
}
}
}

// If mouse position is in the intron region, return the mRNA
return featureObj.parent
}
// If mouse position is in a feature that is not a CDS, return the feature
return featureObj
}
return feature
}
Expand Down

0 comments on commit 37c5e03

Please sign in to comment.