Skip to content

Commit

Permalink
Make feature type ontology configurable (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjstevens authored Nov 13, 2024
1 parent 73593c4 commit 1433542
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
35 changes: 29 additions & 6 deletions packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -55,15 +66,27 @@ export const OntologyManagerType = types
'SO:': 'http://purl.obolibrary.org/obo/SO_',
}),
})
.views((self) => ({
get featureTypeOntologyName(): string {
const jbConfig = getRoot<ApolloRootModel>(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) {
Expand Down
5 changes: 5 additions & 0 deletions packages/jbrowse-plugin-apollo/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -136,7 +137,6 @@ export function clientDataStoreFactory(
desktopFileDriver: isElectron
? new DesktopFileDriver(self as unknown as ClientDataStoreType)
: undefined,
ontologyManager: OntologyManagerType.create(),
}))
.actions((self) => ({
afterCreate() {
Expand Down
1 change: 1 addition & 0 deletions packages/jbrowse-plugin-apollo/src/session/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ export function extendSession(
([, assembly]) => assembly.backendDriverType === 'InMemoryFileDriver',
),
)
// @ts-expect-error ontologyManager isn't actually required
snap.apolloDataStore = {
typeName: 'Client',
assemblies,
Expand Down

0 comments on commit 1433542

Please sign in to comment.