jbrowse-plugin-protein3d 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlignTranscriptRpc/index.js +5 -25
- package/dist/AlignTranscriptRpc/isoformRanking.js +24 -0
- package/dist/LaunchProteinView/components/FoldseekActionMenu.js +1 -1
- package/dist/LaunchProteinView/components/ProteinViewActions.js +1 -3
- package/dist/LaunchProteinView/components/UserProvidedStructure.js +1 -1
- package/dist/LaunchProteinView/hooks/useIsoformRanking.js +1 -1
- package/dist/LaunchProteinView/hooks/useTranscriptSelection.js +1 -1
- package/dist/LaunchProteinView/index.js +8 -4
- package/dist/LaunchProteinView/resolveGeneLaunch.js +1 -1
- package/dist/LaunchProteinView/utils/launchViewUtils.js +3 -2
- package/dist/LaunchProteinViewExtensionPoint/annotationView.js +5 -80
- package/dist/LaunchProteinViewExtensionPoint/index.js +7 -85
- package/dist/LaunchProteinViewExtensionPoint/launchAnnotationView.js +82 -0
- package/dist/LaunchProteinViewExtensionPoint/launchProteinView.js +83 -0
- package/dist/ProteinView/addProteinView.js +12 -0
- package/dist/ProteinView/index.js +1 -2
- package/dist/chunks/AddStructureDialog-U6BWWHJW.js +2 -0
- package/dist/chunks/{AddStructureDialog-Z5HMGUWS.js.map → AddStructureDialog-U6BWWHJW.js.map} +1 -1
- package/dist/chunks/{HelpDialog-IRAXBGZB.js → HelpDialog-XVM5IEP4.js} +2 -2
- package/dist/chunks/LaunchProteinViewDialog-KHZEPVNM.js +7 -0
- package/dist/chunks/LaunchProteinViewDialog-KHZEPVNM.js.map +7 -0
- package/dist/chunks/{ManualAlignmentDialog-BTL4LYX2.js → ManualAlignmentDialog-63MGXT7T.js} +2 -2
- package/dist/chunks/{ProteinAlignmentHelpDialog-LURGMLCI.js → ProteinAlignmentHelpDialog-BNW2WV6D.js} +2 -2
- package/dist/chunks/{ProteinView-YFTN6FW3.js → ProteinView-BDDPQYHT.js} +3 -3
- package/dist/chunks/{ProteinView-YFTN6FW3.js.map → ProteinView-BDDPQYHT.js.map} +1 -1
- package/dist/chunks/chunk-2VSFBM55.js +2 -0
- package/dist/chunks/chunk-2VSFBM55.js.map +7 -0
- package/dist/chunks/chunk-56ZPPPNO.js +2 -0
- package/dist/chunks/chunk-56ZPPPNO.js.map +7 -0
- package/dist/chunks/chunk-C6C6ZP3E.js +2 -0
- package/dist/chunks/chunk-C6C6ZP3E.js.map +7 -0
- package/dist/chunks/chunk-CAYS7ALN.js +2 -0
- package/dist/chunks/chunk-CAYS7ALN.js.map +7 -0
- package/dist/chunks/chunk-CKT7MHJV.js +2 -0
- package/dist/chunks/chunk-CKT7MHJV.js.map +7 -0
- package/dist/chunks/chunk-CRY6RO5J.js +2 -0
- package/dist/chunks/chunk-CRY6RO5J.js.map +7 -0
- package/dist/chunks/{chunk-7Q7UK2ZL.js → chunk-CU6NAWYQ.js} +2 -2
- package/dist/chunks/chunk-GEIZQIY6.js +2 -0
- package/dist/chunks/chunk-GEIZQIY6.js.map +7 -0
- package/dist/chunks/chunk-HLJP35OE.js +3 -0
- package/dist/chunks/chunk-HLJP35OE.js.map +7 -0
- package/dist/chunks/chunk-IAAJJTFE.js +2 -0
- package/dist/chunks/chunk-IAAJJTFE.js.map +7 -0
- package/dist/chunks/chunk-IE75QKW6.js +2 -0
- package/dist/chunks/chunk-IE75QKW6.js.map +7 -0
- package/dist/chunks/chunk-JGD4QDSN.js +2 -0
- package/dist/chunks/chunk-JGD4QDSN.js.map +7 -0
- package/dist/chunks/chunk-KMATC3NI.js +2 -0
- package/dist/chunks/chunk-KMATC3NI.js.map +7 -0
- package/dist/chunks/chunk-LZS4UIBQ.js +2 -0
- package/dist/chunks/chunk-LZS4UIBQ.js.map +7 -0
- package/dist/chunks/chunk-NC24P2PF.js +2 -0
- package/dist/chunks/chunk-NC24P2PF.js.map +7 -0
- package/dist/chunks/chunk-NZ3TO6NV.js +2 -0
- package/dist/chunks/chunk-NZ3TO6NV.js.map +7 -0
- package/dist/chunks/chunk-OGVPIMFY.js +2 -0
- package/dist/chunks/chunk-OGVPIMFY.js.map +7 -0
- package/dist/chunks/chunk-P24I4JTG.js +2 -0
- package/dist/chunks/chunk-P24I4JTG.js.map +7 -0
- package/dist/chunks/chunk-Q4RUYXMJ.js +25 -0
- package/dist/chunks/chunk-Q4RUYXMJ.js.map +7 -0
- package/dist/chunks/chunk-S6PS4I6X.js +2 -0
- package/dist/chunks/chunk-S6PS4I6X.js.map +7 -0
- package/dist/chunks/chunk-TXX67FGG.js +2 -0
- package/dist/chunks/chunk-TXX67FGG.js.map +7 -0
- package/dist/chunks/chunk-UVDYWAS6.js +2 -0
- package/dist/chunks/chunk-UVDYWAS6.js.map +7 -0
- package/dist/chunks/chunk-X47I2IB5.js +15 -0
- package/dist/chunks/chunk-X47I2IB5.js.map +7 -0
- package/dist/chunks/chunk-YCRC6WEC.js +2 -0
- package/dist/chunks/chunk-YCRC6WEC.js.map +7 -0
- package/dist/chunks/clinVarSource-W77HO5ZQ.js +2 -0
- package/dist/chunks/esm-AA25HCYO.js +2 -0
- package/dist/chunks/esm-AA25HCYO.js.map +7 -0
- package/dist/chunks/isoformRanking-BCLW5EL6.js +2 -0
- package/dist/chunks/isoformRanking-BCLW5EL6.js.map +7 -0
- package/dist/chunks/launchAnnotationView-O4PUPNFA.js +2 -0
- package/dist/chunks/launchAnnotationView-O4PUPNFA.js.map +7 -0
- package/dist/chunks/launchProteinView-7IHV3Q4W.js +2 -0
- package/dist/chunks/launchProteinView-7IHV3Q4W.js.map +7 -0
- package/dist/chunks/launchViewUtils-D7FKTS4Q.js +2 -0
- package/dist/chunks/launchViewUtils-D7FKTS4Q.js.map +7 -0
- package/dist/chunks/model-FQK2TZ5H.js +2 -0
- package/dist/chunks/model-FQK2TZ5H.js.map +7 -0
- package/dist/chunks/resolveGeneLaunch-FESFI6CM.js +2 -0
- package/dist/chunks/resolveGeneLaunch-FESFI6CM.js.map +7 -0
- package/dist/jbrowse-plugin-protein3d.esm.js +1 -29
- package/dist/jbrowse-plugin-protein3d.esm.js.map +4 -4
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/AlignTranscriptRpc/index.ts +6 -48
- package/src/AlignTranscriptRpc/isoformRanking.ts +42 -0
- package/src/LaunchProteinView/components/FoldseekActionMenu.tsx +1 -1
- package/src/LaunchProteinView/components/ProteinViewActions.tsx +3 -3
- package/src/LaunchProteinView/components/UserProvidedStructure.tsx +1 -1
- package/src/LaunchProteinView/hooks/useIsoformRanking.ts +2 -2
- package/src/LaunchProteinView/hooks/useTranscriptSelection.test.ts +1 -1
- package/src/LaunchProteinView/hooks/useTranscriptSelection.ts +1 -1
- package/src/LaunchProteinView/index.ts +15 -8
- package/src/LaunchProteinView/resolveGeneLaunch.test.ts +1 -1
- package/src/LaunchProteinView/resolveGeneLaunch.ts +5 -2
- package/src/LaunchProteinView/utils/launchViewUtils.ts +3 -2
- package/src/LaunchProteinViewExtensionPoint/annotationView.ts +7 -96
- package/src/LaunchProteinViewExtensionPoint/index.ts +7 -177
- package/src/LaunchProteinViewExtensionPoint/launchAnnotationView.ts +102 -0
- package/src/LaunchProteinViewExtensionPoint/launchProteinView.ts +178 -0
- package/src/LaunchProteinViewExtensionPoint/launchViewSnapshot.test.ts +1 -1
- package/src/ProteinView/addProteinView.ts +18 -0
- package/src/ProteinView/index.ts +1 -3
- package/src/version.ts +1 -1
- package/dist/chunks/AddStructureDialog-Z5HMGUWS.js +0 -2
- package/dist/chunks/chunk-C2KRWQQY.js +0 -2
- package/dist/chunks/chunk-C2KRWQQY.js.map +0 -7
- package/dist/chunks/chunk-EXD7S43Q.js +0 -16
- package/dist/chunks/chunk-EXD7S43Q.js.map +0 -7
- package/dist/chunks/chunk-QPR5H2OZ.js +0 -2
- package/dist/chunks/chunk-QPR5H2OZ.js.map +0 -7
- package/dist/chunks/chunk-R46YRV6D.js +0 -2
- package/dist/chunks/chunk-R46YRV6D.js.map +0 -7
- package/dist/chunks/chunk-RIAQ5NV7.js +0 -2
- package/dist/chunks/chunk-RIAQ5NV7.js.map +0 -7
- package/dist/chunks/clinVarSource-LCO5EZ6C.js +0 -2
- /package/dist/chunks/{HelpDialog-IRAXBGZB.js.map → HelpDialog-XVM5IEP4.js.map} +0 -0
- /package/dist/chunks/{ManualAlignmentDialog-BTL4LYX2.js.map → ManualAlignmentDialog-63MGXT7T.js.map} +0 -0
- /package/dist/chunks/{ProteinAlignmentHelpDialog-LURGMLCI.js.map → ProteinAlignmentHelpDialog-BNW2WV6D.js.map} +0 -0
- /package/dist/chunks/{chunk-7Q7UK2ZL.js.map → chunk-CU6NAWYQ.js.map} +0 -0
- /package/dist/chunks/{clinVarSource-LCO5EZ6C.js.map → clinVarSource-W77HO5ZQ.js.map} +0 -0
|
@@ -1,47 +1,27 @@
|
|
|
1
1
|
import { RpcMethodType } from '@jbrowse/core/pluggableElementTypes';
|
|
2
|
-
import { alignTranscriptToEntity, chooseMappedEntity, classifyIsoforms, pickStructureSequence, } from 'p2s_mapper';
|
|
3
|
-
/** The launch dialog's isoform order: one alignment per chain to pick the
|
|
4
|
-
* chain, then one per isoform that does not match it exactly. */
|
|
5
|
-
export function rankIsoforms(isoforms, structureSequences) {
|
|
6
|
-
const structureSequence = pickStructureSequence(structureSequences, isoforms);
|
|
7
|
-
return {
|
|
8
|
-
structureSequence,
|
|
9
|
-
ranking: classifyIsoforms({ isoforms, structureSequence }),
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* The isoform to open from a ranking. An exact match to the structure wins;
|
|
14
|
-
* the annotation's flagged transcript (MANE Select) breaks a tie between exact
|
|
15
|
-
* matches, and leads when there is no structure to rank against, where length
|
|
16
|
-
* alone would decide.
|
|
17
|
-
*/
|
|
18
|
-
export function rankedTranscriptId({ matches, nonMatches }, flaggedId) {
|
|
19
|
-
const flagged = (list) => list.find(i => i.id === flaggedId);
|
|
20
|
-
const unranked = nonMatches.every(i => i.score === undefined);
|
|
21
|
-
return (flagged(matches) ??
|
|
22
|
-
matches[0] ??
|
|
23
|
-
(unranked ? flagged(nonMatches) : undefined) ??
|
|
24
|
-
nonMatches[0])?.id;
|
|
25
|
-
}
|
|
26
2
|
// The alignment DP runs ~50 ns a cell, so a 4,000-residue transcript against
|
|
27
3
|
// its structure is almost a second and a complex of long chains several: on
|
|
28
4
|
// the main thread, frozen UI. These run it in the host's RPC worker instead,
|
|
29
|
-
// or in place on a host whose driver is MainThreadRpcDriver.
|
|
5
|
+
// or in place on a host whose driver is MainThreadRpcDriver. The aligner loads
|
|
6
|
+
// on the first call, so registering the methods costs the plugin's boot nothing.
|
|
30
7
|
export class ProteinChooseMappedEntity extends RpcMethodType {
|
|
31
8
|
name = 'ProteinChooseMappedEntity';
|
|
32
9
|
async execute({ transcript, entities, algorithm }) {
|
|
10
|
+
const { chooseMappedEntity } = await import('p2s_mapper');
|
|
33
11
|
return chooseMappedEntity(transcript, entities, algorithm);
|
|
34
12
|
}
|
|
35
13
|
}
|
|
36
14
|
export class ProteinAlignTranscriptToEntity extends RpcMethodType {
|
|
37
15
|
name = 'ProteinAlignTranscriptToEntity';
|
|
38
16
|
async execute({ transcript, entitySeq, algorithm }) {
|
|
17
|
+
const { alignTranscriptToEntity } = await import('p2s_mapper');
|
|
39
18
|
return alignTranscriptToEntity(transcript, entitySeq, algorithm);
|
|
40
19
|
}
|
|
41
20
|
}
|
|
42
21
|
export class ProteinRankIsoforms extends RpcMethodType {
|
|
43
22
|
name = 'ProteinRankIsoforms';
|
|
44
23
|
async execute({ isoforms, structureSequences }) {
|
|
24
|
+
const { rankIsoforms } = await import('./isoformRanking');
|
|
45
25
|
return rankIsoforms(isoforms, structureSequences);
|
|
46
26
|
}
|
|
47
27
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { classifyIsoforms, pickStructureSequence } from 'p2s_mapper';
|
|
2
|
+
/** The launch dialog's isoform order: one alignment per chain to pick the
|
|
3
|
+
* chain, then one per isoform that does not match it exactly. */
|
|
4
|
+
export function rankIsoforms(isoforms, structureSequences) {
|
|
5
|
+
const structureSequence = pickStructureSequence(structureSequences, isoforms);
|
|
6
|
+
return {
|
|
7
|
+
structureSequence,
|
|
8
|
+
ranking: classifyIsoforms({ isoforms, structureSequence }),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The isoform to open from a ranking. An exact match to the structure wins;
|
|
13
|
+
* the annotation's flagged transcript (MANE Select) breaks a tie between exact
|
|
14
|
+
* matches, and leads when there is no structure to rank against, where length
|
|
15
|
+
* alone would decide.
|
|
16
|
+
*/
|
|
17
|
+
export function rankedTranscriptId({ matches, nonMatches }, flaggedId) {
|
|
18
|
+
const flagged = (list) => list.find(i => i.id === flaggedId);
|
|
19
|
+
const unranked = nonMatches.every(i => i.score === undefined);
|
|
20
|
+
return (flagged(matches) ??
|
|
21
|
+
matches[0] ??
|
|
22
|
+
(unranked ? flagged(nonMatches) : undefined) ??
|
|
23
|
+
nonMatches[0])?.id;
|
|
24
|
+
}
|
|
@@ -21,7 +21,7 @@ export default function FoldseekActionMenu({ hit, session, view, feature, select
|
|
|
21
21
|
const pdbData = !hit.structureUrl && hasValidCaCoords(hit)
|
|
22
22
|
? caCoordsToPdb(hit.tCa, hit.tSeq, 'A', hit.target)
|
|
23
23
|
: undefined;
|
|
24
|
-
launch3DProteinView({
|
|
24
|
+
return launch3DProteinView({
|
|
25
25
|
...baseParams,
|
|
26
26
|
url: hit.structureUrl,
|
|
27
27
|
data: pdbData,
|
|
@@ -36,9 +36,7 @@ export default function ProteinViewActions({ handleClose, uniprotId, userSelecte
|
|
|
36
36
|
userProvidedTranscriptSequence: userSelectedProteinSequence?.seq,
|
|
37
37
|
sideBySide,
|
|
38
38
|
};
|
|
39
|
-
const handleLaunch3DView = runLaunch(() =>
|
|
40
|
-
launch3DProteinView(launch3DParams);
|
|
41
|
-
});
|
|
39
|
+
const handleLaunch3DView = runLaunch(() => launch3DProteinView(launch3DParams));
|
|
42
40
|
const { launch1D } = getConditionalProteinLaunches({
|
|
43
41
|
session,
|
|
44
42
|
view,
|
|
@@ -70,7 +70,7 @@ const UserProvidedStructure = observer(function UserProvidedStructure({ feature,
|
|
|
70
70
|
const structureData = activeFile
|
|
71
71
|
? await readStructureFile(activeFile)
|
|
72
72
|
: undefined;
|
|
73
|
-
launch3DProteinView({
|
|
73
|
+
await launch3DProteinView({
|
|
74
74
|
session,
|
|
75
75
|
view,
|
|
76
76
|
feature,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSession } from '@jbrowse/core/util';
|
|
2
2
|
import useSWR from 'swr';
|
|
3
3
|
import { STATIC_SWR_OPTIONS } from './swrOptions';
|
|
4
|
-
import { rankIsoforms } from '../../AlignTranscriptRpc';
|
|
4
|
+
import { rankIsoforms } from '../../AlignTranscriptRpc/isoformRanking';
|
|
5
5
|
import { alignOffThread } from '../../ProteinView/alignOffThread';
|
|
6
6
|
/**
|
|
7
7
|
* The isoforms in the order the picker lists them, ranked in the RPC worker:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { rankedTranscriptId } from '../../AlignTranscriptRpc';
|
|
2
|
+
import { rankedTranscriptId } from '../../AlignTranscriptRpc/isoformRanking';
|
|
3
3
|
import { flaggedTranscriptId } from '../codingFeature';
|
|
4
4
|
import { rankableIsoforms } from '../utils/util';
|
|
5
5
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { lazy } from 'react';
|
|
1
2
|
import { getContainingTrack, getContainingView, getSession, isGeneLikeType, } from '@jbrowse/core/util';
|
|
2
3
|
import AddIcon from '@mui/icons-material/Add';
|
|
3
4
|
import { isCodingFeature } from './codingFeature';
|
|
4
|
-
import LaunchProteinViewDialog from './components/LaunchProteinViewDialog';
|
|
5
|
-
import { describeMissingStructure, resolveGeneLaunch, sessionGeneLaunchHost, } from './resolveGeneLaunch';
|
|
6
|
-
import { launch3DProteinView } from './utils/launchViewUtils';
|
|
7
5
|
import { getGeneDisplayName } from './utils/util';
|
|
6
|
+
// the menu items register at boot; what they open loads on the first click
|
|
7
|
+
const LaunchProteinViewDialog = lazy(() => import('./components/LaunchProteinViewDialog'));
|
|
8
8
|
function isDisplay(elt) {
|
|
9
9
|
return elt.name === 'LinearBasicDisplay';
|
|
10
10
|
}
|
|
@@ -84,6 +84,10 @@ function openAlphaFoldStructure(self, target) {
|
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
session.notify(`Looking up the AlphaFold structure of ${name}`, 'info');
|
|
87
|
+
const [{ describeMissingStructure, resolveGeneLaunch, sessionGeneLaunchHost }, { launch3DProteinView },] = await Promise.all([
|
|
88
|
+
import('./resolveGeneLaunch'),
|
|
89
|
+
import('./utils/launchViewUtils'),
|
|
90
|
+
]);
|
|
87
91
|
const launch = await resolveGeneLaunch({
|
|
88
92
|
host: sessionGeneLaunchHost(session, assemblyName),
|
|
89
93
|
feature,
|
|
@@ -91,7 +95,7 @@ function openAlphaFoldStructure(self, target) {
|
|
|
91
95
|
});
|
|
92
96
|
const { transcript, userProvidedTranscriptSequence, uniprotId, url } = launch;
|
|
93
97
|
if (url) {
|
|
94
|
-
launch3DProteinView({
|
|
98
|
+
await launch3DProteinView({
|
|
95
99
|
session,
|
|
96
100
|
view,
|
|
97
101
|
feature,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getConf } from '@jbrowse/core/configuration';
|
|
2
2
|
import { fetchAlphaFoldModels, getAlphaFoldStructureUrl, pickAlphaFoldModel, searchUniProtEntries, } from 'p2s_mapper';
|
|
3
3
|
import { codingTranscripts, flaggedTranscriptId } from './codingFeature';
|
|
4
|
-
import { rankIsoforms, rankedTranscriptId } from '../AlignTranscriptRpc';
|
|
4
|
+
import { rankIsoforms, rankedTranscriptId, } from '../AlignTranscriptRpc/isoformRanking';
|
|
5
5
|
import { fetchTranscriptProteinSeqs } from './utils/translateTranscripts';
|
|
6
6
|
import { extractFeatureIdentifiers, extractTaxonId } from './utils/util';
|
|
7
7
|
import { alignOffThread } from '../ProteinView/alignOffThread';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { maybeLaunchSideBySide } from './sideBySide';
|
|
2
2
|
import { getGeneDisplayName, getTranscriptDisplayName } from './util';
|
|
3
|
+
import { addProteinView } from '../../ProteinView/addProteinView';
|
|
3
4
|
import { proteinViewSnapshot } from '../../ProteinView/proteinViewSpec';
|
|
4
5
|
import { clinVarTrackConfFor } from '../components/clinVarTrackSource';
|
|
5
6
|
import { launchProteinAnnotationView } from '../components/launchProteinAnnotationView';
|
|
@@ -16,7 +17,7 @@ export function formatViewName(prefix, feature, selectedTranscript, uniprotId) {
|
|
|
16
17
|
.filter(s => !!s)
|
|
17
18
|
.join(' - ');
|
|
18
19
|
}
|
|
19
|
-
export function launch3DProteinView({ session, view, feature, selectedTranscript, uniprotId, url, data, userProvidedTranscriptSequence, sideBySide, }) {
|
|
20
|
+
export async function launch3DProteinView({ session, view, feature, selectedTranscript, uniprotId, url, data, userProvidedTranscriptSequence, sideBySide, }) {
|
|
20
21
|
const snap = proteinViewSnapshot({
|
|
21
22
|
displayName: formatViewName('Protein view', feature, selectedTranscript, uniprotId),
|
|
22
23
|
structures: [
|
|
@@ -29,7 +30,7 @@ export function launch3DProteinView({ session, view, feature, selectedTranscript
|
|
|
29
30
|
},
|
|
30
31
|
],
|
|
31
32
|
});
|
|
32
|
-
const proteinView = session
|
|
33
|
+
const proteinView = await addProteinView(session, snap);
|
|
33
34
|
maybeLaunchSideBySide(session, proteinView.id, sideBySide);
|
|
34
35
|
return proteinView;
|
|
35
36
|
}
|
|
@@ -1,91 +1,16 @@
|
|
|
1
|
-
import { SimpleFeature } from '@jbrowse/core/util';
|
|
2
|
-
import { fetchAlphaFoldModels } from 'p2s_mapper';
|
|
3
|
-
import { normalizeAnnotationLaunch } from './normalizeAnnotationLaunch';
|
|
4
|
-
import { connectGenomeView, resolveTranscriptLinkage, } from './transcriptLinkage';
|
|
5
|
-
import { clinVarTrackConfFor } from '../LaunchProteinView/components/clinVarTrackSource';
|
|
6
|
-
import { openProteinAnnotationView } from '../LaunchProteinView/components/launchProteinAnnotationView';
|
|
7
|
-
import { canAddTemporaryAssembly } from '../LaunchProteinView/components/proteinAssemblySetup';
|
|
8
|
-
import { fetchUniProtFeatureTypes } from '../LaunchProteinView/components/proteinTrackSetup';
|
|
9
|
-
import { describeMissingStructure } from '../LaunchProteinView/resolveGeneLaunch';
|
|
10
|
-
import { uniProtEntry } from '../LaunchProteinView/utils/launchViewUtils';
|
|
11
|
-
import { viewAssemblyName } from '../ProteinView/util';
|
|
12
|
-
// The canonical model's pLDDT is in the entry's numbering; an isoform model's
|
|
13
|
-
// is not, and has no place on the entry's track
|
|
14
|
-
async function entryConfidenceUrl(uniprotId) {
|
|
15
|
-
try {
|
|
16
|
-
const models = await fetchAlphaFoldModels(uniprotId);
|
|
17
|
-
return models.find(m => m.accession === uniprotId)?.confidenceUrl;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
1
|
/**
|
|
24
2
|
* The 1D protein-annotation view of a UniProt entry, from a session spec:
|
|
25
3
|
* the same view the launch dialog's 1D option opens, linked to the transcript
|
|
26
4
|
* a `gene` or `transcriptId` names the way a ProteinView spec links its
|
|
27
5
|
* structures. The view itself is a LinearGenomeView on a temporary assembly,
|
|
28
6
|
* so the extension point is named for the spec type rather than the view type.
|
|
7
|
+
*
|
|
8
|
+
* The launch itself loads on first use, so registering it costs the plugin's
|
|
9
|
+
* boot nothing.
|
|
29
10
|
*/
|
|
30
11
|
export default function LaunchProteinAnnotationViewF(pluginManager) {
|
|
31
12
|
pluginManager.addToExtensionPoint('LaunchView-ProteinAnnotationView', async (args) => {
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
console.error(e);
|
|
35
|
-
session.notify(`Could not launch protein annotation view: ${e}`, 'error');
|
|
36
|
-
return args;
|
|
37
|
-
};
|
|
38
|
-
const normalized = normalizeAnnotationLaunch(given);
|
|
39
|
-
for (const warning of normalized.warnings) {
|
|
40
|
-
console.warn(warning);
|
|
41
|
-
session.notify(`Protein annotation view launch: ${warning}`, 'warning');
|
|
42
|
-
}
|
|
43
|
-
if ('error' in normalized) {
|
|
44
|
-
return fail(normalized.error);
|
|
45
|
-
}
|
|
46
|
-
if (!canAddTemporaryAssembly(session)) {
|
|
47
|
-
return fail('this session cannot add the temporary assembly the view opens on');
|
|
48
|
-
}
|
|
49
|
-
const { launch } = normalized;
|
|
50
|
-
try {
|
|
51
|
-
const { named, resolved, connectedView } = await resolveTranscriptLinkage(session, launch, {
|
|
52
|
-
findStructure: !launch.uniprotId,
|
|
53
|
-
});
|
|
54
|
-
const accession = launch.uniprotId ?? named?.uniprotId;
|
|
55
|
-
if (!accession) {
|
|
56
|
-
throw new Error(launch.gene && named
|
|
57
|
-
? `${describeMissingStructure(launch.gene, named)}; name a uniprotId`
|
|
58
|
-
: 'no UniProt entry to open');
|
|
59
|
-
}
|
|
60
|
-
const uniprotId = uniProtEntry(accession);
|
|
61
|
-
// fetched before anything is added, so a failure leaves no view
|
|
62
|
-
const [featureTypes, confidenceUrl] = await Promise.all([
|
|
63
|
-
fetchUniProtFeatureTypes(uniprotId),
|
|
64
|
-
entryConfidenceUrl(uniprotId),
|
|
65
|
-
]);
|
|
66
|
-
const transcript = resolved
|
|
67
|
-
? new SimpleFeature(resolved.feature)
|
|
68
|
-
: undefined;
|
|
69
|
-
const connectedViewId = transcript
|
|
70
|
-
? connectGenomeView(session, launch.connectedViewId, connectedView)
|
|
71
|
-
: undefined;
|
|
72
|
-
await openProteinAnnotationView({
|
|
73
|
-
session,
|
|
74
|
-
feature: transcript,
|
|
75
|
-
selectedTranscript: transcript,
|
|
76
|
-
uniprotId,
|
|
77
|
-
confidenceUrl,
|
|
78
|
-
connectedViewId,
|
|
79
|
-
connectedAssemblyName: (launch.connectedViewId
|
|
80
|
-
? viewAssemblyName(session, launch.connectedViewId)
|
|
81
|
-
: undefined) ?? connectedView?.assembly,
|
|
82
|
-
featureTypes,
|
|
83
|
-
clinVar: (linkage, idPrefix) => clinVarTrackConfFor({ session, linkage, idPrefix }),
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
return fail(e);
|
|
88
|
-
}
|
|
89
|
-
return args;
|
|
13
|
+
const { launchAnnotationView } = await import('./launchAnnotationView');
|
|
14
|
+
return launchAnnotationView(args);
|
|
90
15
|
});
|
|
91
16
|
}
|
|
@@ -1,88 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { maybeLaunchSideBySide } from '../LaunchProteinView/utils/sideBySide';
|
|
6
|
-
import { coerceColorScheme } from '../ProteinView/applyColorTheme';
|
|
7
|
-
import { proteinViewSnapshot } from '../ProteinView/proteinViewSpec';
|
|
8
|
-
export function launchViewSnapshot({ alignmentAlgorithm, colorScheme, ...settings }, structures) {
|
|
9
|
-
return proteinViewSnapshot({
|
|
10
|
-
...settings,
|
|
11
|
-
alignmentAlgorithm: alignmentAlgorithm === undefined
|
|
12
|
-
? undefined
|
|
13
|
-
: coerceAlignmentAlgorithm(alignmentAlgorithm),
|
|
14
|
-
colorScheme: colorScheme === undefined ? undefined : coerceColorScheme(colorScheme),
|
|
15
|
-
structures,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* The launch itself loads on first use, so registering it costs the plugin's
|
|
3
|
+
* boot nothing.
|
|
4
|
+
*/
|
|
18
5
|
export default function LaunchProteinViewExtensionPointF(pluginManager) {
|
|
19
|
-
pluginManager.addToExtensionPoint('LaunchView-ProteinView',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// ("...returned undefined instead of the value it was passed, so its result
|
|
23
|
-
// was ignored"), on every launch. This used to return nothing on the
|
|
24
|
-
// assumption that the result was ignored; it is not. The handler returns
|
|
25
|
-
// its extendee at each exit now, like jbrowse-components' own
|
|
26
|
-
// LaunchDotplotView does.
|
|
27
|
-
async (args) => {
|
|
28
|
-
const { session, structures: _structures, url: _url, data: _data, pdbId: _pdbId, initialSelection: _initialSelection, initialResidues: _initialResidues, initialTranscriptResidues: _initialTranscriptResidues, mappedEntityId: _mappedEntityId, pairwiseAlignment: _pairwiseAlignment, alignmentImported: _alignmentImported, hidden: _hidden, uniprotId, transcriptId, userProvidedTranscriptSequence, feature, connectedViewId, connectedView: givenConnectedView, gene, sideBySide, ...settings } = args;
|
|
29
|
-
const fail = (e) => {
|
|
30
|
-
console.error(e);
|
|
31
|
-
session.notify(`Could not launch protein view: ${e}`, 'error');
|
|
32
|
-
return args;
|
|
33
|
-
};
|
|
34
|
-
const { session: _session, ...launch } = args;
|
|
35
|
-
const normalized = normalizeLaunch(launch);
|
|
36
|
-
for (const warning of normalized.warnings) {
|
|
37
|
-
console.warn(warning);
|
|
38
|
-
session.notify(`Protein view launch: ${warning}`, 'warning');
|
|
39
|
-
}
|
|
40
|
-
if ('error' in normalized) {
|
|
41
|
-
return fail(normalized.error);
|
|
42
|
-
}
|
|
43
|
-
const { geneModel } = normalized;
|
|
44
|
-
// A gene name alone: the host's text search finds the gene, and the
|
|
45
|
-
// launch dialog's defaults pick its isoform and AlphaFold model. A
|
|
46
|
-
// structure, transcript or locus the spec names wins over those. The
|
|
47
|
-
// short form instead derives the feature and sequence from the
|
|
48
|
-
// connected track, and the same mapping applies to every structure.
|
|
49
|
-
let linkage;
|
|
50
|
-
try {
|
|
51
|
-
linkage = await resolveTranscriptLinkage(session, {
|
|
52
|
-
gene,
|
|
53
|
-
transcriptId,
|
|
54
|
-
uniprotId,
|
|
55
|
-
userProvidedTranscriptSequence,
|
|
56
|
-
connectedView: givenConnectedView,
|
|
57
|
-
connectedViewId,
|
|
58
|
-
}, { findStructure: geneModel === 'required' });
|
|
59
|
-
}
|
|
60
|
-
catch (e) {
|
|
61
|
-
return fail(e);
|
|
62
|
-
}
|
|
63
|
-
const { named, resolved, connectedView } = linkage;
|
|
64
|
-
if (gene && named && geneModel === 'required' && !named.url) {
|
|
65
|
-
return fail(new Error(`${describeMissingStructure(gene, named)}; name a ${named.uniprotId ? 'pdbId or url' : 'uniprotId or pdbId'}`));
|
|
66
|
-
}
|
|
67
|
-
const requested = named && geneModel
|
|
68
|
-
? normalized.requested.map(s => ({ ...s, url: named.url }))
|
|
69
|
-
: normalized.requested;
|
|
70
|
-
// a connected view this launch created itself can be split beside the
|
|
71
|
-
// protein view; a pre-existing connectedViewId is left in place
|
|
72
|
-
const ownsConnectedView = !connectedViewId && !!connectedView;
|
|
73
|
-
const resolvedConnectedViewId = connectGenomeView(session, connectedViewId, connectedView);
|
|
74
|
-
const structures = requested.map(s => ({
|
|
75
|
-
...s,
|
|
76
|
-
userProvidedTranscriptSequence: s.userProvidedTranscriptSequence ??
|
|
77
|
-
resolved?.userProvidedTranscriptSequence ??
|
|
78
|
-
userProvidedTranscriptSequence,
|
|
79
|
-
feature: s.feature ?? resolved?.feature ?? feature,
|
|
80
|
-
connectedViewId: s.connectedViewId ?? resolvedConnectedViewId,
|
|
81
|
-
}));
|
|
82
|
-
const proteinView = session.addView('ProteinView', launchViewSnapshot({ displayName: named?.displayName, ...settings }, structures));
|
|
83
|
-
if (ownsConnectedView) {
|
|
84
|
-
maybeLaunchSideBySide(session, proteinView.id, sideBySide);
|
|
85
|
-
}
|
|
86
|
-
return args;
|
|
6
|
+
pluginManager.addToExtensionPoint('LaunchView-ProteinView', async (args) => {
|
|
7
|
+
const { launchProteinView } = await import('./launchProteinView');
|
|
8
|
+
return launchProteinView(args);
|
|
87
9
|
});
|
|
88
10
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { SimpleFeature } from '@jbrowse/core/util';
|
|
2
|
+
import { fetchAlphaFoldModels } from 'p2s_mapper';
|
|
3
|
+
import { normalizeAnnotationLaunch } from './normalizeAnnotationLaunch';
|
|
4
|
+
import { connectGenomeView, resolveTranscriptLinkage, } from './transcriptLinkage';
|
|
5
|
+
import { clinVarTrackConfFor } from '../LaunchProteinView/components/clinVarTrackSource';
|
|
6
|
+
import { openProteinAnnotationView } from '../LaunchProteinView/components/launchProteinAnnotationView';
|
|
7
|
+
import { canAddTemporaryAssembly } from '../LaunchProteinView/components/proteinAssemblySetup';
|
|
8
|
+
import { fetchUniProtFeatureTypes } from '../LaunchProteinView/components/proteinTrackSetup';
|
|
9
|
+
import { describeMissingStructure } from '../LaunchProteinView/resolveGeneLaunch';
|
|
10
|
+
import { uniProtEntry } from '../LaunchProteinView/utils/launchViewUtils';
|
|
11
|
+
import { viewAssemblyName } from '../ProteinView/util';
|
|
12
|
+
// The canonical model's pLDDT is in the entry's numbering; an isoform model's
|
|
13
|
+
// is not, and has no place on the entry's track
|
|
14
|
+
async function entryConfidenceUrl(uniprotId) {
|
|
15
|
+
try {
|
|
16
|
+
const models = await fetchAlphaFoldModels(uniprotId);
|
|
17
|
+
return models.find(m => m.accession === uniprotId)?.confidenceUrl;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export async function launchAnnotationView(args) {
|
|
24
|
+
const { session, ...given } = args;
|
|
25
|
+
const fail = (e) => {
|
|
26
|
+
console.error(e);
|
|
27
|
+
session.notify(`Could not launch protein annotation view: ${e}`, 'error');
|
|
28
|
+
return args;
|
|
29
|
+
};
|
|
30
|
+
const normalized = normalizeAnnotationLaunch(given);
|
|
31
|
+
for (const warning of normalized.warnings) {
|
|
32
|
+
console.warn(warning);
|
|
33
|
+
session.notify(`Protein annotation view launch: ${warning}`, 'warning');
|
|
34
|
+
}
|
|
35
|
+
if ('error' in normalized) {
|
|
36
|
+
return fail(normalized.error);
|
|
37
|
+
}
|
|
38
|
+
if (!canAddTemporaryAssembly(session)) {
|
|
39
|
+
return fail('this session cannot add the temporary assembly the view opens on');
|
|
40
|
+
}
|
|
41
|
+
const { launch } = normalized;
|
|
42
|
+
try {
|
|
43
|
+
const { named, resolved, connectedView } = await resolveTranscriptLinkage(session, launch, {
|
|
44
|
+
findStructure: !launch.uniprotId,
|
|
45
|
+
});
|
|
46
|
+
const accession = launch.uniprotId ?? named?.uniprotId;
|
|
47
|
+
if (!accession) {
|
|
48
|
+
throw new Error(launch.gene && named
|
|
49
|
+
? `${describeMissingStructure(launch.gene, named)}; name a uniprotId`
|
|
50
|
+
: 'no UniProt entry to open');
|
|
51
|
+
}
|
|
52
|
+
const uniprotId = uniProtEntry(accession);
|
|
53
|
+
// fetched before anything is added, so a failure leaves no view
|
|
54
|
+
const [featureTypes, confidenceUrl] = await Promise.all([
|
|
55
|
+
fetchUniProtFeatureTypes(uniprotId),
|
|
56
|
+
entryConfidenceUrl(uniprotId),
|
|
57
|
+
]);
|
|
58
|
+
const transcript = resolved
|
|
59
|
+
? new SimpleFeature(resolved.feature)
|
|
60
|
+
: undefined;
|
|
61
|
+
const connectedViewId = transcript
|
|
62
|
+
? connectGenomeView(session, launch.connectedViewId, connectedView)
|
|
63
|
+
: undefined;
|
|
64
|
+
await openProteinAnnotationView({
|
|
65
|
+
session,
|
|
66
|
+
feature: transcript,
|
|
67
|
+
selectedTranscript: transcript,
|
|
68
|
+
uniprotId,
|
|
69
|
+
confidenceUrl,
|
|
70
|
+
connectedViewId,
|
|
71
|
+
connectedAssemblyName: (launch.connectedViewId
|
|
72
|
+
? viewAssemblyName(session, launch.connectedViewId)
|
|
73
|
+
: undefined) ?? connectedView?.assembly,
|
|
74
|
+
featureTypes,
|
|
75
|
+
clinVar: (linkage, idPrefix) => clinVarTrackConfFor({ session, linkage, idPrefix }),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
return fail(e);
|
|
80
|
+
}
|
|
81
|
+
return args;
|
|
82
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { coerceAlignmentAlgorithm } from 'p2s_mapper';
|
|
2
|
+
import { normalizeLaunch } from './normalizeLaunch';
|
|
3
|
+
import { connectGenomeView, resolveTranscriptLinkage, } from './transcriptLinkage';
|
|
4
|
+
import { describeMissingStructure } from '../LaunchProteinView/resolveGeneLaunch';
|
|
5
|
+
import { maybeLaunchSideBySide } from '../LaunchProteinView/utils/sideBySide';
|
|
6
|
+
import { addProteinView } from '../ProteinView/addProteinView';
|
|
7
|
+
import { coerceColorScheme } from '../ProteinView/applyColorTheme';
|
|
8
|
+
import { proteinViewSnapshot } from '../ProteinView/proteinViewSpec';
|
|
9
|
+
export function launchViewSnapshot({ alignmentAlgorithm, colorScheme, ...settings }, structures) {
|
|
10
|
+
return proteinViewSnapshot({
|
|
11
|
+
...settings,
|
|
12
|
+
alignmentAlgorithm: alignmentAlgorithm === undefined
|
|
13
|
+
? undefined
|
|
14
|
+
: coerceAlignmentAlgorithm(alignmentAlgorithm),
|
|
15
|
+
colorScheme: colorScheme === undefined ? undefined : coerceColorScheme(colorScheme),
|
|
16
|
+
structures,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
// A LaunchView point is a transformer: the chain hands what each callback
|
|
20
|
+
// returns to the next, and JBrowse warns on every launch when one returns
|
|
21
|
+
// undefined. So this returns its extendee at each exit, like
|
|
22
|
+
// jbrowse-components' own LaunchDotplotView.
|
|
23
|
+
export async function launchProteinView(args) {
|
|
24
|
+
const { session, structures: _structures, url: _url, data: _data, pdbId: _pdbId, initialSelection: _initialSelection, initialResidues: _initialResidues, initialTranscriptResidues: _initialTranscriptResidues, mappedEntityId: _mappedEntityId, pairwiseAlignment: _pairwiseAlignment, alignmentImported: _alignmentImported, hidden: _hidden, uniprotId, transcriptId, userProvidedTranscriptSequence, feature, connectedViewId, connectedView: givenConnectedView, gene, sideBySide, ...settings } = args;
|
|
25
|
+
const fail = (e) => {
|
|
26
|
+
console.error(e);
|
|
27
|
+
session.notify(`Could not launch protein view: ${e}`, 'error');
|
|
28
|
+
return args;
|
|
29
|
+
};
|
|
30
|
+
const { session: _session, ...launch } = args;
|
|
31
|
+
const normalized = normalizeLaunch(launch);
|
|
32
|
+
for (const warning of normalized.warnings) {
|
|
33
|
+
console.warn(warning);
|
|
34
|
+
session.notify(`Protein view launch: ${warning}`, 'warning');
|
|
35
|
+
}
|
|
36
|
+
if ('error' in normalized) {
|
|
37
|
+
return fail(normalized.error);
|
|
38
|
+
}
|
|
39
|
+
const { geneModel } = normalized;
|
|
40
|
+
// A gene name alone: the host's text search finds the gene, and the
|
|
41
|
+
// launch dialog's defaults pick its isoform and AlphaFold model. A
|
|
42
|
+
// structure, transcript or locus the spec names wins over those. The
|
|
43
|
+
// short form instead derives the feature and sequence from the
|
|
44
|
+
// connected track, and the same mapping applies to every structure.
|
|
45
|
+
let linkage;
|
|
46
|
+
try {
|
|
47
|
+
linkage = await resolveTranscriptLinkage(session, {
|
|
48
|
+
gene,
|
|
49
|
+
transcriptId,
|
|
50
|
+
uniprotId,
|
|
51
|
+
userProvidedTranscriptSequence,
|
|
52
|
+
connectedView: givenConnectedView,
|
|
53
|
+
connectedViewId,
|
|
54
|
+
}, { findStructure: geneModel === 'required' });
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
return fail(e);
|
|
58
|
+
}
|
|
59
|
+
const { named, resolved, connectedView } = linkage;
|
|
60
|
+
if (gene && named && geneModel === 'required' && !named.url) {
|
|
61
|
+
return fail(new Error(`${describeMissingStructure(gene, named)}; name a ${named.uniprotId ? 'pdbId or url' : 'uniprotId or pdbId'}`));
|
|
62
|
+
}
|
|
63
|
+
const requested = named && geneModel
|
|
64
|
+
? normalized.requested.map(s => ({ ...s, url: named.url }))
|
|
65
|
+
: normalized.requested;
|
|
66
|
+
// a connected view this launch created itself can be split beside the
|
|
67
|
+
// protein view; a pre-existing connectedViewId is left in place
|
|
68
|
+
const ownsConnectedView = !connectedViewId && !!connectedView;
|
|
69
|
+
const resolvedConnectedViewId = connectGenomeView(session, connectedViewId, connectedView);
|
|
70
|
+
const structures = requested.map(s => ({
|
|
71
|
+
...s,
|
|
72
|
+
userProvidedTranscriptSequence: s.userProvidedTranscriptSequence ??
|
|
73
|
+
resolved?.userProvidedTranscriptSequence ??
|
|
74
|
+
userProvidedTranscriptSequence,
|
|
75
|
+
feature: s.feature ?? resolved?.feature ?? feature,
|
|
76
|
+
connectedViewId: s.connectedViewId ?? resolvedConnectedViewId,
|
|
77
|
+
}));
|
|
78
|
+
const proteinView = await addProteinView(session, launchViewSnapshot({ displayName: named?.displayName, ...settings }, structures));
|
|
79
|
+
if (ownsConnectedView) {
|
|
80
|
+
maybeLaunchSideBySide(session, proteinView.id, sideBySide);
|
|
81
|
+
}
|
|
82
|
+
return args;
|
|
83
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getEnv } from '@jbrowse/core/util';
|
|
2
|
+
/**
|
|
3
|
+
* Add a ProteinView, loading its state model first: the model is a lazy
|
|
4
|
+
* loader, so it stays out of the plugin's boot, and a host refuses `addView`
|
|
5
|
+
* for a type whose model has not loaded.
|
|
6
|
+
*/
|
|
7
|
+
export async function addProteinView(session, snapshot) {
|
|
8
|
+
await getEnv(session)
|
|
9
|
+
.pluginManager.getViewType('ProteinView')
|
|
10
|
+
.loadStateModel();
|
|
11
|
+
return session.addView('ProteinView', snapshot);
|
|
12
|
+
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { lazy } from 'react';
|
|
2
2
|
import { ViewType } from '@jbrowse/core/pluggableElementTypes';
|
|
3
|
-
import stateModelF from './model';
|
|
4
3
|
const ReactComponent = lazy(() => import('./components/ProteinView'));
|
|
5
4
|
export default function ProteinViewF(pluginManager) {
|
|
6
5
|
pluginManager.addViewType(() => {
|
|
7
6
|
return new ViewType({
|
|
8
7
|
name: 'ProteinView',
|
|
9
8
|
displayName: 'Protein view',
|
|
10
|
-
stateModel:
|
|
9
|
+
stateModel: () => import('./model').then(m => m.default()),
|
|
11
10
|
ReactComponent,
|
|
12
11
|
});
|
|
13
12
|
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as m,b as C,c as S,d as P}from"./chunk-UXGREKQA.js";import{a as W}from"./chunk-LOG7ZCI7.js";import{Ja as p}from"./chunk-Q4RUYXMJ.js";import"./chunk-SPXMXPSC.js";import{a as q}from"./chunk-HAGLAQP5.js";import{a as N}from"./chunk-HLB63AD7.js";import{a as V}from"./chunk-GVEKA5YG.js";import{c as a}from"./chunk-KVMUXFPB.js";var e=a(V()),T=a(N()),r=a(q()),I=a(W());var _=(0,I.observer)(function({model:s,handleClose:c}){let[n,D]=(0,e.useState)(),[l,x]=(0,e.useState)(""),[u,A]=(0,e.useState)(""),[t,U]=(0,e.useState)("pdb"),[d,w]=(0,e.useState)(""),[g,h]=(0,e.useState)(),[F,f]=(0,e.useState)(!1),[b,B]=(0,e.useState)(!0),k=!!s.primaryStructure?.userProvidedTranscriptSequence,E=async()=>{f(!0),h(void 0);try{let o=t==="pdb"&&l?{pdbId:l}:t==="uniprot"&&u?{uniprotId:u}:t==="url"&&d?{url:d}:t==="file"&&n?{data:await S(n)}:void 0;if(o){let i=s.primaryStructure,L=b&&i?.userProvidedTranscriptSequence?{userProvidedTranscriptSequence:i.userProvidedTranscriptSequence,feature:i.feature,connectedViewId:i.connectedViewId}:{};s.addStructure({...o,...L}),c()}}catch(o){console.error(o),h(o)}finally{f(!1)}},v=l!==""&&!p(l),y=u!==""&&!m(u),M=t==="url"&&d!==""||t==="file"&&n!==void 0||t==="pdb"&&p(l)||t==="uniprot"&&m(u);return e.default.createElement(r.Dialog,{open:!0,onClose:c,maxWidth:"sm",fullWidth:!0},e.default.createElement(r.DialogTitle,null,"Add structure"),e.default.createElement(r.DialogContent,null,g?e.default.createElement(T.ErrorMessage,{error:g}):null,e.default.createElement(r.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2}},"Add another structure to superpose on the existing structure(s)."),e.default.createElement(r.FormControl,{component:"fieldset",sx:{mb:2}},e.default.createElement(r.RadioGroup,{value:t,onChange:o=>{U(o.target.value)}},e.default.createElement(r.FormControlLabel,{value:"pdb",control:e.default.createElement(r.Radio,null),label:"PDB ID"}),e.default.createElement(r.FormControlLabel,{value:"uniprot",control:e.default.createElement(r.Radio,null),label:"UniProt ID (AlphaFold)"}),e.default.createElement(r.FormControlLabel,{value:"url",control:e.default.createElement(r.Radio,null),label:"URL"}),e.default.createElement(r.FormControlLabel,{value:"file",control:e.default.createElement(r.Radio,null),label:"File"}))),t==="pdb"?e.default.createElement(r.TextField,{fullWidth:!0,value:l,onChange:o=>{x(o.target.value.trim().toUpperCase())},label:"PDB ID (e.g. 1CRN)",placeholder:"Enter PDB ID",error:v,helperText:v?"A PDB ID is four characters beginning with a digit":void 0,sx:{mb:2}}):null,t==="uniprot"?e.default.createElement(r.TextField,{fullWidth:!0,value:u,onChange:o=>{A(o.target.value.trim().toUpperCase())},label:"UniProt ID (e.g. P04637)",placeholder:"Enter UniProt ID",error:y,helperText:y?C:"Fetches the AlphaFold predicted structure",sx:{mb:2}}):null,t==="url"?e.default.createElement(r.TextField,{fullWidth:!0,label:"Structure URL",value:d,onChange:o=>{w(o.target.value.trim())},placeholder:"https://files.rcsb.org/download/1CRN.cif",sx:{mb:2}}):null,t==="file"?e.default.createElement("div",{style:{marginBottom:16}},e.default.createElement(r.Button,{variant:"outlined",component:"label"},n?n.name:"Choose file",e.default.createElement("input",{type:"file",hidden:!0,accept:P,onChange:({target:o})=>{let i=o.files?.[0];i&&D(i)}})),n?e.default.createElement(r.Typography,{variant:"body2",sx:{mt:1}},"Selected: ",n.name):null):null,k?e.default.createElement(r.FormControlLabel,{control:e.default.createElement(r.Checkbox,{checked:b,onChange:o=>{B(o.target.checked)}}),label:"Map to the same transcript as the first structure (alignment, hover and click linked to the genome)"}):null,e.default.createElement(r.Typography,{variant:"body2",color:"text.secondary",sx:{mt:1}},"Tip: Structures will be automatically superposed using TM-align. For manual control, use the Mol* controls (\u{1F527} wrench icon).")),e.default.createElement(r.DialogActions,null,e.default.createElement(r.Button,{onClick:c},"Cancel"),e.default.createElement(r.Button,{onClick:()=>{E()},variant:"contained",color:"primary",disabled:!M||F},"Add structure")))}),j=_;export{j as default};
|
|
2
|
+
//# sourceMappingURL=AddStructureDialog-U6BWWHJW.js.map
|