Skip to content

Commit

Permalink
Make feature type ontology configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjstevens committed Nov 13, 2024
1 parent 73593c4 commit d20075a
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

Check warning on line 71 in packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts#L69-L71

Added lines #L69 - L71 were not covered by tests
.configuration as AnyConfigurationModel
const pluginConfiguration = jbConfig.ApolloPlugin as Instance<

Check warning on line 73 in packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts#L73

Added line #L73 was not covered by tests
typeof ApolloPluginConfigurationSchema
>
const featureTypeOntologyName = readConfObject(

Check warning on line 76 in packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts#L76

Added line #L76 was not covered by tests
pluginConfiguration,
'featureTypeOntologyName',
) as string
return featureTypeOntologyName

Check warning on line 80 in packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts#L80

Added line #L80 was not covered by tests
},
}))
.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)

Check warning on line 89 in packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts#L89

Added line #L89 was not covered by tests
},

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 d20075a

Please sign in to comment.