diff --git a/packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts b/packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts index 3225c522..d10f0edf 100644 --- a/packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts +++ b/packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts @@ -1,15 +1,26 @@ -import { ConfigurationSchema } from '@jbrowse/core/configuration' +import { + AnyConfigurationModel, + ConfigurationSchema, + readConfObject, +} from '@jbrowse/core/configuration' import { BlobLocation, LocalPathLocation, UriLocation, } from '@jbrowse/core/util/types/mst' import { autorun } from 'mobx' -import { Instance, addDisposer, getSnapshot, types } from 'mobx-state-tree' - +import { + Instance, + addDisposer, + getRoot, + getSnapshot, + types, +} from 'mobx-state-tree' import OntologyStore, { OntologyStoreOptions } from './OntologyStore' import { OntologyDBNode } from './OntologyStore/indexeddb-schema' import { applyPrefixes, expandPrefixes } from './OntologyStore/prefixes' +import ApolloPluginConfigurationSchema from '../config' +import { ApolloRootModel } from '../types' export { isDeprecated } from './OntologyStore/indexeddb-schema' @@ -55,15 +66,27 @@ export const OntologyManagerType = types 'SO:': 'http://purl.obolibrary.org/obo/SO_', }), }) + .views((self) => ({ + get featureTypeOntologyName(): string { + const jbConfig = getRoot(self).jbrowse + .configuration as AnyConfigurationModel + const pluginConfiguration = jbConfig.ApolloPlugin as Instance< + typeof ApolloPluginConfigurationSchema + > + const featureTypeOntologyName = readConfObject( + pluginConfiguration, + 'featureTypeOntologyName', + ) as string + return featureTypeOntologyName + }, + })) .views((self) => ({ /** * gets the OntologyRecord for the ontology we should be * using for feature types (e.g. SO or maybe biotypes) **/ get featureTypeOntology() { - // TODO: change this to read some configuration for which feature type ontology - // we should be using. currently hardcoded to use SO. - return this.findOntology('Sequence Ontology') + return this.findOntology(self.featureTypeOntologyName) }, findOntology(name: string, version?: string) { diff --git a/packages/jbrowse-plugin-apollo/src/config.ts b/packages/jbrowse-plugin-apollo/src/config.ts index de8fae01..66f92669 100644 --- a/packages/jbrowse-plugin-apollo/src/config.ts +++ b/packages/jbrowse-plugin-apollo/src/config.ts @@ -5,6 +5,11 @@ import { OntologyRecordConfiguration } from './OntologyManager' const ApolloPluginConfigurationSchema = ConfigurationSchema('ApolloPlugin', { ontologies: types.array(OntologyRecordConfiguration), + featureTypeOntologyName: { + description: 'Name of the feature type ontology', + type: 'string', + defaultValue: 'Sequence Ontology', + }, }) export default ApolloPluginConfigurationSchema diff --git a/packages/jbrowse-plugin-apollo/src/session/ClientDataStore.ts b/packages/jbrowse-plugin-apollo/src/session/ClientDataStore.ts index a6a91faa..20cea3a5 100644 --- a/packages/jbrowse-plugin-apollo/src/session/ClientDataStore.ts +++ b/packages/jbrowse-plugin-apollo/src/session/ClientDataStore.ts @@ -51,6 +51,7 @@ export function clientDataStoreFactory( typeName: types.optional(types.literal('Client'), 'Client'), assemblies: types.map(ApolloAssembly), checkResults: types.map(CheckResult), + ontologyManager: types.optional(OntologyManagerType, {}), }) .views((self) => ({ get internetAccounts() { @@ -136,7 +137,6 @@ export function clientDataStoreFactory( desktopFileDriver: isElectron ? new DesktopFileDriver(self as unknown as ClientDataStoreType) : undefined, - ontologyManager: OntologyManagerType.create(), })) .actions((self) => ({ afterCreate() { diff --git a/packages/jbrowse-plugin-apollo/src/session/session.ts b/packages/jbrowse-plugin-apollo/src/session/session.ts index 4e56759a..615ff0e4 100644 --- a/packages/jbrowse-plugin-apollo/src/session/session.ts +++ b/packages/jbrowse-plugin-apollo/src/session/session.ts @@ -419,6 +419,7 @@ export function extendSession( ([, assembly]) => assembly.backendDriverType === 'InMemoryFileDriver', ), ) + // @ts-expect-error ontologyManager isn't actually required snap.apolloDataStore = { typeName: 'Client', assemblies,