diff --git a/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/GeneGlyph.ts b/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/GeneGlyph.ts index 394b34220..7fd12a4fd 100644 --- a/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/GeneGlyph.ts +++ b/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/GeneGlyph.ts @@ -24,6 +24,7 @@ import { getStreamIcon, isCDSFeature, isExonFeature, + isGeneFeature, isMousePositionWithFeature, isTranscriptFeature, navToFeatureCenter, @@ -949,6 +950,28 @@ function getContextMenuItems( }, ) } + + if ( + isGeneFeature(feature, session) && + isSessionModelWithWidgets(session) + ) { + contextMenuItemsForFeature.push({ + label: 'Open gene details', + onClick: () => { + const apolloGeneWidget = session.addWidget( + 'ApolloFeatureDetailsWidget', + 'apolloFeatureDetailsWidget', + { + feature, + assembly: currentAssemblyId, + refName: region.refName, + }, + ) + session.showWidget(apolloGeneWidget) + }, + }) + } + if (isTranscriptFeature(feature, session)) { contextMenuItemsForFeature.push({ label: 'Merge transcript', diff --git a/packages/jbrowse-plugin-apollo/src/util/glyphUtils.ts b/packages/jbrowse-plugin-apollo/src/util/glyphUtils.ts index f7d8b4052..c8b585646 100644 --- a/packages/jbrowse-plugin-apollo/src/util/glyphUtils.ts +++ b/packages/jbrowse-plugin-apollo/src/util/glyphUtils.ts @@ -62,6 +62,20 @@ export function selectFeatureAndOpenWidget( } } +export function isGeneFeature( + feature: AnnotationFeature, + session: ApolloSessionModel, +): boolean { + const { featureTypeOntology } = session.apolloDataStore.ontologyManager + if (!featureTypeOntology) { + throw new Error('featureTypeOntology is undefined') + } + return ( + featureTypeOntology.isTypeOf(feature.type, 'gene') || + featureTypeOntology.isTypeOf(feature.type, 'pseudogene') + ) +} + export function isTranscriptFeature( feature: AnnotationFeature, session: ApolloSessionModel,