Skip to content

Commit

Permalink
Add ability to launch a protein view from any gene
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 26, 2024
1 parent 0cd5a69 commit 5f757a2
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 4 deletions.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default tseslint.config(
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-empty-function': 'off',

'unicorn/no-array-for-each': 'off',
'unicorn/no-null': 'off',
'unicorn/prefer-spread': 'off',
'unicorn/no-nested-ternary': 'off',
Expand Down
125 changes: 123 additions & 2 deletions src/LaunchProteinView/components/AlphaFoldDBSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Feature,
getContainingView,
getSession,
isSessionWithAddTracks,
} from '@jbrowse/core/util'
import { ErrorMessage, LoadingEllipses } from '@jbrowse/core/ui'
import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
Expand Down Expand Up @@ -186,12 +187,132 @@ const AlphaFoldDBSearch = observer(function ({
connectedViewId: view.id,
},
],
displayName: `Protein view ${getGeneDisplayName(feature)} - ${getTranscriptDisplayName(selectedTranscript)}`,
displayName: `Protein view ${uniprotId} - ${getGeneDisplayName(feature)} - ${getTranscriptDisplayName(selectedTranscript)}`,
})
handleClose()
}}
>
Submit
Launch 3-D protein structure view
</Button>
<Button
variant="contained"
disabled={
!uniprotId || !userSelectedProteinSequence || !selectedTranscript
}
onClick={() => {
if (uniprotId && isSessionWithAddTracks(session)) {
session.addTemporaryAssembly?.({
name: uniprotId,
sequence: {
type: 'ReferenceSequenceTrack',
trackId: `${uniprotId}-ReferenceSequenceTrack`,
sequenceType: 'pep',
adapter: {
type: 'UnindexedFastaAdapter',
rewriteRefNames: "jexl:split(refName,'|')[1]",
fastaLocation: {
uri: `https://rest.uniprot.org/uniprotkb/${uniprotId}.fasta`,
},
},
},
})
;[
'Alternative sequence',
'Beta strand',
'Binding site',
'Chain',
'Compositional bias',
'Cross-link',
'Disulfide bond',
'Domain',
'Glycosylation',
'Helix',
'Modified residue',
'Motif',
'Mutagenesis',
'Natural variant',
'Peptide',
'Region',
'Sequence conflict',
'Signal peptide',
'Site',
'Topological domain',
'Transmembrane',
'Turn',
].forEach(type => {
const s = `${uniprotId}-${type}`
session.addTrackConf({
type: 'FeatureTrack',
trackId: s,
name: type,
adapter: {
type: 'Gff3Adapter',
gffLocation: {
uri: `https://rest.uniprot.org/uniprotkb/${uniprotId}.gff`,
},
},
assemblyNames: [uniprotId],
displays: [
{
displayId: `${type}-LinearBasicDisplay`,
type: 'LinearBasicDisplay',
jexlFilters: [`get(feature,'type')=='${type}'`],
},
],
})
})
session.addTrackConf({
type: 'QuantitativeTrack',
trackId: 'AlphaFold confidence',
name: 'AlphaFold confidence',
adapter: {
type: 'AlphaFoldConfidenceAdapter',
location: {
uri: `https://alphafold.ebi.ac.uk/files/AF-${uniprotId}-F1-confidence_v4.json`,
locationType: 'UriLocation',
},
},
assemblyNames: [uniprotId],
})
session.addTrackConf({
type: 'MultiQuantitativeTrack',
trackId: 'AlphaMissense scores',
name: 'AlphaMissense scores',
assemblyNames: [uniprotId],
adapter: {
type: 'AlphaMissensePathogenicityAdapter',
location: {
locationType: 'UriLocation',
uri: `https://alphafold.ebi.ac.uk/files/AF-${uniprotId}-F1-aa-substitutions.csv`,
},
},
displays: [
{
type: 'MultiLinearWiggleDisplay',
displayId: 'AlphaMissense scores-MultiLinearWiggleDisplay',
defaultRendering: 'multirowdensity',
renderers: {
MultiDensityRenderer: {
type: 'MultiDensityRenderer',
bicolorPivotValue: 0.5,
},
},
},
],
})
const view = session.addView('LinearGenomeView', {
type: 'LinearGenomeView',
displayName: `Protein view ${uniprotId} ${getGeneDisplayName(feature)} - ${getTranscriptDisplayName(selectedTranscript)}`,
}) as LinearGenomeViewModel
view.navToLocString(uniprotId, uniprotId).catch((e: unknown) => {
console.error(e)
session.notifyError(`${e}`, e)
})
}
handleClose()
}}
>
Launch linear protein annotation view
</Button>
</DialogActions>
</>
Expand Down
8 changes: 6 additions & 2 deletions src/LaunchProteinView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ function extendStateModel(stateModel: IAnyModelType) {
...(feature
? [
{
label: 'Launch 3-D protein view',
label: 'Launch protein view',
icon: AddIcon,
onClick: () => {
getSession(track).queueDialog(handleClose => [
LaunchProteinViewDialog,
{ model: track, handleClose, feature },
{
model: track,
handleClose,
feature,
},
])
},
},
Expand Down

0 comments on commit 5f757a2

Please sign in to comment.