Skip to content

Commit

Permalink
Load ontology configuration
Browse files Browse the repository at this point in the history
Cypress tests updated so that they start with a configuration record
already in the database. This should resolve issue #421
  • Loading branch information
dariober committed Aug 14, 2024
1 parent 6fbe4ac commit 3a70b30
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 33 deletions.
7 changes: 4 additions & 3 deletions packages/jbrowse-plugin-apollo/cypress/e2e/editFeature.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
describe('Different ways of editing features', () => {
beforeEach(() => {
cy.addOntologies()
cy.deleteAssemblies()
cy.loginAsGuest()
})
Expand Down Expand Up @@ -61,7 +62,7 @@ describe('Different ways of editing features', () => {
})
})

it.skip('Can add gene ontology attribute', () => {
it('Can add gene ontology attribute', () => {
cy.addAssemblyFromGff('onegene.fasta.gff3', 'test_data/onegene.fasta.gff3')
cy.selectAssemblyToView('onegene.fasta.gff3')
cy.searchFeatures('gx1', 1)
Expand Down Expand Up @@ -142,7 +143,7 @@ describe('Different ways of editing features', () => {
cy.contains('td', '=CDS1').should('not.exist')
})

it.skip('Suggest only valid SO terms from dropdown', () => {
it('Suggest only valid SO terms from dropdown', () => {
cy.addAssemblyFromGff('onegene.fasta.gff3', 'test_data/onegene.fasta.gff3')
cy.selectAssemblyToView('onegene.fasta.gff3')
cy.searchFeatures('gx1', 1)
Expand All @@ -160,7 +161,7 @@ describe('Different ways of editing features', () => {
)
})

it.skip('Can add child feature via table editor', () => {
it('Can add child feature via table editor', () => {
cy.addAssemblyFromGff('onegene.fasta.gff3', 'test_data/onegene.fasta.gff3')
cy.selectAssemblyToView('onegene.fasta.gff3')
cy.searchFeatures('gx1', 1)
Expand Down
28 changes: 28 additions & 0 deletions packages/jbrowse-plugin-apollo/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,34 @@ Cypress.Commands.add('deleteAssemblies', () => {
}
})

Cypress.Commands.add('addOntologies', () => {
cy.deleteMany({}, {collection: 'jbrowseconfigs'})
cy.insertOne({
'configuration': {
'ApolloPlugin': {
'ontologies': [
{
'name': 'Gene Ontology',
'version': 'full',
'source': {
'uri': 'https://release.geneontology.org/2023-06-11/ontology/go.json',
'locationType': 'UriLocation'
}
},
{
'name': 'Sequence Ontology',
'version': '3.1',
'source': {
'uri': 'http://localhost:9000/test_data/so-v3.1.json',
'locationType': 'UriLocation'
}
}
]
}
}
}, {collection: 'jbrowseconfigs'})
})

Cypress.Commands.add('addAssemblyFromGff', (assemblyName, fin) => {
cy.get('button[data-testid="dropDownMenuButton"]', { timeout: 10_000 })
.contains('Apollo')
Expand Down
1 change: 1 addition & 0 deletions packages/jbrowse-plugin-apollo/cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare namespace Cypress {
interface Chainable {
addOntologies(): Chainable<void>
loginAsGuest(): Chainable<void>
deleteAssemblies(): Chainable<void>
addAssemblyFromGff(assemblyName: string, fin: string): Chainable<void>
Expand Down
66 changes: 36 additions & 30 deletions packages/jbrowse-plugin-apollo/src/session/ClientDataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Region, getSession, isElectron } from '@jbrowse/core/util'
import { LocalPathLocation, UriLocation } from '@jbrowse/core/util/types/mst'
import {
Instance,
addDisposer,
flow,
getParentOfType,
getRoot,
Expand All @@ -39,6 +40,7 @@ import {
TextIndexFieldDefinition,
} from '../OntologyManager'
import { ApolloRootModel } from '../types'
import { autorun } from 'mobx'

export function clientDataStoreFactory(
AnnotationFeatureExtended: typeof AnnotationFeature,
Expand Down Expand Up @@ -130,36 +132,40 @@ export function clientDataStoreFactory(
}))
.actions((self) => ({
afterCreate() {
// Merge in the ontologies from our plugin configuration.
// Ontologies of a given name that are already in the session
// take precedence over the ontologies in the configuration.
const { ontologyManager, pluginConfiguration } = self
const configuredOntologies =
pluginConfiguration.ontologies as ConfigurationModel<
typeof OntologyRecordConfiguration
>[]

for (const ont of configuredOntologies || []) {
const [name, version, source, indexFields] = [
readConfObject(ont, 'name') as string,
readConfObject(ont, 'version') as string,
readConfObject(ont, 'source') as
| Instance<typeof LocalPathLocation>
| Instance<typeof UriLocation>,
readConfObject(
ont,
'textIndexFields',
) as TextIndexFieldDefinition[],
]
if (!ontologyManager.findOntology(name)) {
ontologyManager.addOntology(name, version, source, {
textIndexing: { indexFields },
})
}
}

// TODO: add in any configured ontology prefixes that we don't already
// have in the session (or hardcoded in the model)
addDisposer(
self,
autorun((reaction) => {
// Merge in the ontologies from our plugin configuration.
// Ontologies of a given name that are already in the session
// take precedence over the ontologies in the configuration.
const { ontologyManager, pluginConfiguration } = self
const configuredOntologies =
pluginConfiguration.ontologies as ConfigurationModel<
typeof OntologyRecordConfiguration
>[]
for (const ont of configuredOntologies || []) {
const [name, version, source, indexFields] = [
readConfObject(ont, 'name') as string,
readConfObject(ont, 'version') as string,
readConfObject(ont, 'source') as
| Instance<typeof LocalPathLocation>
| Instance<typeof UriLocation>,
readConfObject(
ont,
'textIndexFields',
) as TextIndexFieldDefinition[],
]
if (!ontologyManager.findOntology(name)) {
ontologyManager.addOntology(name, version, source, {
textIndexing: { indexFields },
})
}
}
// TODO: add in any configured ontology prefixes that we don't already
// have in the session (or hardcoded in the model)
reaction.dispose()
}),
)
},
}))
.views((self) => ({
Expand Down

0 comments on commit 3a70b30

Please sign in to comment.