diff --git a/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/BoxGlyph.ts b/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/BoxGlyph.ts index 5ddd8baf..df190ad8 100644 --- a/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/BoxGlyph.ts +++ b/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/BoxGlyph.ts @@ -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 @@ -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}` diff --git a/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/GeneGlyph.ts b/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/GeneGlyph.ts index 32ed3777..25b34b32 100644 --- a/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/GeneGlyph.ts +++ b/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/GeneGlyph.ts @@ -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 }