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

Display message if sequence ontology is unavailable (#453) #459

Merged
merged 3 commits into from
Nov 6, 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
UriLocation,
isUriLocation,
} from '@jbrowse/core/util'
import { IDBPTransaction, IndexNames, StoreNames } from 'idb/with-async-ittr'
import {
deleteDB,
IDBPTransaction,
IndexNames,
StoreNames,
} from 'idb/with-async-ittr'

import { textSearch } from './fulltext'
import { OntologyDB, OntologyDBEdge, isDeprecated } from './indexeddb-schema'
Expand Down Expand Up @@ -176,18 +181,24 @@
return db
}

const { sourceLocation, sourceType } = this
if (sourceType === 'obo-graph-json') {
await this.loadOboGraphJson(db)
} else {
throw new Error(
`ontology source file ${JSON.stringify(
sourceLocation,
)} has type ${sourceType}, which is not yet supported`,
)
}
try {
const { sourceLocation, sourceType } = this
if (sourceType === 'obo-graph-json') {
await this.loadOboGraphJson(db)
} else {
throw new Error(

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

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/OntologyManager/OntologyStore/index.ts#L188-L189

Added lines #L188 - L189 were not covered by tests
`ontology source file ${JSON.stringify(
sourceLocation,
)} has type ${sourceType}, which is not yet supported`,
)
}

return db
return db
} catch (error) {
db.close()
await deleteDB(this.dbName)
throw error

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

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/OntologyManager/OntologyStore/index.ts#L198-L200

Added lines #L198 - L200 were not covered by tests
}
}

async termCount(tx?: Transaction<['nodes']>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,14 @@
// TODO: using file streaming along with an event-based json parser
// instead of JSON.parse and .readFile could probably make this faster
// and less memory intensive
const oboGraph = JSON.parse(
await openLocation(this.sourceLocation).readFile('utf8'),
) as GraphDocument
let oboGraph: GraphDocument
try {
oboGraph = JSON.parse(
await openLocation(this.sourceLocation).readFile('utf8'),
) as GraphDocument
} catch {
throw new Error('Error in loading ontology')

Check warning on line 93 in packages/jbrowse-plugin-apollo/src/OntologyManager/OntologyStore/indexeddb-storage.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/OntologyManager/OntologyStore/indexeddb-storage.ts#L93

Added line #L93 was not covered by tests
}

const parseTime = Date.now()

Expand Down
23 changes: 22 additions & 1 deletion packages/jbrowse-plugin-apollo/src/makeDisplayComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type LinearGenomeViewPlugin from '@jbrowse/plugin-linear-genome-view'
import ExpandLessIcon from '@mui/icons-material/ExpandLess'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import { Typography, alpha } from '@mui/material'
import { Alert, Typography, alpha } from '@mui/material'

Check warning on line 6 in packages/jbrowse-plugin-apollo/src/makeDisplayComponent.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/makeDisplayComponent.tsx#L6

Added line #L6 was not covered by tests
import { observer } from 'mobx-react'
import React, { useCallback, useEffect, useRef } from 'react'
import { makeStyles } from 'tss-react/mui'
Expand All @@ -14,6 +14,9 @@
import { SixFrameFeatureDisplay } from './SixFrameFeatureDisplay/stateModel'
import { TabularEditorPane } from './TabularEditor'

import { getSession } from '@jbrowse/core/util'

Check warning on line 17 in packages/jbrowse-plugin-apollo/src/makeDisplayComponent.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/makeDisplayComponent.tsx#L17

Added line #L17 was not covered by tests
import { ApolloSessionModel } from './session'

const accordionControlHeight = 12

const useStyles = makeStyles()((theme) => ({
Expand Down Expand Up @@ -52,6 +55,11 @@
// position: 'relative',
userSelect: 'none',
},
alertContainer: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
}))

function scrollSelectedFeatureIntoView(
Expand Down Expand Up @@ -155,6 +163,11 @@
}: {
model: LinearApolloDisplayI
}) {
const session = getSession(model) as unknown as ApolloSessionModel
const { ontologyManager } = session.apolloDataStore
const { featureTypeOntology } = ontologyManager

Check warning on line 168 in packages/jbrowse-plugin-apollo/src/makeDisplayComponent.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/makeDisplayComponent.tsx#L166-L168

Added lines #L166 - L168 were not covered by tests
const ontologyStore = featureTypeOntology?.dataStore

const { classes } = useStyles()

const {
Expand All @@ -177,6 +190,14 @@
model.setDetailsHeight(detailsHeight - delta)
}

if (!ontologyStore) {
return (

Check warning on line 194 in packages/jbrowse-plugin-apollo/src/makeDisplayComponent.tsx

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/makeDisplayComponent.tsx#L194

Added line #L194 was not covered by tests
<div className={classes.alertContainer}>
<Alert severity="error">Could not load feature type ontology.</Alert>
</div>
)
}

if (graphical && table) {
const tabularHeight = tabularEditor.isShown ? detailsHeight : 0
const featureAreaHeight = isShown
Expand Down