Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make feature type ontology configurable #472

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
'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