Skip to content

Commit

Permalink
Temp commit - not working yet
Browse files Browse the repository at this point in the history
  • Loading branch information
dariober committed Oct 23, 2024
1 parent 89ccf49 commit a950b8b
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { stopwords } from './fulltext-stopwords'
import { OntologyDBNode } from './indexeddb-schema'
import { applyPrefixes } from './prefixes'
import OntologyStore, { Transaction } from '.'
import { TextIndexFieldDefinition } from '..'
import { TextIndexFieldDefinition } from '../../config'

/** special value of jsonPath that gets the IRI (that is, ID) of the node with the configured prefixes applied */
export const PREFIXED_ID_PATH = '$PREFIXED_ID'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from './indexeddb-schema'
import { GraphDocument } from './obo-graph-json-schema'
import OntologyStore from '.'
import { defaultTextIndexFields } from '..'
import { defaultTextIndexFields } from '../../config'

/** schema version we are currently on, used for the IndexedDB schema open call */
const schemaVersion = 2
Expand Down
64 changes: 18 additions & 46 deletions packages/jbrowse-plugin-apollo/src/OntologyManager/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ConfigurationSchema } from '@jbrowse/core/configuration'
import {
ConfigurationReference,
readConfObject,
} from '@jbrowse/core/configuration'
import {
BlobLocation,
LocalPathLocation,
Expand All @@ -11,6 +14,8 @@ import OntologyStore, { OntologyStoreOptions } from './OntologyStore'
import { OntologyDBNode } from './OntologyStore/indexeddb-schema'
import { applyPrefixes, expandPrefixes } from './OntologyStore/prefixes'

import ApolloPluginConfigurationSchema from '../config'

export { isDeprecated } from './OntologyStore/indexeddb-schema'

export const OntologyRecordType = types
Expand Down Expand Up @@ -54,16 +59,25 @@ export const OntologyManagerType = types
'GO:': 'http://purl.obolibrary.org/obo/GO_',
'SO:': 'http://purl.obolibrary.org/obo/SO_',
}),
pluginConfiguration: ConfigurationReference(
ApolloPluginConfigurationSchema,
),
})
.views((self) => ({
get featureTypeOntologyName(): string {
return readConfObject(
self.pluginConfiguration,
'featureTypeOntologyName',
) as string
},
}))
.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 Expand Up @@ -113,48 +127,6 @@ export const OntologyManagerType = types

export default OntologyManagerType

export interface TextIndexFieldDefinition {
/** name to display in the UI for text taken from this field or fields */
displayName: string
/** JSONPath of the field(s) */
jsonPath: string
}
export const defaultTextIndexFields: TextIndexFieldDefinition[] = [
{ displayName: 'Label', jsonPath: '$.lbl' },
{ displayName: 'Synonym', jsonPath: '$.meta.synonyms[*].val' },
{ displayName: 'Definition', jsonPath: '$.meta.definition.val' },
]

export const OntologyRecordConfiguration = ConfigurationSchema(
'OntologyRecord',
{
name: {
type: 'string',
description: 'the full name of the ontology, e.g. "Gene Ontology"',
defaultValue: 'My Ontology',
},
version: {
type: 'string',
description: "the ontology's version string",
defaultValue: 'unversioned',
},
source: {
type: 'fileLocation',
description: "the download location for the ontology's source file",
defaultValue: {
locationType: 'UriLocation',
uri: 'http://example.com/myontology.json',
},
},
textIndexFields: {
type: 'frozen',
description:
'JSON paths for text fields that will be indexed for text searching',
defaultValue: defaultTextIndexFields,
},
},
)

// eslint disables because of
// https://mobx-state-tree.js.org/tips/typescript#using-a-mst-type-at-design-time
// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand Down
58 changes: 54 additions & 4 deletions packages/jbrowse-plugin-apollo/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,60 @@
import { ConfigurationSchema } from '@jbrowse/core/configuration'
import { types } from 'mobx-state-tree'

import { OntologyRecordConfiguration } from './OntologyManager'
export interface TextIndexFieldDefinition {
/** name to display in the UI for text taken from this field or fields */
displayName: string
/** JSONPath of the field(s) */
jsonPath: string
}
export const defaultTextIndexFields: TextIndexFieldDefinition[] = [
{ displayName: 'Label', jsonPath: '$.lbl' },
{ displayName: 'Synonym', jsonPath: '$.meta.synonyms[*].val' },
{ displayName: 'Definition', jsonPath: '$.meta.definition.val' },
]

const ApolloPluginConfigurationSchema = ConfigurationSchema('ApolloPlugin', {
ontologies: types.array(OntologyRecordConfiguration),
})
export const OntologyRecordConfiguration = ConfigurationSchema(
'OntologyRecord',
{
name: {
type: 'string',
description: 'the full name of the ontology, e.g. "Gene Ontology"',
defaultValue: 'My Ontology',
},
version: {
type: 'string',
description: "the ontology's version string",
defaultValue: 'unversioned',
},
source: {
type: 'fileLocation',
description: "the download location for the ontology's source file",
defaultValue: {
locationType: 'UriLocation',
uri: 'http://example.com/myontology.json',
},
},
textIndexFields: {
type: 'frozen',
description:
'JSON paths for text fields that will be indexed for text searching',
defaultValue: defaultTextIndexFields,
},
},
{ explicitlyTyped: true },
)

const ApolloPluginConfigurationSchema = ConfigurationSchema(
'ApolloPlugin',
{
ontologies: types.array(OntologyRecordConfiguration),
featureTypeOntologyName: {
description: 'Name of the feature type ontology',
type: 'string',
defaultValue: 'Sequence Ontology',
},
},
{ explicitlyTyped: true },
)

export default ApolloPluginConfigurationSchema
11 changes: 6 additions & 5 deletions packages/jbrowse-plugin-apollo/src/session/ClientDataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ import {
InMemoryFileDriver,
} from '../BackendDrivers'
import { ChangeManager } from '../ChangeManager'
import ApolloPluginConfigurationSchema from '../config'
import {
OntologyManagerType,
import ApolloPluginConfigurationSchema, {
OntologyRecordConfiguration,
TextIndexFieldDefinition,
} from '../OntologyManager'
} from '../config'
import { OntologyManagerType } from '../OntologyManager'
import { ApolloRootModel } from '../types'
import { autorun } from 'mobx'

Expand Down Expand Up @@ -136,7 +135,9 @@ export function clientDataStoreFactory(
desktopFileDriver: isElectron
? new DesktopFileDriver(self as unknown as ClientDataStoreType)
: undefined,
ontologyManager: OntologyManagerType.create(),
ontologyManager: OntologyManagerType.create({
pluginConfiguration: self.pluginConfiguration,
}),
}))
.actions((self) => ({
afterCreate() {
Expand Down

0 comments on commit a950b8b

Please sign in to comment.