mirror of
https://github.com/molstar/molstar.git
synced 2026-06-05 14:04:36 +08:00
Compare commits
105 Commits
v3.0.0-dev
...
v3.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7f75861de | ||
|
|
ccd04dbc9d | ||
|
|
e71f8d2c10 | ||
|
|
d9b4c60239 | ||
|
|
103c1fca21 | ||
|
|
49559bf5fb | ||
|
|
26dceabf83 | ||
|
|
abe506182e | ||
|
|
582a0e2a38 | ||
|
|
2784ccf379 | ||
|
|
0ad1d578fe | ||
|
|
31fd1c9c68 | ||
|
|
9c961297a2 | ||
|
|
b920053349 | ||
|
|
0a5c764e4a | ||
|
|
b9a71c83ff | ||
|
|
3255f207d0 | ||
|
|
e3b4ca8862 | ||
|
|
6810793015 | ||
|
|
1feb3c2095 | ||
|
|
f2da6033d0 | ||
|
|
28bc212132 | ||
|
|
1a7c62eec6 | ||
|
|
de67dbacba | ||
|
|
57223a0f9a | ||
|
|
2ad0754b90 | ||
|
|
3ecb3af57b | ||
|
|
ec4f15f549 | ||
|
|
2458ea7b92 | ||
|
|
c5e6bedf11 | ||
|
|
8528e5a666 | ||
|
|
6ed232b3d9 | ||
|
|
f8aae8cbd1 | ||
|
|
00c2517045 | ||
|
|
99b043a929 | ||
|
|
5900e27e39 | ||
|
|
1b79d34907 | ||
|
|
fc52e29c92 | ||
|
|
df23b3c0fe | ||
|
|
5e25716c98 | ||
|
|
f70a10bc56 | ||
|
|
0ccb045f4e | ||
|
|
fa18d0d852 | ||
|
|
687c4342fb | ||
|
|
9459af46b8 | ||
|
|
fc5832747a | ||
|
|
01205d244b | ||
|
|
31a555255a | ||
|
|
fbb60c9493 | ||
|
|
9f953ef51c | ||
|
|
4871f1547c | ||
|
|
d6413529f4 | ||
|
|
724cf5a0da | ||
|
|
b6847907ca | ||
|
|
fb54a1aed7 | ||
|
|
9815318daf | ||
|
|
bc13b98111 | ||
|
|
238b70c121 | ||
|
|
dcd23bc0cb | ||
|
|
4694ea85fa | ||
|
|
bdb17743d7 | ||
|
|
8b76ff2461 | ||
|
|
ea5421002b | ||
|
|
76ac55917d | ||
|
|
5cfb2376c4 | ||
|
|
6b9d3fd80e | ||
|
|
a09752b62e | ||
|
|
3134e1d9f9 | ||
|
|
e94ecf2a0b | ||
|
|
1bd4d841a1 | ||
|
|
8e349f47a5 | ||
|
|
119c0a4231 | ||
|
|
f009f533e0 | ||
|
|
3ab0c1e509 | ||
|
|
e3d264e239 | ||
|
|
9bd60f8e8e | ||
|
|
bcec1d9637 | ||
|
|
1b431b1d20 | ||
|
|
23c2dcdfd4 | ||
|
|
dd415bf802 | ||
|
|
7bc0e9db7c | ||
|
|
ca10bb01db | ||
|
|
ade5e4d4b8 | ||
|
|
cb76b53a1b | ||
|
|
b9423f70d4 | ||
|
|
796a034fec | ||
|
|
f9deb54352 | ||
|
|
eae3c1b33a | ||
|
|
5c5f8aa741 | ||
|
|
ba68ac2e32 | ||
|
|
239fef281e | ||
|
|
c0880b647f | ||
|
|
039dc6a76b | ||
|
|
042a7625ad | ||
|
|
41827c478d | ||
|
|
9a73180c3c | ||
|
|
333ee85fdb | ||
|
|
fa8ca45b6a | ||
|
|
c2bae1aeb7 | ||
|
|
13ea97bd98 | ||
|
|
009a17a9ca | ||
|
|
ca38d9adb1 | ||
|
|
4e5a86e3db | ||
|
|
a736fe7989 | ||
|
|
1970b7f249 |
50
CHANGELOG.md
50
CHANGELOG.md
@@ -6,6 +6,56 @@ Note that since we don't clearly distinguish between a public and private interf
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [v3.0.2] - 2022-01-30
|
||||
|
||||
- Fix color smoothing of elongated structures (by fixing ``Sphere.expand`` for spheres with highly directional extrema)
|
||||
- Fix entity label not displayed when multiple instances of the same entity are highlighted
|
||||
- Fix empty elements created in ``StructureElement.Loci.extendToAllInstances``
|
||||
- Measurement options tweaks (allow larger ``textSize``; make ``customText`` essential)
|
||||
- Fix visual visibility sync edge case when changing state snapshots
|
||||
|
||||
## [v3.0.1] - 2022-01-27
|
||||
|
||||
- Fix marking pass not working with ``transparentBackground``
|
||||
- Fix pdbe xray maps url not https
|
||||
- Fix entity-id color theme broken for non-IHM models
|
||||
- Improve/fix marking of ``InteractionsInterUnitVisual`` (mark when all contact-feature members are given)
|
||||
- Add missing "entity-id" and "enity-source" options for carbon coloring to "element-symbol" color theme
|
||||
- Fix VolumeServer/query CLI
|
||||
- Support automatic iso-value adjustment for VolumeServer data in ``Viewer.loadVolumeFromUrl``
|
||||
- Emit drag event whenever started within viewport (not only for non-empty loci)
|
||||
|
||||
## [v3.0.0] - 2022-01-23
|
||||
|
||||
- Assembly handling tweaks:
|
||||
- Do not include suffix for "identity assembly operators"
|
||||
- Do not include assembly-related categories to export if the structure was composed from an assembly
|
||||
- Special case for ``structAsymMap`` if Mol* asym id operator mapping is present
|
||||
- Support for opening ZIP files with multiple entries
|
||||
- Add Model Export extension
|
||||
- Bugfix: Automatically treat empty string as "non-present" value in BinaryCIF writer.
|
||||
- Fix coarse model support in entity-id color theme
|
||||
- Fix marking of carbohydrate visuals (whole chain could get marked instead of single residue)
|
||||
- Add custom colors to "element-symbol", "molecule-type", "residue-name", and "secondary-structure" themes
|
||||
- Support/bugfixes for ``atom_site.pdbx_sifts_xref`` categories
|
||||
- Improve/fix marking of ``InteractionsIntraUnitVisual`` (mark when all contact-feature members are given)
|
||||
|
||||
## [v3.0.0-dev.10] - 2022-01-17
|
||||
|
||||
- Fix ``getOperatorsForIndex``
|
||||
- Pass animation info (current frame & count) to state animations
|
||||
- Fix camera stutter for "camera spin" animation
|
||||
- Add formal charge parsing support for MOL/SDF files (thanks @ptourlas)
|
||||
- [Breaking] Cleaner looking ``MembraneOrientationVisuals`` defaults
|
||||
- [Breaking] Add rock animation to trackball controls
|
||||
- Add ``animate`` to ``TrackballControlsParams``, remove ``spin`` and ``spinSpeed``
|
||||
- Add ``animate`` to ``SimpleSettingsParams``, remove ``spin``
|
||||
- Add "camera rock" state animation
|
||||
- Add support for custom colors to "molecule-type" theme
|
||||
- [Breaking] Add style parameter to "illustrative" color theme
|
||||
- Defaults to "entity-id" style instead of "chain-id"
|
||||
- Add "illustrative" representation preset
|
||||
|
||||
## [v3.0.0-dev.9] - 2022-01-09
|
||||
|
||||
- Add PDBj as a ``pdb-provider`` option
|
||||
|
||||
72
CITATION.cff
Normal file
72
CITATION.cff
Normal file
@@ -0,0 +1,72 @@
|
||||
cff-version: 1.2.0
|
||||
title: >-
|
||||
Mol* library
|
||||
message: >-
|
||||
Please cite this software using the metadata from
|
||||
'preferred-citation'.
|
||||
authors:
|
||||
- given-names: Alexander S
|
||||
family-names: Rose
|
||||
orcid: 'https://orcid.org/0000-0002-0893-5551'
|
||||
- given-names: David
|
||||
family-names: Sehnal
|
||||
orcid: 'https://orcid.org/0000-0002-0682-3089'
|
||||
- given-names: Sebastian
|
||||
family-names: Bittrich
|
||||
orcid: 'https://orcid.org/0000-0003-3576-0387'
|
||||
- given-names: Áron Samuel
|
||||
family-names: Kovács
|
||||
- given-names: Ludovic
|
||||
family-names: Autin
|
||||
orcid: 'https://orcid.org/0000-0002-2197-191X'
|
||||
- given-names: Michal
|
||||
family-names: Malý
|
||||
- given-names: Jiří
|
||||
family-names: Černý
|
||||
- given-names: Panagiotis
|
||||
family-names: Tourlas
|
||||
type: software
|
||||
doi: 10.5281/zenodo.3947306
|
||||
preferred-citation:
|
||||
authors:
|
||||
- given-names: David
|
||||
family-names: Sehnal
|
||||
orcid: 'https://orcid.org/0000-0002-0682-3089'
|
||||
- given-names: Sebastian
|
||||
family-names: Bittrich
|
||||
orcid: 'https://orcid.org/0000-0003-3576-0387'
|
||||
- given-names: Mandar
|
||||
family-names: Deshpande
|
||||
orcid: 'https://orcid.org/0000-0002-9043-7665'
|
||||
- given-names: Radka
|
||||
family-names: Svobodová
|
||||
orcid: 'https://orcid.org/0000-0002-3840-8760'
|
||||
- given-names: Karel
|
||||
family-names: Berka
|
||||
orcid: 'https://orcid.org/0000-0001-9472-2589'
|
||||
- given-names: Václav
|
||||
family-names: Bazgier
|
||||
orcid: 'https://orcid.org/0000-0003-3393-3010'
|
||||
- given-names: Sameer
|
||||
family-names: Velankar
|
||||
orcid: 'https://orcid.org/0000-0002-8439-5964'
|
||||
- given-names: Stephen K
|
||||
family-names: Burley
|
||||
orcid: 'https://orcid.org/0000-0002-2487-9713'
|
||||
- given-names: Jaroslav
|
||||
family-names: Koča
|
||||
orcid: 'https://orcid.org/0000-0002-2780-4901'
|
||||
- given-names: Alexander S
|
||||
family-names: Rose
|
||||
orcid: 'https://orcid.org/0000-0002-0893-5551'
|
||||
title: >-
|
||||
Mol* Viewer: modern web app for 3D visualization
|
||||
and analysis of large biomolecular structures
|
||||
type: article
|
||||
doi: 10.1093/nar/gkab314
|
||||
journal: "Nucleic Acids Research"
|
||||
issue: W1
|
||||
volume: 49
|
||||
year: 2021
|
||||
month: 7
|
||||
pages: "W431–W437"
|
||||
@@ -11,6 +11,13 @@ When using Mol*, please cite:
|
||||
|
||||
David Sehnal, Sebastian Bittrich, Mandar Deshpande, Radka Svobodová, Karel Berka, Václav Bazgier, Sameer Velankar, Stephen K Burley, Jaroslav Koča, Alexander S Rose: [Mol* Viewer: modern web app for 3D visualization and analysis of large biomolecular structures](https://doi.org/10.1093/nar/gkab314), *Nucleic Acids Research*, 2021; https://doi.org/10.1093/nar/gkab314.
|
||||
|
||||
### Protein Data Bank Integrations
|
||||
|
||||
- The [pdbe-molstar](https://github.com/molstar/pdbe-molstar) library is the Mol* implementation used by EMBL-EBI data resources such as [PDBe](https://pdbe.org/), [PDBe-KB](https://pdbe-kb.org/) and [AlphaFold DB](https://alphafold.ebi.ac.uk/). This implementation can be used as a JS plugin and a Web component and supports property/attribute-based easy customisation. It provides helper methods to facilitate programmatic interactions between the web application and the 3D viewer. It also provides a superposition view for overlaying all the observed ligand molecules on representative protein conformations.
|
||||
|
||||
- [rcsb-molstar](https://github.com/molstar/rcsb-molstar) is the Mol* plugin used by [RCSB PDB](https://www.rcsb.org). The project provides additional presets for the visualization of structure alignments and structure motifs such as ligand binding sites. Furthermore, [rcsb-molstar](https://github.com/molstar/rcsb-molstar) allows to interactively add or hide of (parts of) chains, as seen in the [3D Protein Feature View](https://www.rcsb.org/3d-sequence/4hhb).
|
||||
|
||||
|
||||
## Project Structure Overview
|
||||
|
||||
The core of Mol* consists of these modules (see under `src/`):
|
||||
|
||||
8538
package-lock.json
generated
8538
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
74
package.json
74
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "molstar",
|
||||
"version": "3.0.0-dev.9",
|
||||
"version": "3.0.2",
|
||||
"description": "A comprehensive macromolecular library.",
|
||||
"homepage": "https://github.com/molstar/molstar#readme",
|
||||
"repository": {
|
||||
@@ -13,7 +13,7 @@
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"lint-fix": "eslint . --fix",
|
||||
"test": "npm run lint && jest",
|
||||
"test": "npm install --no-save \"gl@^5.0.0\" && npm run lint && jest",
|
||||
"jest": "jest",
|
||||
"build": "npm run build-tsc && npm run build-extra && npm run build-webpack",
|
||||
"clean": "node ./scripts/clean.js",
|
||||
@@ -86,45 +86,46 @@
|
||||
"Áron Samuel Kovács <aron.kovacs@mail.muni.cz>",
|
||||
"Ludovic Autin <autin@scripps.edu>",
|
||||
"Michal Malý <michal.maly@ibt.cas.cz>",
|
||||
"Jiří Černý <jiri.cerny@ibt.cas.cz>"
|
||||
"Jiří Černý <jiri.cerny@ibt.cas.cz>",
|
||||
"Panagiotis Tourlas <panagiot_tourlov@hotmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@graphql-codegen/add": "^3.1.0",
|
||||
"@graphql-codegen/cli": "^2.3.0",
|
||||
"@graphql-codegen/time": "^3.1.0",
|
||||
"@graphql-codegen/typescript": "^2.4.1",
|
||||
"@graphql-codegen/typescript-graphql-files-modules": "^2.1.0",
|
||||
"@graphql-codegen/typescript-graphql-request": "^4.3.1",
|
||||
"@graphql-codegen/typescript-operations": "^2.2.1",
|
||||
"@graphql-codegen/add": "^3.1.1",
|
||||
"@graphql-codegen/cli": "^2.4.0",
|
||||
"@graphql-codegen/time": "^3.1.1",
|
||||
"@graphql-codegen/typescript": "^2.4.2",
|
||||
"@graphql-codegen/typescript-graphql-files-modules": "^2.1.1",
|
||||
"@graphql-codegen/typescript-graphql-request": "^4.3.3",
|
||||
"@graphql-codegen/typescript-operations": "^2.2.2",
|
||||
"@types/cors": "^2.8.12",
|
||||
"@types/gl": "^4.1.0",
|
||||
"@types/jest": "^27.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
||||
"@typescript-eslint/parser": "^5.5.0",
|
||||
"@types/jest": "^27.4.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
||||
"@typescript-eslint/parser": "^5.10.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"concurrently": "^6.4.0",
|
||||
"cpx2": "^4.0.0",
|
||||
"concurrently": "^7.0.0",
|
||||
"cpx2": "^4.1.2",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"css-loader": "^6.5.1",
|
||||
"eslint": "^8.3.0",
|
||||
"eslint": "^8.7.0",
|
||||
"extra-watch-webpack-plugin": "^1.0.3",
|
||||
"file-loader": "^6.2.0",
|
||||
"fs-extra": "^10.0.0",
|
||||
"graphql": "^15.7.2",
|
||||
"http-server": "^14.0.0",
|
||||
"jest": "^27.3.1",
|
||||
"mini-css-extract-plugin": "^2.4.5",
|
||||
"graphql": "^16.2.0",
|
||||
"http-server": "^14.1.0",
|
||||
"jest": "^27.4.7",
|
||||
"mini-css-extract-plugin": "^2.5.2",
|
||||
"path-browserify": "^1.0.1",
|
||||
"raw-loader": "^4.0.2",
|
||||
"sass": "^1.43.5",
|
||||
"sass-loader": "^12.3.0",
|
||||
"simple-git": "^2.47.0",
|
||||
"sass": "^1.49.0",
|
||||
"sass-loader": "^12.4.0",
|
||||
"simple-git": "^2.48.0",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"style-loader": "^3.3.1",
|
||||
"ts-jest": "^27.0.7",
|
||||
"typescript": "^4.5.2",
|
||||
"webpack": "^5.64.4",
|
||||
"ts-jest": "^27.1.3",
|
||||
"typescript": "^4.5.5",
|
||||
"webpack": "^5.67.0",
|
||||
"webpack-cli": "^4.9.1"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -132,22 +133,22 @@
|
||||
"@types/benchmark": "^2.1.1",
|
||||
"@types/compression": "1.7.2",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/node": "^16.11.10",
|
||||
"@types/node": "^16.11.21",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"@types/react": "^17.0.37",
|
||||
"@types/react": "^17.0.38",
|
||||
"@types/react-dom": "^17.0.11",
|
||||
"@types/swagger-ui-dist": "3.30.1",
|
||||
"argparse": "^2.0.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"body-parser": "^1.19.1",
|
||||
"compression": "^1.7.4",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
"express": "^4.17.2",
|
||||
"h264-mp4-encoder": "^1.0.12",
|
||||
"immer": "^9.0.7",
|
||||
"immutable": "^3.8.2",
|
||||
"node-fetch": "^2.6.2",
|
||||
"rxjs": "^7.4.0",
|
||||
"swagger-ui-dist": "^4.1.1",
|
||||
"immer": "^9.0.12",
|
||||
"immutable": "^4.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"rxjs": "^7.5.2",
|
||||
"swagger-ui-dist": "^4.2.1",
|
||||
"tslib": "^2.3.1",
|
||||
"util.promisify": "^1.1.1",
|
||||
"xhr2": "^0.2.1"
|
||||
@@ -155,8 +156,5 @@
|
||||
"peerDependencies": {
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"gl": "^4.9.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,11 @@ import { GeometryExport } from '../../extensions/geo-export';
|
||||
import { MAQualityAssessment } from '../../extensions/model-archive/quality-assessment/behavior';
|
||||
import { QualityAssessmentPLDDTPreset, QualityAssessmentQmeanPreset } from '../../extensions/model-archive/quality-assessment/behavior';
|
||||
import { QualityAssessment } from '../../extensions/model-archive/quality-assessment/prop';
|
||||
import { ModelExport } from '../../extensions/model-export';
|
||||
import { Mp4Export } from '../../extensions/mp4-export';
|
||||
import { PDBeStructureQualityReport } from '../../extensions/pdbe';
|
||||
import { RCSBAssemblySymmetry, RCSBValidationReport } from '../../extensions/rcsb';
|
||||
import { Volume } from '../../mol-model/volume';
|
||||
import { DownloadStructure, PdbDownloadProvider } from '../../mol-plugin-state/actions/structure';
|
||||
import { DownloadDensity } from '../../mol-plugin-state/actions/volume';
|
||||
import { PresetTrajectoryHierarchy } from '../../mol-plugin-state/builder/structure/hierarchy-preset';
|
||||
@@ -57,6 +59,7 @@ const Extensions = {
|
||||
'rcsb-validation-report': PluginSpec.Behavior(RCSBValidationReport),
|
||||
'anvil-membrane-orientation': PluginSpec.Behavior(ANVILMembraneOrientation),
|
||||
'g3d': PluginSpec.Behavior(G3DFormat),
|
||||
'model-export': PluginSpec.Behavior(ModelExport),
|
||||
'mp4-export': PluginSpec.Behavior(Mp4Export),
|
||||
'geo-export': PluginSpec.Behavior(GeometryExport),
|
||||
'ma-quality-assessment': PluginSpec.Behavior(MAQualityAssessment),
|
||||
@@ -99,7 +102,14 @@ export class Viewer {
|
||||
}
|
||||
|
||||
static async create(elementOrId: string | HTMLElement, options: Partial<ViewerOptions> = {}) {
|
||||
const o = { ...DefaultViewerOptions, ...options };
|
||||
const definedOptions = {} as any;
|
||||
// filter for defined properies only so the default values
|
||||
// are property applied
|
||||
for (const p of Object.keys(options) as (keyof ViewerOptions)[]) {
|
||||
if (options[p] !== void 0) definedOptions[p] = options[p];
|
||||
}
|
||||
|
||||
const o: ViewerOptions = { ...DefaultViewerOptions, ...definedOptions };
|
||||
const defaultSpec = DefaultPluginUISpec();
|
||||
|
||||
const spec: PluginUISpec = {
|
||||
@@ -357,11 +367,13 @@ export class Viewer {
|
||||
|
||||
const repr = plugin.build();
|
||||
for (const iso of isovalues) {
|
||||
const volume: StateObjectSelector<PluginStateObject.Volume.Data> = parsed.volumes?.[iso.volumeIndex ?? 0] ?? parsed.volume;
|
||||
const volumeData = volume.cell!.obj!.data;
|
||||
repr
|
||||
.to(parsed.volumes?.[iso.volumeIndex ?? 0] ?? parsed.volume)
|
||||
.to(volume)
|
||||
.apply(StateTransforms.Representation.VolumeRepresentation3D, createVolumeRepresentationParams(this.plugin, firstVolume.data!, {
|
||||
type: 'isosurface',
|
||||
typeParams: { alpha: iso.alpha ?? 1, isoValue: iso.type === 'absolute' ? { kind: 'absolute', absoluteValue: iso.value } : { kind: 'relative', relativeValue: iso.value } },
|
||||
typeParams: { alpha: iso.alpha ?? 1, isoValue: Volume.adjustedIsoValue(volumeData, iso.value, iso.type) },
|
||||
color: 'uniform',
|
||||
colorParams: { value: iso.color }
|
||||
}));
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
var pickScale = getParam('pick-scale', '[^&]+').trim();
|
||||
var pickPadding = getParam('pick-padding', '[^&]+').trim();
|
||||
var disableWboit = getParam('disable-wboit', '[^&]+').trim() === '1';
|
||||
var preferWebgl1 = getParam('prefer-webgl1', '[^&]+').trim() === '1';
|
||||
var preferWebgl1 = getParam('prefer-webgl1', '[^&]+').trim() === '1' || void 0;
|
||||
|
||||
molstar.Viewer.create('app', {
|
||||
layoutShowControls: !hideControls,
|
||||
@@ -71,7 +71,7 @@
|
||||
pixelScale: parseFloat(pixelScale) || 1,
|
||||
pickScale: parseFloat(pickScale) || 0.25,
|
||||
pickPadding: isNaN(parseFloat(pickPadding)) ? 1 : parseFloat(pickPadding),
|
||||
enableWboit: !disableWboit,
|
||||
enableWboit: disableWboit ? true : void 0, // use default value if disable-wboit is not set
|
||||
preferWebgl1: preferWebgl1,
|
||||
}).then(viewer => {
|
||||
var snapshotId = getParam('snapshot-id', '[^&]+').trim();
|
||||
|
||||
@@ -9,4 +9,4 @@ import './embedded.html';
|
||||
import './favicon.ico';
|
||||
import './index.html';
|
||||
require('mol-plugin-ui/skin/light.scss');
|
||||
export * from './app';
|
||||
export * from './app';
|
||||
|
||||
@@ -74,12 +74,20 @@ class BasicWrapper {
|
||||
toggleSpin() {
|
||||
if (!this.plugin.canvas3d) return;
|
||||
|
||||
const trackball = this.plugin.canvas3d.props.trackball;
|
||||
PluginCommands.Canvas3D.SetSettings(this.plugin, {
|
||||
settings: props => {
|
||||
props.trackball.spin = !props.trackball.spin;
|
||||
settings: {
|
||||
trackball: {
|
||||
...trackball,
|
||||
animate: trackball.animate.name === 'spin'
|
||||
? { name: 'off', params: {} }
|
||||
: { name: 'spin', params: { speed: 1 } }
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!this.plugin.canvas3d.props.trackball.spin) PluginCommands.Camera.Reset(this.plugin, {});
|
||||
if (this.plugin.canvas3d.props.trackball.animate.name !== 'spin') {
|
||||
PluginCommands.Camera.Reset(this.plugin, {});
|
||||
}
|
||||
}
|
||||
|
||||
private animateModelIndexTargetFps() {
|
||||
|
||||
@@ -256,7 +256,16 @@ class MolStarProteopediaWrapper {
|
||||
toggleSpin() {
|
||||
if (!this.plugin.canvas3d) return;
|
||||
const trackball = this.plugin.canvas3d.props.trackball;
|
||||
PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { trackball: { ...trackball, spin: !trackball.spin } } });
|
||||
PluginCommands.Canvas3D.SetSettings(this.plugin, {
|
||||
settings: {
|
||||
trackball: {
|
||||
...trackball,
|
||||
animate: trackball.animate.name === 'spin'
|
||||
? { name: 'off', params: {} }
|
||||
: { name: 'spin', params: { speed: 1 } }
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
viewport = {
|
||||
|
||||
@@ -43,9 +43,9 @@ export type BilayerPlanesProps = PD.Values<BilayerPlanesParams>
|
||||
const BilayerRimsParams = {
|
||||
...Lines.Params,
|
||||
...SharedParams,
|
||||
lineSizeAttenuation: PD.Boolean(true),
|
||||
linesSize: PD.Numeric(0.3, { min: 0.01, max: 50, step: 0.01 }),
|
||||
dashedLines: PD.Boolean(true),
|
||||
lineSizeAttenuation: PD.Boolean(false),
|
||||
linesSize: PD.Numeric(0.5, { min: 0.01, max: 50, step: 0.01 }),
|
||||
dashedLines: PD.Boolean(false),
|
||||
};
|
||||
export type BilayerRimsParams = typeof BilayerRimsParams
|
||||
export type BilayerRimsProps = PD.Values<BilayerRimsParams>
|
||||
|
||||
87
src/extensions/model-export/export.ts
Normal file
87
src/extensions/model-export/export.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
*/
|
||||
|
||||
import { utf8ByteCount, utf8Write } from '../../mol-io/common/utf8';
|
||||
import { to_mmCIF, Unit } from '../../mol-model/structure';
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import { Task } from '../../mol-task';
|
||||
import { getFormattedTime } from '../../mol-util/date';
|
||||
import { download } from '../../mol-util/download';
|
||||
import { zip } from '../../mol-util/zip/zip';
|
||||
|
||||
export async function exportHierarchy(plugin: PluginContext, options?: { format?: 'cif' | 'bcif' }) {
|
||||
try {
|
||||
await plugin.runTask(_exportHierarchy(plugin, options), { useOverlay: true });
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
plugin.log.error(`Model export failed. See console for details.`);
|
||||
}
|
||||
}
|
||||
|
||||
function _exportHierarchy(plugin: PluginContext, options?: { format?: 'cif' | 'bcif' }) {
|
||||
return Task.create('Export', async ctx => {
|
||||
await ctx.update({ message: 'Exporting...', isIndeterminate: true, canAbort: false });
|
||||
|
||||
const format = options?.format ?? 'cif';
|
||||
const { structures } = plugin.managers.structure.hierarchy.current;
|
||||
|
||||
const files: [name: string, data: string | Uint8Array][] = [];
|
||||
const entryMap = new Map<string, number>();
|
||||
|
||||
for (const _s of structures) {
|
||||
const s = _s.transform?.cell.obj?.data ?? _s.cell.obj?.data;
|
||||
if (!s) continue;
|
||||
if (s.models.length > 1) {
|
||||
plugin.log.warn(`[Export] Skipping ${_s.cell.obj?.label}: Multimodel exports not supported.`);
|
||||
continue;
|
||||
}
|
||||
if (s.units.some(u => !Unit.isAtomic(u))) {
|
||||
plugin.log.warn(`[Export] Skipping ${_s.cell.obj?.label}: Non-atomic model exports not supported.`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const name = entryMap.has(s.model.entryId)
|
||||
? `${s.model.entryId}_${entryMap.get(s.model.entryId)! + 1}.${format}`
|
||||
: `${s.model.entryId}.${format}`;
|
||||
entryMap.set(s.model.entryId, (entryMap.get(s.model.entryId) ?? 0) + 1);
|
||||
|
||||
await ctx.update({ message: `Exporting ${s.model.entryId}...`, isIndeterminate: true, canAbort: false });
|
||||
if (s.elementCount > 100000) {
|
||||
// Give UI chance to update, only needed for larger structures.
|
||||
await new Promise(res => setTimeout(res, 50));
|
||||
}
|
||||
|
||||
try {
|
||||
files.push([name, to_mmCIF(s.model.entryId, s, format === 'bcif', { copyAllCategories: true })]);
|
||||
} catch (e) {
|
||||
if (format === 'cif' && s.elementCount > 2000000) {
|
||||
plugin.log.warn(`[Export] The structure might be too big to be exported as Text CIF, consider using the BinaryCIF format instead.`);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
if (files.length === 1) {
|
||||
download(new Blob([files[0][1]]), files[0][0]);
|
||||
} else if (files.length > 1) {
|
||||
const zipData: Record<string, Uint8Array> = {};
|
||||
for (const [fn, data] of files) {
|
||||
if (data instanceof Uint8Array) {
|
||||
zipData[fn] = data;
|
||||
} else {
|
||||
const bytes = new Uint8Array(utf8ByteCount(data));
|
||||
utf8Write(bytes, 0, data);
|
||||
zipData[fn] = bytes;
|
||||
}
|
||||
}
|
||||
await ctx.update({ message: `Compressing Data...`, isIndeterminate: true, canAbort: false });
|
||||
const buffer = await zip(ctx, zipData);
|
||||
download(new Blob([new Uint8Array(buffer, 0, buffer.byteLength)]), `structures_${getFormattedTime()}.zip`);
|
||||
}
|
||||
|
||||
plugin.log.info(`[Export] Done.`);
|
||||
});
|
||||
}
|
||||
30
src/extensions/model-export/index.ts
Normal file
30
src/extensions/model-export/index.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
*/
|
||||
|
||||
import { PluginBehavior } from '../../mol-plugin/behavior/behavior';
|
||||
import { ModelExportUI } from './ui';
|
||||
|
||||
export const ModelExport = PluginBehavior.create<{}>({
|
||||
name: 'extension-model-export',
|
||||
category: 'misc',
|
||||
display: {
|
||||
name: 'Model Export'
|
||||
},
|
||||
ctor: class extends PluginBehavior.Handler<{}> {
|
||||
register(): void {
|
||||
this.ctx.customStructureControls.set('model-export', ModelExportUI as any);
|
||||
}
|
||||
|
||||
update() {
|
||||
return false;
|
||||
}
|
||||
|
||||
unregister() {
|
||||
this.ctx.customStructureControls.delete('model-export');
|
||||
}
|
||||
},
|
||||
params: () => ({})
|
||||
});
|
||||
69
src/extensions/model-export/ui.tsx
Normal file
69
src/extensions/model-export/ui.tsx
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
*/
|
||||
|
||||
import { useState } from 'react';
|
||||
import { CollapsableControls, CollapsableState } from '../../mol-plugin-ui/base';
|
||||
import { Button } from '../../mol-plugin-ui/controls/common';
|
||||
import { GetAppSvg } from '../../mol-plugin-ui/controls/icons';
|
||||
import { ParameterControls } from '../../mol-plugin-ui/controls/parameters';
|
||||
import { useBehavior } from '../../mol-plugin-ui/hooks/use-behavior';
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { exportHierarchy } from './export';
|
||||
|
||||
export class ModelExportUI extends CollapsableControls<{}, {}> {
|
||||
protected defaultState(): CollapsableState {
|
||||
return {
|
||||
header: 'Export Models',
|
||||
isCollapsed: true,
|
||||
brand: { accent: 'cyan', svg: GetAppSvg }
|
||||
};
|
||||
}
|
||||
protected renderControls(): JSX.Element | null {
|
||||
return <ExportControls plugin={this.plugin} />;
|
||||
}
|
||||
}
|
||||
|
||||
const Params = {
|
||||
format: PD.Select<'cif' | 'bcif'>('cif', [['cif', 'mmCIF'], ['bcif', 'Binary mmCIF']])
|
||||
};
|
||||
const DefaultParams = PD.getDefaultValues(Params);
|
||||
|
||||
function ExportControls({ plugin }: { plugin: PluginContext }) {
|
||||
const [params, setParams] = useState(DefaultParams);
|
||||
const [exporting, setExporting] = useState(false);
|
||||
useBehavior(plugin.managers.structure.hierarchy.behaviors.selection); // triggers UI update
|
||||
const isBusy = useBehavior(plugin.behaviors.state.isBusy);
|
||||
const hierarchy = plugin.managers.structure.hierarchy.current;
|
||||
|
||||
let label: string = 'Nothing to Export';
|
||||
if (hierarchy.structures.length === 1) {
|
||||
label = 'Export';
|
||||
} if (hierarchy.structures.length > 1) {
|
||||
label = 'Export (as ZIP)';
|
||||
}
|
||||
|
||||
const onExport = async () => {
|
||||
setExporting(true);
|
||||
try {
|
||||
await exportHierarchy(plugin, { format: params.format });
|
||||
} finally {
|
||||
setExporting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return <>
|
||||
<ParameterControls params={Params} values={params} onChangeValues={setParams} isDisabled={isBusy || exporting} />
|
||||
<Button
|
||||
onClick={onExport}
|
||||
style={{ marginTop: 1 }}
|
||||
disabled={isBusy || hierarchy.structures.length === 0 || exporting}
|
||||
commit={hierarchy.structures.length ? 'on' : 'off'}
|
||||
>
|
||||
{label}
|
||||
</Button>
|
||||
</>;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ export async function encodeMp4Animation<A extends PluginStateAnimation>(plugin:
|
||||
await plugin.managers.animation.play(params.animation.definition, params.animation.params);
|
||||
stoppedAnimation = false;
|
||||
for (let i = 0; i <= N; i++) {
|
||||
await loop.tick(i * dt, { isSynchronous: true, manualDraw: true });
|
||||
await loop.tick(i * dt, { isSynchronous: true, animation: { currentFrame: i, frameCount: N }, manualDraw: true });
|
||||
|
||||
const image = params.pass.getImageData(width, height, normalizedViewport);
|
||||
encoder.addFrameRgba(image.data);
|
||||
|
||||
@@ -4,7 +4,7 @@ export type InputMaybe<T> = Maybe<T>;
|
||||
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
||||
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
|
||||
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
|
||||
// Generated on 2021-11-25T14:34:23-08:00
|
||||
// Generated on 2022-01-15T19:52:34-08:00
|
||||
|
||||
/** All built-in and custom scalars, mapped to their actual values */
|
||||
export type Scalars = {
|
||||
@@ -11113,11 +11113,11 @@ export type RcsbUniprotAlignments = {
|
||||
|
||||
export type RcsbUniprotAlignmentsCoreEntityAlignments = {
|
||||
/** Aligned region */
|
||||
readonly aligned_regions?: Maybe<ReadonlyArray<Maybe<CoreEntityAlignmentsAlignedRegions>>>;
|
||||
readonly aligned_regions: ReadonlyArray<Maybe<CoreEntityAlignmentsAlignedRegions>>;
|
||||
/** core_entity identifiers */
|
||||
readonly core_entity_identifiers?: Maybe<CoreEntityAlignmentsCoreEntityIdentifiers>;
|
||||
/** Alignment scores */
|
||||
readonly scores?: Maybe<CoreEntityAlignmentsScores>;
|
||||
readonly scores: CoreEntityAlignmentsScores;
|
||||
};
|
||||
|
||||
export type RcsbUniprotAnnotation = {
|
||||
|
||||
@@ -404,7 +404,7 @@ namespace Canvas3D {
|
||||
|
||||
const ctx = { renderer, camera: cam, scene, helper };
|
||||
if (MultiSamplePass.isEnabled(p.multiSample)) {
|
||||
const forceOn = !cameraChanged && allowMulti && !controls.props.spin;
|
||||
const forceOn = !cameraChanged && allowMulti && !controls.isAnimating;
|
||||
multiSampleHelper.render(ctx, p, true, forceOn);
|
||||
} else {
|
||||
passes.draw.render(ctx, p, true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
@@ -13,7 +13,7 @@ import { Viewport } from '../camera/util';
|
||||
import { InputObserver, DragInput, WheelInput, PinchInput, ButtonsType, ModifiersKeys, GestureInput } from '../../mol-util/input/input-observer';
|
||||
import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { Camera } from '../camera';
|
||||
import { absMax } from '../../mol-math/misc';
|
||||
import { absMax, degToRad } from '../../mol-math/misc';
|
||||
import { Binding } from '../../mol-util/binding';
|
||||
|
||||
const B = ButtonsType;
|
||||
@@ -40,8 +40,16 @@ export const TrackballControlsParams = {
|
||||
zoomSpeed: PD.Numeric(7.0, { min: 1, max: 15, step: 1 }),
|
||||
panSpeed: PD.Numeric(1.0, { min: 0.1, max: 5, step: 0.1 }),
|
||||
|
||||
spin: PD.Boolean(false, { description: 'Spin the 3D scene around the x-axis in view space' }),
|
||||
spinSpeed: PD.Numeric(1, { min: -20, max: 20, step: 1 }),
|
||||
animate: PD.MappedStatic('off', {
|
||||
off: PD.EmptyGroup(),
|
||||
spin: PD.Group({
|
||||
speed: PD.Numeric(1, { min: -20, max: 20, step: 1 }),
|
||||
}, { description: 'Spin the 3D scene around the x-axis in view space' }),
|
||||
rock: PD.Group({
|
||||
speed: PD.Numeric(0.3, { min: -5, max: 5, step: 0.1 }),
|
||||
angle: PD.Numeric(10, { min: 0, max: 90, step: 1 }, { description: 'How many degrees to rotate in each direction.' }),
|
||||
}, { description: 'Rock the 3D scene around the x-axis in view space' })
|
||||
}),
|
||||
|
||||
staticMoving: PD.Boolean(true, { isHidden: true }),
|
||||
dynamicDampingFactor: PD.Numeric(0.2, {}, { isHidden: true }),
|
||||
@@ -72,7 +80,8 @@ export type TrackballControlsProps = PD.Values<typeof TrackballControlsParams>
|
||||
|
||||
export { TrackballControls };
|
||||
interface TrackballControls {
|
||||
viewport: Viewport
|
||||
readonly viewport: Viewport
|
||||
readonly isAnimating: boolean
|
||||
|
||||
readonly props: Readonly<TrackballControlsProps>
|
||||
setProps: (props: Partial<TrackballControlsProps>) => void
|
||||
@@ -144,6 +153,11 @@ namespace TrackballControls {
|
||||
);
|
||||
}
|
||||
|
||||
function getRotateFactor() {
|
||||
const aspectRatio = input.width / input.height;
|
||||
return p.rotateSpeed * input.pixelRatio * aspectRatio;
|
||||
}
|
||||
|
||||
const rotAxis = Vec3();
|
||||
const rotQuat = Quat();
|
||||
const rotEyeDir = Vec3();
|
||||
@@ -156,8 +170,7 @@ namespace TrackballControls {
|
||||
const dy = _rotCurr[1] - _rotPrev[1];
|
||||
Vec3.set(rotMoveDir, dx, dy, 0);
|
||||
|
||||
const aspectRatio = input.width / input.height;
|
||||
const angle = Vec3.magnitude(rotMoveDir) * p.rotateSpeed * input.pixelRatio * aspectRatio;
|
||||
const angle = Vec3.magnitude(rotMoveDir) * getRotateFactor();
|
||||
|
||||
if (angle) {
|
||||
Vec3.sub(_eye, camera.position, camera.target);
|
||||
@@ -306,7 +319,10 @@ namespace TrackballControls {
|
||||
/** Update the object's position, direction and up vectors */
|
||||
function update(t: number) {
|
||||
if (lastUpdated === t) return;
|
||||
if (p.spin && lastUpdated > 0) spin(t - lastUpdated);
|
||||
if (lastUpdated > 0) {
|
||||
if (p.animate.name === 'spin') spin(t - lastUpdated);
|
||||
else if (p.animate.name === 'rock') rock(t - lastUpdated);
|
||||
}
|
||||
|
||||
Vec3.sub(_eye, camera.position, camera.target);
|
||||
|
||||
@@ -345,6 +361,7 @@ namespace TrackballControls {
|
||||
if (!isStart && !_isInteracting) return;
|
||||
|
||||
_isInteracting = true;
|
||||
resetRock(); // start rocking from the center after interactions
|
||||
|
||||
const dragRotate = Binding.match(p.bindings.dragRotate, buttons, modifiers);
|
||||
const dragRotateZ = Binding.match(p.bindings.dragRotateZ, buttons, modifiers);
|
||||
@@ -434,11 +451,34 @@ namespace TrackballControls {
|
||||
|
||||
const _spinSpeed = Vec2.create(0.005, 0);
|
||||
function spin(deltaT: number) {
|
||||
if (p.spinSpeed === 0) return;
|
||||
if (p.animate.name !== 'spin' || p.animate.params.speed === 0 || _isInteracting) return;
|
||||
|
||||
const frameSpeed = (p.spinSpeed || 0) / 1000;
|
||||
const frameSpeed = p.animate.params.speed / 1000;
|
||||
_spinSpeed[0] = 60 * Math.min(Math.abs(deltaT), 1000 / 8) / 1000 * frameSpeed;
|
||||
if (!_isInteracting) Vec2.add(_rotCurr, _rotPrev, _spinSpeed);
|
||||
Vec2.add(_rotCurr, _rotPrev, _spinSpeed);
|
||||
}
|
||||
|
||||
let _rockPhase = 0;
|
||||
const _rockSpeed = Vec2.create(0.005, 0);
|
||||
function rock(deltaT: number) {
|
||||
if (p.animate.name !== 'rock' || p.animate.params.speed === 0 || _isInteracting) return;
|
||||
|
||||
const dt = deltaT / 1000 * p.animate.params.speed;
|
||||
const maxAngle = degToRad(p.animate.params.angle) / getRotateFactor();
|
||||
const angleA = Math.sin(_rockPhase * Math.PI * 2) * maxAngle;
|
||||
const angleB = Math.sin((_rockPhase + dt) * Math.PI * 2) * maxAngle;
|
||||
|
||||
_rockSpeed[0] = angleB - angleA;
|
||||
Vec2.add(_rotCurr, _rotPrev, _rockSpeed);
|
||||
|
||||
_rockPhase += dt;
|
||||
if (_rockPhase >= 1) {
|
||||
_rockPhase = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function resetRock() {
|
||||
_rockPhase = 0;
|
||||
}
|
||||
|
||||
function start(t: number) {
|
||||
@@ -448,9 +488,13 @@ namespace TrackballControls {
|
||||
|
||||
return {
|
||||
viewport,
|
||||
get isAnimating() { return p.animate.name !== 'off'; },
|
||||
|
||||
get props() { return p as Readonly<TrackballControlsProps>; },
|
||||
setProps: (props: Partial<TrackballControlsProps>) => {
|
||||
if (props.animate?.name === 'rock' && p.animate.name !== 'rock') {
|
||||
resetRock(); // start rocking from the center
|
||||
}
|
||||
Object.assign(p, props);
|
||||
},
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ export class Canvas3dInteractionHelper {
|
||||
const xyChanged = this.startX !== this.endX || this.startY !== this.endY;
|
||||
|
||||
if (e === InputEvent.Drag) {
|
||||
if (xyChanged && !Representation.Loci.isEmpty(this.prevLoci)) {
|
||||
if (xyChanged && !this.outsideViewport(this.startX, this.startY)) {
|
||||
this.events.drag.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, pageStart: Vec2.create(this.startX, this.startY), pageEnd: Vec2.create(this.endX, this.endY) });
|
||||
|
||||
this.startX = this.endX;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
* @author Áron Samuel Kovács <aron.kovacs@mail.muni.cz>
|
||||
@@ -310,12 +310,12 @@ export class DrawPass {
|
||||
const markingDepthTest = props.marking.ghostEdgeStrength < 1;
|
||||
if (markingDepthTest) {
|
||||
this.marking.depthTarget.bind();
|
||||
renderer.clear(false);
|
||||
renderer.clear(false, true);
|
||||
renderer.renderMarkingDepth(scene.primitives, camera, null);
|
||||
}
|
||||
|
||||
this.marking.maskTarget.bind();
|
||||
renderer.clear(false);
|
||||
renderer.clear(false, true);
|
||||
renderer.renderMarkingMask(scene.primitives, camera, markingDepthTest ? this.marking.depthTarget.texture : null);
|
||||
|
||||
this.marking.update(props.marking);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -53,7 +53,7 @@ interface Renderer {
|
||||
readonly stats: RendererStats
|
||||
readonly props: Readonly<RendererProps>
|
||||
|
||||
clear: (toBackgroundColor: boolean) => void
|
||||
clear: (toBackgroundColor: boolean, ignoreTransparentBackground?: boolean) => void
|
||||
clearDepth: () => void
|
||||
update: (camera: ICamera) => void
|
||||
|
||||
@@ -523,13 +523,13 @@ namespace Renderer {
|
||||
};
|
||||
|
||||
return {
|
||||
clear: (toBackgroundColor: boolean) => {
|
||||
clear: (toBackgroundColor: boolean, ignoreTransparentBackground?: boolean) => {
|
||||
state.enable(gl.SCISSOR_TEST);
|
||||
state.enable(gl.DEPTH_TEST);
|
||||
state.colorMask(true, true, true, true);
|
||||
state.depthMask(true);
|
||||
|
||||
if (transparentBackground) {
|
||||
if (transparentBackground && !ignoreTransparentBackground) {
|
||||
state.clearColor(0, 0, 0, 0);
|
||||
} else if (toBackgroundColor) {
|
||||
state.clearColor(bgColor[0], bgColor[1], bgColor[2], 1);
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
/**
|
||||
* Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
* @author Panagiotis Tourlas <panagiot_tourlov@hotmail.com>
|
||||
*/
|
||||
|
||||
import { parseMol } from '../mol/parser';
|
||||
import { parseMol, formalChargeMapper } from '../mol/parser';
|
||||
|
||||
const MolString = `2244
|
||||
-OEChem-04072009073D
|
||||
@@ -49,6 +56,48 @@ const MolString = `2244
|
||||
13 20 1 0 0 0 0
|
||||
M END`;
|
||||
|
||||
const MolStringWithAtomBlockCharge = `
|
||||
Ketcher 1 72215442D 1 1.00000 0.00000 0
|
||||
|
||||
4 3 0 0 0 0 999 V2000
|
||||
0.0000 0.0000 0.0000 C 0 1 0 0 0 0 0 0 0 0 0 0
|
||||
0.8660 0.5000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-0.8660 0.5000 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0.0000 -1.0000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 4 2 0 0 0 0
|
||||
3 1 1 0 0 0 0
|
||||
2 1 1 0 0 0 0
|
||||
M END`;
|
||||
|
||||
const MolStringWithPropertyBlockCharge = `
|
||||
Ketcher 1 72215442D 1 1.00000 0.00000 0
|
||||
|
||||
4 3 0 0 0 0 999 V2000
|
||||
0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0.8660 0.5000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-0.8660 0.5000 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0.0000 -1.0000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 4 2 0 0 0 0
|
||||
3 1 1 0 0 0 0
|
||||
2 1 1 0 0 0 0
|
||||
M CHG 3 2 -1 3 1 4 1
|
||||
M END`;
|
||||
|
||||
const MolStringWithMultipleChargeLines = `
|
||||
Ketcher 1 72215442D 1 1.00000 0.00000 0
|
||||
|
||||
4 3 0 0 0 0 999 V2000
|
||||
0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0.8660 0.5000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-0.8660 0.5000 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0.0000 -1.0000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 4 2 0 0 0 0
|
||||
3 1 1 0 0 0 0
|
||||
2 1 1 0 0 0 0
|
||||
M CHG 1 2 -1
|
||||
M CHG 2 3 1 4 1
|
||||
M END`;
|
||||
|
||||
describe('mol reader', () => {
|
||||
it('basic', async () => {
|
||||
const parsed = await parseMol(MolString).run();
|
||||
@@ -70,4 +119,63 @@ describe('mol reader', () => {
|
||||
expect(bonds.atomIdxB.value(20)).toBe(20);
|
||||
expect(bonds.order.value(20)).toBe(1);
|
||||
});
|
||||
it('property block charges', async () => {
|
||||
const parsed = await parseMol(MolStringWithPropertyBlockCharge).run();
|
||||
if (parsed.isError) {
|
||||
throw new Error(parsed.message);
|
||||
}
|
||||
const { formalCharges } = parsed.result;
|
||||
|
||||
expect(formalCharges.atomIdx.rowCount).toBe(3);
|
||||
expect(formalCharges.charge.rowCount).toBe(3);
|
||||
|
||||
expect(formalCharges.atomIdx.value(0)).toBe(2);
|
||||
expect(formalCharges.atomIdx.value(1)).toBe(3);
|
||||
|
||||
expect(formalCharges.charge.value(0)).toBe(-1);
|
||||
expect(formalCharges.charge.value(1)).toBe(1);
|
||||
});
|
||||
it('multiple charge lines', async () => {
|
||||
const parsed = await parseMol(MolStringWithMultipleChargeLines).run();
|
||||
if (parsed.isError) {
|
||||
throw new Error(parsed.message);
|
||||
}
|
||||
const { formalCharges } = parsed.result;
|
||||
|
||||
expect(formalCharges.atomIdx.rowCount).toBe(3);
|
||||
expect(formalCharges.charge.rowCount).toBe(3);
|
||||
|
||||
expect(formalCharges.atomIdx.value(0)).toBe(2);
|
||||
expect(formalCharges.atomIdx.value(1)).toBe(3);
|
||||
|
||||
expect(formalCharges.charge.value(0)).toBe(-1);
|
||||
expect(formalCharges.charge.value(1)).toBe(1);
|
||||
});
|
||||
|
||||
it('atom block charge mapping', async () => {
|
||||
expect(formalChargeMapper(7)).toBe(-3);
|
||||
expect(formalChargeMapper(6)).toBe(-2);
|
||||
expect(formalChargeMapper(5)).toBe(-1);
|
||||
expect(formalChargeMapper(0)).toBe(0);
|
||||
expect(formalChargeMapper(3)).toBe(1);
|
||||
expect(formalChargeMapper(2)).toBe(2);
|
||||
expect(formalChargeMapper(1)).toBe(3);
|
||||
expect(formalChargeMapper(4)).toBe(0);
|
||||
});
|
||||
it('atom block charges', async () => {
|
||||
const parsed = await parseMol(MolStringWithAtomBlockCharge).run();
|
||||
if (parsed.isError) {
|
||||
throw new Error(parsed.message);
|
||||
}
|
||||
const { atoms, formalCharges } = parsed.result;
|
||||
|
||||
/* No property block charges */
|
||||
expect(formalCharges.atomIdx.rowCount).toBe(0);
|
||||
expect(formalCharges.charge.rowCount).toBe(0);
|
||||
|
||||
expect(atoms.formal_charge.value(0)).toBe(1);
|
||||
expect(atoms.formal_charge.value(1)).toBe(0);
|
||||
expect(atoms.formal_charge.value(2)).toBe(0);
|
||||
expect(atoms.formal_charge.value(3)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Panagiotis Tourlas <panagiot_tourlov@hotmail.com>
|
||||
*/
|
||||
|
||||
import { parseSdf } from '../sdf/parser';
|
||||
|
||||
@@ -458,6 +465,38 @@ describe('sdf reader', () => {
|
||||
expect(compound3.dataItems.data.value(21)).toBe('2\n5\n10');
|
||||
});
|
||||
|
||||
it('charge parsing in V2000', async () => {
|
||||
const parsed = await parseSdf(SdfString).run();
|
||||
if (parsed.isError) {
|
||||
throw new Error(parsed.message);
|
||||
}
|
||||
const compound1 = parsed.result.compounds[0];
|
||||
const compound2 = parsed.result.compounds[1];
|
||||
const compound3 = parsed.result.compounds[2];
|
||||
|
||||
const formalCharges1 = {
|
||||
atomIdx: compound1.molFile.formalCharges.atomIdx,
|
||||
charge: compound1.molFile.formalCharges.charge
|
||||
};
|
||||
const formalCharges2 = {
|
||||
atomIdx: compound2.molFile.formalCharges.atomIdx,
|
||||
charge: compound2.molFile.formalCharges.charge
|
||||
};
|
||||
const formalCharges3 = {
|
||||
atomIdx: compound3.molFile.formalCharges.atomIdx,
|
||||
charge: compound3.molFile.formalCharges.charge
|
||||
};
|
||||
|
||||
expect(formalCharges1.atomIdx.rowCount).toBe(3);
|
||||
expect(formalCharges2.atomIdx.rowCount).toBe(3);
|
||||
expect(formalCharges3.atomIdx.rowCount).toBe(0);
|
||||
|
||||
expect(formalCharges1.charge.rowCount === formalCharges1.atomIdx.rowCount).toBe(true);
|
||||
expect(formalCharges2.charge.rowCount === formalCharges2.atomIdx.rowCount).toBe(true);
|
||||
expect(formalCharges3.charge.rowCount === formalCharges3.atomIdx.rowCount).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
it('v3000', async () => {
|
||||
const parsed = await parseSdf(V3000SdfString).run();
|
||||
if (parsed.isError) {
|
||||
@@ -486,6 +525,11 @@ describe('sdf reader', () => {
|
||||
expect(compound1.molFile.bonds.atomIdxB.value(10)).toBe(9);
|
||||
expect(compound1.molFile.bonds.order.value(10)).toBe(2);
|
||||
|
||||
expect(compound1.molFile.formalCharges.atomIdx.rowCount).toBe(13);
|
||||
for (let i = 0; i < compound1.molFile.atoms.count; i++) {
|
||||
expect(compound1.molFile.formalCharges.charge.value(i)).toBe(0);
|
||||
}
|
||||
|
||||
expect(compound1.dataItems.dataHeader.rowCount).toBe(2);
|
||||
expect(compound1.dataItems.data.rowCount).toBe(2);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) 2017-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* Code-generated 'BIRD' schema file. Dictionary versions: mmCIF 5.352, IHM 1.17, CARB draft.
|
||||
* Code-generated 'BIRD' schema file. Dictionary versions: mmCIF 5.354, IHM 1.17, MA 1.3.3.
|
||||
*
|
||||
* @author molstar/ciftools package
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) 2017-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* Code-generated 'CCD' schema file. Dictionary versions: mmCIF 5.352, IHM 1.17, CARB draft.
|
||||
* Code-generated 'CCD' schema file. Dictionary versions: mmCIF 5.354, IHM 1.17, MA 1.3.3.
|
||||
*
|
||||
* @author molstar/ciftools package
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) 2017-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* Code-generated 'mmCIF' schema file. Dictionary versions: mmCIF 5.353, IHM 1.17, MA 1.3.3.
|
||||
* Code-generated 'mmCIF' schema file. Dictionary versions: mmCIF 5.354, IHM 1.17, MA 1.3.3.
|
||||
*
|
||||
* @author molstar/ciftools package
|
||||
*/
|
||||
@@ -682,7 +682,7 @@ export const mmCIF_Schema = {
|
||||
/**
|
||||
* An abbreviation that identifies the database.
|
||||
*/
|
||||
database_id: Aliased<'CAS' | 'CSD' | 'EMDB' | 'ICSD' | 'MDF' | 'NDB' | 'NBS' | 'PDB' | 'PDF' | 'RCSB' | 'EBI' | 'PDBE' | 'BMRB' | 'WWPDB' | 'PDB_ACC'>(str),
|
||||
database_id: Aliased<'AFDB' | 'CAS' | 'CSD' | 'EMDB' | 'ICSD' | 'MA' | 'MDF' | 'MODBASE' | 'NDB' | 'NBS' | 'PDB' | 'PDF' | 'RCSB' | 'SMR' | 'EBI' | 'PDBE' | 'BMRB' | 'WWPDB' | 'PDB_ACC'>(str),
|
||||
/**
|
||||
* The code assigned by the database identified in
|
||||
* _database_2.database_id.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Panagiotis Tourlas <panagiot_tourlov@hotmail.com>
|
||||
*/
|
||||
|
||||
import { Column } from '../../../mol-data/db';
|
||||
@@ -10,6 +11,7 @@ import { TokenColumnProvider as TokenColumn } from '../common/text/column/token'
|
||||
import { TokenBuilder, Tokenizer } from '../common/text/tokenizer';
|
||||
import { ReaderResult as Result } from '../result';
|
||||
|
||||
|
||||
/** Subset of the MolFile V2000 format */
|
||||
export interface MolFile {
|
||||
readonly title: string,
|
||||
@@ -20,7 +22,8 @@ export interface MolFile {
|
||||
readonly x: Column<number>,
|
||||
readonly y: Column<number>,
|
||||
readonly z: Column<number>,
|
||||
readonly type_symbol: Column<string>
|
||||
readonly type_symbol: Column<string>,
|
||||
readonly formal_charge: Column<number>
|
||||
},
|
||||
readonly bonds: {
|
||||
readonly count: number
|
||||
@@ -28,6 +31,57 @@ export interface MolFile {
|
||||
readonly atomIdxB: Column<number>,
|
||||
readonly order: Column<number>
|
||||
}
|
||||
readonly formalCharges: {
|
||||
readonly atomIdx: Column<number>;
|
||||
readonly charge: Column<number>;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
The atom lines in a .mol file have the following structure:
|
||||
|
||||
xxxxx.xxxxyyyyy.yyyyzzzzz.zzzz aaaddcccssshhhbbbvvvHHHrrriiimmmnnneee
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Below is a breakdown of each component and its start/end indices:
|
||||
|
||||
xxxxx.xxxx (X COORDINATE, 1-10)
|
||||
yyyyy.yyyy (Y COORDINATE, 10-20)
|
||||
zzzzz.zzzz (Z COORDINATE, 20-30)
|
||||
_ (30 IS EMPTY)
|
||||
aaa (ATOM SYMBOL, 31-34)
|
||||
dd (MASS DIFF, 34-36)
|
||||
ccc (FORMAL CHARGE, 36-39)
|
||||
sss (ATOM STEREO PARITY, 39-42)
|
||||
hhh (HYDROGEN COUNT+1, 42-45)
|
||||
bbb (STEREO CARE BOX, 45-48)
|
||||
vvv (VALENCE, 48-51)
|
||||
HHH (H0 DESIGNATOR, 51-54)
|
||||
rrr (UNUSED, 54-57)
|
||||
iii (UNUSED, 57-60)
|
||||
mmm (ATOM-ATOM MAPPING NUMBER, 60-63)
|
||||
nnn (INVERSION/RETENTION FLAG, 63-66)
|
||||
eee (EXACT CHANGE FLAG, 66-69)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param key - The value found at the atom block.
|
||||
* @returns The actual formal charge based on the mapping.
|
||||
*/
|
||||
export function formalChargeMapper(key: number) {
|
||||
switch (key) {
|
||||
case 7: return -3;
|
||||
case 6: return -2;
|
||||
case 5: return -1;
|
||||
case 0: return 0;
|
||||
case 3: return 1;
|
||||
case 2: return 2;
|
||||
case 1: return 3;
|
||||
case 4: return 0;
|
||||
default:
|
||||
console.error(`Value ${key} is outside the 0-7 range, defaulting to 0.`);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export function handleAtoms(tokenizer: Tokenizer, count: number): MolFile['atoms'] {
|
||||
@@ -35,6 +89,7 @@ export function handleAtoms(tokenizer: Tokenizer, count: number): MolFile['atoms
|
||||
const y = TokenBuilder.create(tokenizer.data, count * 2);
|
||||
const z = TokenBuilder.create(tokenizer.data, count * 2);
|
||||
const type_symbol = TokenBuilder.create(tokenizer.data, count * 2);
|
||||
const formal_charge = TokenBuilder.create(tokenizer.data, count * 2);
|
||||
|
||||
for (let i = 0; i < count; ++i) {
|
||||
Tokenizer.markLine(tokenizer);
|
||||
@@ -47,6 +102,8 @@ export function handleAtoms(tokenizer: Tokenizer, count: number): MolFile['atoms
|
||||
TokenBuilder.addUnchecked(z, tokenizer.tokenStart, tokenizer.tokenEnd);
|
||||
Tokenizer.trim(tokenizer, s + 31, s + 34);
|
||||
TokenBuilder.addUnchecked(type_symbol, tokenizer.tokenStart, tokenizer.tokenEnd);
|
||||
Tokenizer.trim(tokenizer, s + 36, s + 39);
|
||||
TokenBuilder.addUnchecked(formal_charge, tokenizer.tokenStart, tokenizer.tokenEnd);
|
||||
tokenizer.position = position;
|
||||
}
|
||||
|
||||
@@ -55,7 +112,8 @@ export function handleAtoms(tokenizer: Tokenizer, count: number): MolFile['atoms
|
||||
x: TokenColumn(x)(Column.Schema.float),
|
||||
y: TokenColumn(y)(Column.Schema.float),
|
||||
z: TokenColumn(z)(Column.Schema.float),
|
||||
type_symbol: TokenColumn(type_symbol)(Column.Schema.str)
|
||||
type_symbol: TokenColumn(type_symbol)(Column.Schema.str),
|
||||
formal_charge: TokenColumn(formal_charge)(Column.Schema.int)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -84,6 +142,76 @@ export function handleBonds(tokenizer: Tokenizer, count: number): MolFile['bonds
|
||||
};
|
||||
}
|
||||
|
||||
interface FormalChargesRawData {
|
||||
atomIdx: Array<number>;
|
||||
charge: Array<number>;
|
||||
}
|
||||
export function handleFormalCharges(tokenizer: Tokenizer, lineStart: number, formalCharges: FormalChargesRawData) {
|
||||
|
||||
Tokenizer.trim(tokenizer, lineStart + 6, lineStart + 9);
|
||||
const numOfCharges = parseInt(Tokenizer.getTokenString(tokenizer));
|
||||
for (let i = 0; i < numOfCharges; ++i) {
|
||||
/*
|
||||
M CHG 3 1 -1 2 0 2 -1
|
||||
| | | | |
|
||||
| | | | |__charge2 (etc.)
|
||||
| | | |
|
||||
| | | |__atomIdx2
|
||||
| | |
|
||||
| | |__charge1
|
||||
| |
|
||||
| |__atomIdx1 (cursor at position 12)
|
||||
|
|
||||
|___numOfCharges
|
||||
*/
|
||||
const offset = 9 + (i * 8);
|
||||
|
||||
Tokenizer.trim(tokenizer, lineStart + offset, lineStart + offset + 4);
|
||||
const _atomIdx = Tokenizer.getTokenString(tokenizer);
|
||||
formalCharges.atomIdx.push(+_atomIdx);
|
||||
Tokenizer.trim(tokenizer, lineStart + offset + 4, lineStart + offset + 8);
|
||||
const _charge = Tokenizer.getTokenString(tokenizer);
|
||||
formalCharges.charge.push(+_charge);
|
||||
}
|
||||
/* Once the line is read, move to the next one. */
|
||||
Tokenizer.eatLine(tokenizer);
|
||||
}
|
||||
|
||||
/** Call an appropriate handler based on the property type.
|
||||
* (For now it only calls the formal charge handler, additional handlers can
|
||||
* be added for other properties.)
|
||||
*/
|
||||
export function handlePropertiesBlock(tokenizer: Tokenizer): MolFile['formalCharges'] {
|
||||
|
||||
const _atomIdx: Array<number> = [];
|
||||
const _charge: Array<number> = [];
|
||||
const _formalCharges: FormalChargesRawData = { atomIdx: _atomIdx, charge: _charge };
|
||||
|
||||
while (tokenizer.position < tokenizer.length) {
|
||||
const { position: s } = tokenizer;
|
||||
|
||||
Tokenizer.trim(tokenizer, s + 3, s + 6);
|
||||
const propertyType = Tokenizer.getTokenString(tokenizer);
|
||||
|
||||
if (propertyType === 'END') break;
|
||||
Tokenizer.eatLine(tokenizer);
|
||||
|
||||
switch (propertyType) {
|
||||
case 'CHG':
|
||||
handleFormalCharges(tokenizer, s, _formalCharges);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const formalCharges: MolFile['formalCharges'] = {
|
||||
atomIdx: Column.ofIntArray(_formalCharges.atomIdx),
|
||||
charge: Column.ofIntArray(_formalCharges.charge)
|
||||
};
|
||||
return formalCharges;
|
||||
}
|
||||
|
||||
function parseInternal(data: string): Result<MolFile> {
|
||||
const tokenizer = Tokenizer(data);
|
||||
|
||||
@@ -98,12 +226,15 @@ function parseInternal(data: string): Result<MolFile> {
|
||||
const atoms = handleAtoms(tokenizer, atomCount);
|
||||
const bonds = handleBonds(tokenizer, bondCount);
|
||||
|
||||
const formalCharges = handlePropertiesBlock(tokenizer);
|
||||
|
||||
const result: MolFile = {
|
||||
title,
|
||||
program,
|
||||
comment,
|
||||
atoms,
|
||||
bonds
|
||||
bonds,
|
||||
formalCharges,
|
||||
};
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) 2021-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Jason Pattle <jpattle@exscientia.co.uk>
|
||||
* @author Panagiotis Tourlas <panagiot_tourlov@hotmail.com>
|
||||
*/
|
||||
|
||||
import { Column } from '../../../mol-data/db';
|
||||
import { MolFile } from '../mol/parser';
|
||||
import { Tokenizer, TokenBuilder, Tokens } from '../common/text/tokenizer';
|
||||
@@ -61,6 +68,9 @@ export function handleAtomsV3(
|
||||
y: TokenColumn(y)(Column.Schema.float),
|
||||
z: TokenColumn(z)(Column.Schema.float),
|
||||
type_symbol: TokenColumn(type_symbol)(Column.Schema.str),
|
||||
/* No support for formal charge parsing in V3000 molfiles at the moment,
|
||||
so all charges default to 0.*/
|
||||
formal_charge: Column.ofConst(0, atomCount, Column.Schema.int)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2020-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
* @author Jason Pattle <jpattle@exscientia.co.uk>
|
||||
* @author Panagiotis Tourlas <panagiot_tourlov@hotmail.com>
|
||||
*/
|
||||
|
||||
import { Column } from '../../../mol-data/db';
|
||||
import { MolFile, handleAtoms, handleBonds } from '../mol/parser';
|
||||
import { MolFile, handleAtoms, handleBonds, handlePropertiesBlock } from '../mol/parser';
|
||||
import { Task } from '../../../mol-task';
|
||||
import { ReaderResult as Result } from '../result';
|
||||
import { Tokenizer, TokenBuilder } from '../common/text/tokenizer';
|
||||
@@ -29,6 +31,7 @@ export interface SdfFile {
|
||||
|
||||
|
||||
const delimiter = '$$$$';
|
||||
|
||||
function handleDataItems(tokenizer: Tokenizer): { dataHeader: Column<string>, data: Column<string> } {
|
||||
const dataHeader = TokenBuilder.create(tokenizer.data, 32);
|
||||
const data = TokenBuilder.create(tokenizer.data, 32);
|
||||
@@ -93,12 +96,20 @@ function handleMolFile(tokenizer: Tokenizer) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* No support for formal charge parsing in V3000 molfiles at the moment,
|
||||
so all charges default to 0.*/
|
||||
const nullFormalCharges: MolFile['formalCharges'] = {
|
||||
atomIdx: Column.ofConst(0, atomCount, Column.Schema.int),
|
||||
charge: Column.ofConst(0, atomCount, Column.Schema.int)
|
||||
};
|
||||
|
||||
const atoms = molIsV3 ? handleAtomsV3(tokenizer, atomCount) : handleAtoms(tokenizer, atomCount);
|
||||
const bonds = molIsV3 ? handleBondsV3(tokenizer, bondCount) : handleBonds(tokenizer, bondCount);
|
||||
const formalCharges = molIsV3 ? nullFormalCharges : handlePropertiesBlock(tokenizer);
|
||||
const dataItems = handleDataItems(tokenizer);
|
||||
|
||||
return {
|
||||
molFile: { title, program, comment, atoms, bonds },
|
||||
molFile: { title, program, comment, atoms, bonds, formalCharges },
|
||||
dataItems
|
||||
};
|
||||
}
|
||||
|
||||
@@ -191,8 +191,14 @@ function getFieldData(field: Field<any, any>, arrayCtor: ArrayCtor<string | numb
|
||||
array[offset] = '';
|
||||
allPresent = false;
|
||||
} else {
|
||||
mask[offset] = Column.ValueKind.Present;
|
||||
array[offset] = getter(key, d, offset);
|
||||
const value = getter(key, d, offset);
|
||||
if (typeof value === 'string' && !value) {
|
||||
mask[offset] = Column.ValueKind.NotPresent;
|
||||
allPresent = false;
|
||||
} else {
|
||||
mask[offset] = Column.ValueKind.Present;
|
||||
}
|
||||
array[offset] = value;
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
@@ -11,6 +11,7 @@ import { OrderedSet } from '../../../mol-data/int';
|
||||
import { NumberArray, PickRequired } from '../../../mol-util/type-helpers';
|
||||
import { Box3D } from './box3d';
|
||||
import { Axes3D } from './axes3d';
|
||||
import { PrincipalAxes } from '../../linear-algebra/matrix/principal-axes';
|
||||
|
||||
interface Sphere3D {
|
||||
center: Vec3,
|
||||
@@ -202,11 +203,28 @@ namespace Sphere3D {
|
||||
return out;
|
||||
}
|
||||
if (hasExtrema(sphere)) {
|
||||
const positions = new Float32Array(sphere.extrema.length * 3);
|
||||
for (let i = 0; i < sphere.extrema.length; i++) {
|
||||
Vec3.toArray(sphere.extrema[i], positions, i * 3);
|
||||
}
|
||||
|
||||
const axes = PrincipalAxes.calculateMomentsAxes(positions);
|
||||
Axes3D.scale(axes, Axes3D.normalize(axes, axes), delta);
|
||||
|
||||
setExtrema(out, sphere.extrema.map(e => {
|
||||
Vec3.sub(tmpDir, e, sphere.center);
|
||||
const dist = Vec3.distance(sphere.center, e);
|
||||
Vec3.normalize(tmpDir, tmpDir);
|
||||
return Vec3.scaleAndAdd(Vec3(), sphere.center, tmpDir, dist + delta);
|
||||
const out = Vec3.clone(e);
|
||||
|
||||
const sA = Vec3.dot(tmpDir, axes.dirA) < 0 ? -1 : 1;
|
||||
Vec3.scaleAndAdd(out, out, axes.dirA, sA);
|
||||
|
||||
const sB = Vec3.dot(tmpDir, axes.dirB) < 0 ? -1 : 1;
|
||||
Vec3.scaleAndAdd(out, out, axes.dirB, sB);
|
||||
|
||||
const sC = Vec3.dot(tmpDir, axes.dirC) < 0 ? -1 : 1;
|
||||
Vec3.scaleAndAdd(out, out, axes.dirC, sC);
|
||||
|
||||
return out;
|
||||
}));
|
||||
}
|
||||
return out;
|
||||
|
||||
@@ -52,24 +52,30 @@ namespace SymmetryOperator {
|
||||
export const RotationTranslationEpsilon = 0.005;
|
||||
|
||||
export type CreateInfo = { assembly?: SymmetryOperator['assembly'], ncsId?: number, hkl?: Vec3, spgrOp?: number }
|
||||
export function create(name: string, matrix: Mat4, info?: CreateInfo): SymmetryOperator {
|
||||
export function create(name: string, matrix: Mat4, info?: CreateInfo | SymmetryOperator): SymmetryOperator {
|
||||
let { assembly, ncsId, hkl, spgrOp } = info || { };
|
||||
const _hkl = hkl ? Vec3.clone(hkl) : Vec3();
|
||||
spgrOp = defaults(spgrOp, -1);
|
||||
ncsId = ncsId || -1;
|
||||
const suffix = getSuffix(info);
|
||||
if (Mat4.isIdentity(matrix)) return { name, assembly, matrix, inverse: Mat4.identity(), isIdentity: true, hkl: _hkl, spgrOp, ncsId, suffix };
|
||||
const isIdentity = Mat4.isIdentity(matrix);
|
||||
const suffix = getSuffix(info, isIdentity);
|
||||
if (isIdentity) return { name, assembly, matrix, inverse: Mat4.identity(), isIdentity: true, hkl: _hkl, spgrOp, ncsId, suffix };
|
||||
if (!Mat4.isRotationAndTranslation(matrix, RotationTranslationEpsilon)) {
|
||||
console.warn(`Symmetry operator (${name}) should be a composition of rotation and translation.`);
|
||||
}
|
||||
return { name, assembly, matrix, inverse: Mat4.invert(Mat4(), matrix), isIdentity: false, hkl: _hkl, spgrOp, ncsId, suffix };
|
||||
}
|
||||
|
||||
function getSuffix(info?: CreateInfo) {
|
||||
function isSymmetryOperator(x: any): x is SymmetryOperator {
|
||||
return !!x && !!x.matrix && !!x.inverse && typeof x.name === 'string';
|
||||
}
|
||||
|
||||
function getSuffix(info?: CreateInfo | SymmetryOperator, isIdentity?: boolean) {
|
||||
if (!info) return '';
|
||||
|
||||
if (info.assembly) {
|
||||
return `_${info.assembly.operId}`;
|
||||
if (isSymmetryOperator(info)) return info.suffix;
|
||||
return isIdentity ? '' : `_${info.assembly.operId}`;
|
||||
}
|
||||
|
||||
if (typeof info.spgrOp !== 'undefined' && typeof info.hkl !== 'undefined' && info.spgrOp !== -1) {
|
||||
|
||||
@@ -7,21 +7,21 @@
|
||||
|
||||
import { Column, Table } from '../../../mol-data/db';
|
||||
import { Interval, Segmentation } from '../../../mol-data/int';
|
||||
import { UUID } from '../../../mol-util/uuid';
|
||||
import { ElementIndex, ChainIndex } from '../../../mol-model/structure';
|
||||
import { toDatabase } from '../../../mol-io/reader/cif/schema';
|
||||
import { SymmetryOperator } from '../../../mol-math/geometry';
|
||||
import { Mat4, Vec3 } from '../../../mol-math/linear-algebra';
|
||||
import { ChainIndex, ElementIndex } from '../../../mol-model/structure';
|
||||
import { AtomSiteOperatorMappingSchema } from '../../../mol-model/structure/export/categories/atom_site_operator_mapping';
|
||||
import { Model } from '../../../mol-model/structure/model/model';
|
||||
import { AtomicConformation, AtomicData, AtomicHierarchy, AtomicSegments, AtomsSchema, ChainsSchema, ResiduesSchema } from '../../../mol-model/structure/model/properties/atomic';
|
||||
import { getAtomicIndex } from '../../../mol-model/structure/model/properties/utils/atomic-index';
|
||||
import { ElementSymbol } from '../../../mol-model/structure/model/types';
|
||||
import { Entities } from '../../../mol-model/structure/model/properties/common';
|
||||
import { getAtomicDerivedData } from '../../../mol-model/structure/model/properties/utils/atomic-derived';
|
||||
import { AtomSite } from './schema';
|
||||
import { getAtomicIndex } from '../../../mol-model/structure/model/properties/utils/atomic-index';
|
||||
import { ElementSymbol } from '../../../mol-model/structure/model/types';
|
||||
import { UUID } from '../../../mol-util/uuid';
|
||||
import { ModelFormat } from '../../format';
|
||||
import { SymmetryOperator } from '../../../mol-math/geometry';
|
||||
import { MmcifFormat } from '../mmcif';
|
||||
import { AtomSiteOperatorMappingSchema } from '../../../mol-model/structure/export/categories/atom_site_operator_mapping';
|
||||
import { toDatabase } from '../../../mol-io/reader/cif/schema';
|
||||
import { Mat4, Vec3 } from '../../../mol-math/linear-algebra';
|
||||
import { AtomSite } from './schema';
|
||||
|
||||
function findHierarchyOffsets(atom_site: AtomSite) {
|
||||
if (atom_site._rowCount === 0) return { residues: [], chains: [] };
|
||||
|
||||
@@ -30,7 +30,7 @@ export interface CoarseData {
|
||||
|
||||
export const EmptyCoarse = { hierarchy: CoarseHierarchy.Empty, conformation: void 0 as any };
|
||||
|
||||
export function getCoarse(data: CoarseData, properties: Model['properties']): { hierarchy: CoarseHierarchy, conformation: CoarseConformation } {
|
||||
export function getCoarse(data: CoarseData, chemicalComponentMap: Model['properties']['chemicalComponentMap']): { hierarchy: CoarseHierarchy, conformation: CoarseConformation } {
|
||||
const { ihm_sphere_obj_site, ihm_gaussian_obj_site } = data;
|
||||
|
||||
if (ihm_sphere_obj_site._rowCount === 0 && ihm_gaussian_obj_site._rowCount === 0) return EmptyCoarse;
|
||||
@@ -38,12 +38,12 @@ export function getCoarse(data: CoarseData, properties: Model['properties']): {
|
||||
const sphereData = getData(ihm_sphere_obj_site);
|
||||
const sphereConformation = getSphereConformation(ihm_sphere_obj_site);
|
||||
const sphereKeys = getCoarseKeys(sphereData, data.entities);
|
||||
const sphereRanges = getCoarseRanges(sphereData, properties.chemicalComponentMap);
|
||||
const sphereRanges = getCoarseRanges(sphereData, chemicalComponentMap);
|
||||
|
||||
const gaussianData = getData(ihm_gaussian_obj_site);
|
||||
const gaussianConformation = getGaussianConformation(ihm_gaussian_obj_site);
|
||||
const gaussianKeys = getCoarseKeys(gaussianData, data.entities);
|
||||
const gaussianRanges = getCoarseRanges(gaussianData, properties.chemicalComponentMap);
|
||||
const gaussianRanges = getCoarseRanges(gaussianData, chemicalComponentMap);
|
||||
|
||||
return {
|
||||
hierarchy: {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { getEntityType, getEntitySubtype } from '../../../mol-model/structure/mo
|
||||
import { ElementIndex, EntityIndex, Model } from '../../../mol-model/structure/model';
|
||||
import { BasicData, BasicSchema, Entity } from './schema';
|
||||
|
||||
export function getEntities(data: BasicData, properties: Model['properties']): Entities {
|
||||
export function getEntityData(data: BasicData): Entities {
|
||||
let entityData: Entity;
|
||||
|
||||
if (!data.entity.id.isDefined) {
|
||||
@@ -121,28 +121,32 @@ export function getEntities(data: BasicData, properties: Model['properties']): E
|
||||
|
||||
const subtypeColumn = Column.ofArray({ array: subtypes, schema: EntitySubtype });
|
||||
|
||||
//
|
||||
|
||||
const prdIds: string[] = new Array(entityData._rowCount);
|
||||
prdIds.fill('');
|
||||
|
||||
if (data.pdbx_molecule && data.pdbx_molecule.prd_id.isDefined) {
|
||||
const { asym_id, prd_id, _rowCount } = data.pdbx_molecule;
|
||||
for (let i = 0; i < _rowCount; ++i) {
|
||||
const asymId = asym_id.value(i);
|
||||
const entityId = properties.structAsymMap.get(asymId)?.entity_id;
|
||||
if (entityId !== undefined) {
|
||||
prdIds[getEntityIndex(entityId)] = prd_id.value(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const prdIdColumn = Column.ofArray({ array: prdIds, schema: Column.Schema.str });
|
||||
|
||||
return {
|
||||
data: entityData,
|
||||
subtype: subtypeColumn,
|
||||
prd_id: prdIdColumn,
|
||||
getEntityIndex
|
||||
};
|
||||
}
|
||||
|
||||
export function getEntitiesWithPRD(data: BasicData, entities: Entities, structAsymMap: Model['properties']['structAsymMap']): Entities {
|
||||
if (!data.pdbx_molecule || !data.pdbx_molecule.prd_id.isDefined) {
|
||||
return entities;
|
||||
}
|
||||
|
||||
const prdIds: string[] = new Array(entities.data._rowCount);
|
||||
prdIds.fill('');
|
||||
const { asym_id, prd_id, _rowCount } = data.pdbx_molecule;
|
||||
for (let i = 0; i < _rowCount; ++i) {
|
||||
const asymId = asym_id.value(i);
|
||||
const entityId = structAsymMap.get(asymId)?.entity_id;
|
||||
if (entityId !== undefined) {
|
||||
prdIds[entities.getEntityIndex(entityId)] = prd_id.value(i);
|
||||
}
|
||||
}
|
||||
const prdIdColumn = Column.ofArray({ array: prdIds, schema: Column.Schema.str });
|
||||
|
||||
return {
|
||||
...entities,
|
||||
prd_id: prdIdColumn
|
||||
};
|
||||
}
|
||||
@@ -18,13 +18,13 @@ import { sortAtomSite } from './sort';
|
||||
import { ModelFormat } from '../../format';
|
||||
import { getAtomicRanges } from '../../../mol-model/structure/model/properties/utils/atomic-ranges';
|
||||
import { AtomSite, BasicData } from './schema';
|
||||
import { getProperties } from './properties';
|
||||
import { getEntities } from './entities';
|
||||
import { getChemicalComponentMap, getMissingResidues, getSaccharideComponentMap, getStructAsymMap } from './properties';
|
||||
import { getEntitiesWithPRD, getEntityData } from './entities';
|
||||
import { getModelGroupName } from './util';
|
||||
import { ArrayTrajectory } from '../../../mol-model/structure/trajectory';
|
||||
|
||||
export async function createModels(data: BasicData, format: ModelFormat, ctx: RuntimeContext) {
|
||||
const properties = getProperties(data);
|
||||
const properties = getCommonProperties(data, format);
|
||||
const models = data.ihm_model_list._rowCount > 0
|
||||
? await readIntegrative(ctx, data, properties, format)
|
||||
: await readStandard(ctx, data, properties, format);
|
||||
@@ -36,9 +36,18 @@ export async function createModels(data: BasicData, format: ModelFormat, ctx: Ru
|
||||
return new ArrayTrajectory(models);
|
||||
}
|
||||
|
||||
/** Standard atomic model */
|
||||
function createStandardModel(data: BasicData, atom_site: AtomSite, sourceIndex: Column<number>, entities: Entities, properties: Model['properties'], format: ModelFormat, previous?: Model): Model {
|
||||
type CommonProperties = Omit<Model['properties'], 'structAsymMap'>
|
||||
|
||||
function getCommonProperties(data: BasicData, format: ModelFormat): CommonProperties {
|
||||
return {
|
||||
missingResidues: getMissingResidues(data),
|
||||
chemicalComponentMap: getChemicalComponentMap(data),
|
||||
saccharideComponentMap: getSaccharideComponentMap(data)
|
||||
};
|
||||
}
|
||||
|
||||
/** Standard atomic model */
|
||||
function createStandardModel(data: BasicData, atom_site: AtomSite, sourceIndex: Column<number>, entities: Entities, properties: CommonProperties, format: ModelFormat, previous?: Model): Model {
|
||||
const atomic = getAtomicHierarchyAndConformation(atom_site, sourceIndex, entities, properties.chemicalComponentMap, format, previous);
|
||||
const modelNum = atom_site.pdbx_PDB_model_num.value(0);
|
||||
if (previous && atomic.sameAsPrevious) {
|
||||
@@ -54,6 +63,7 @@ function createStandardModel(data: BasicData, atom_site: AtomSite, sourceIndex:
|
||||
const coarse = EmptyCoarse;
|
||||
const sequence = getSequence(data, entities, atomic.hierarchy, coarse.hierarchy);
|
||||
const atomicRanges = getAtomicRanges(atomic.hierarchy, entities, atomic.conformation, sequence);
|
||||
const structAsymMap = getStructAsymMap(atomic.hierarchy);
|
||||
|
||||
const entry = data.entry.id.valueKind(0) === Column.ValueKind.Present
|
||||
? data.entry.id.value(0) : format.name;
|
||||
@@ -70,7 +80,7 @@ function createStandardModel(data: BasicData, atom_site: AtomSite, sourceIndex:
|
||||
sourceData: format,
|
||||
modelNum,
|
||||
parent: undefined,
|
||||
entities,
|
||||
entities: getEntitiesWithPRD(data, entities, structAsymMap),
|
||||
sequence,
|
||||
atomicHierarchy: atomic.hierarchy,
|
||||
atomicConformation: atomic.conformation,
|
||||
@@ -78,7 +88,10 @@ function createStandardModel(data: BasicData, atom_site: AtomSite, sourceIndex:
|
||||
atomicChainOperatorMappinng: atomic.chainOperatorMapping,
|
||||
coarseHierarchy: coarse.hierarchy,
|
||||
coarseConformation: coarse.conformation,
|
||||
properties,
|
||||
properties: {
|
||||
...properties,
|
||||
structAsymMap
|
||||
},
|
||||
customProperties: new CustomProperties(),
|
||||
_staticPropertyData: Object.create(null),
|
||||
_dynamicPropertyData: Object.create(null)
|
||||
@@ -86,9 +99,9 @@ function createStandardModel(data: BasicData, atom_site: AtomSite, sourceIndex:
|
||||
}
|
||||
|
||||
/** Integrative model with atomic/coarse parts */
|
||||
function createIntegrativeModel(data: BasicData, ihm: CoarseData, properties: Model['properties'], format: ModelFormat): Model {
|
||||
function createIntegrativeModel(data: BasicData, ihm: CoarseData, properties: CommonProperties, format: ModelFormat): Model {
|
||||
const atomic = getAtomicHierarchyAndConformation(ihm.atom_site, ihm.atom_site_sourceIndex, ihm.entities, properties.chemicalComponentMap, format);
|
||||
const coarse = getCoarse(ihm, properties);
|
||||
const coarse = getCoarse(ihm, properties.chemicalComponentMap);
|
||||
const sequence = getSequence(data, ihm.entities, atomic.hierarchy, coarse.hierarchy);
|
||||
const atomicRanges = getAtomicRanges(atomic.hierarchy, ihm.entities, atomic.conformation, sequence);
|
||||
|
||||
@@ -101,6 +114,8 @@ function createIntegrativeModel(data: BasicData, ihm: CoarseData, properties: Mo
|
||||
if (ihm.model_name) label.push(ihm.model_name);
|
||||
if (ihm.model_group_name) label.push(ihm.model_group_name);
|
||||
|
||||
const structAsymMap = getStructAsymMap(atomic.hierarchy, data);
|
||||
|
||||
return {
|
||||
id: UUID.create22(),
|
||||
entryId: entry,
|
||||
@@ -109,7 +124,7 @@ function createIntegrativeModel(data: BasicData, ihm: CoarseData, properties: Mo
|
||||
sourceData: format,
|
||||
modelNum: ihm.model_id,
|
||||
parent: undefined,
|
||||
entities: ihm.entities,
|
||||
entities: getEntitiesWithPRD(data, ihm.entities, structAsymMap),
|
||||
sequence,
|
||||
atomicHierarchy: atomic.hierarchy,
|
||||
atomicConformation: atomic.conformation,
|
||||
@@ -117,7 +132,10 @@ function createIntegrativeModel(data: BasicData, ihm: CoarseData, properties: Mo
|
||||
atomicChainOperatorMappinng: atomic.chainOperatorMapping,
|
||||
coarseHierarchy: coarse.hierarchy,
|
||||
coarseConformation: coarse.conformation,
|
||||
properties,
|
||||
properties: {
|
||||
...properties,
|
||||
structAsymMap
|
||||
},
|
||||
customProperties: new CustomProperties(),
|
||||
_staticPropertyData: Object.create(null),
|
||||
_dynamicPropertyData: Object.create(null)
|
||||
@@ -132,12 +150,12 @@ function findModelEnd(num: Column<number>, startIndex: number) {
|
||||
return endIndex;
|
||||
}
|
||||
|
||||
async function readStandard(ctx: RuntimeContext, data: BasicData, properties: Model['properties'], format: ModelFormat) {
|
||||
async function readStandard(ctx: RuntimeContext, data: BasicData, properties: CommonProperties, format: ModelFormat) {
|
||||
const models: Model[] = [];
|
||||
|
||||
if (data.atom_site) {
|
||||
const atomCount = data.atom_site.id.rowCount;
|
||||
const entities = getEntities(data, properties);
|
||||
const entities = getEntityData(data);
|
||||
|
||||
let modelStart = 0;
|
||||
while (modelStart < atomCount) {
|
||||
@@ -170,8 +188,8 @@ function splitTable<T extends Table<any>>(table: T, col: Column<number>) {
|
||||
|
||||
|
||||
|
||||
async function readIntegrative(ctx: RuntimeContext, data: BasicData, properties: Model['properties'], format: ModelFormat) {
|
||||
const entities = getEntities(data, properties);
|
||||
async function readIntegrative(ctx: RuntimeContext, data: BasicData, properties: CommonProperties, format: ModelFormat) {
|
||||
const entities = getEntityData(data);
|
||||
// when `atom_site.ihm_model_id` is undefined fall back to `atom_site.pdbx_PDB_model_num`
|
||||
const atom_sites_modelColumn = data.atom_site.ihm_model_id.isDefined
|
||||
? data.atom_site.ihm_model_id : data.atom_site.pdbx_PDB_model_num;
|
||||
@@ -206,7 +224,7 @@ async function readIntegrative(ctx: RuntimeContext, data: BasicData, properties:
|
||||
model_id: id,
|
||||
model_name: model_name.value(i),
|
||||
model_group_name: getModelGroupName(id, data),
|
||||
entities: entities,
|
||||
entities,
|
||||
atom_site,
|
||||
atom_site_sourceIndex,
|
||||
ihm_sphere_obj_site: sphere_sites.has(id) ? sphere_sites.get(id)!.table : Table.window(data.ihm_sphere_obj_site, data.ihm_sphere_obj_site._schema, 0, 0),
|
||||
|
||||
@@ -5,15 +5,16 @@
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
import { Table } from '../../../mol-data/db';
|
||||
import { Model } from '../../../mol-model/structure/model/model';
|
||||
import { AtomicHierarchy } from '../../../mol-model/structure/model/properties/atomic';
|
||||
import { ChemicalComponent, MissingResidue, StructAsym } from '../../../mol-model/structure/model/properties/common';
|
||||
import { getMoleculeType, MoleculeType, getDefaultChemicalComponent } from '../../../mol-model/structure/model/types';
|
||||
import { SaccharideComponentMap, SaccharideComponent, SaccharidesSnfgMap, SaccharideCompIdMap, UnknownSaccharideComponent } from '../../../mol-model/structure/structure/carbohydrates/constants';
|
||||
import { getDefaultChemicalComponent, getMoleculeType, MoleculeType } from '../../../mol-model/structure/model/types';
|
||||
import { SaccharideCompIdMap, SaccharideComponent, SaccharideComponentMap, SaccharidesSnfgMap, UnknownSaccharideComponent } from '../../../mol-model/structure/structure/carbohydrates/constants';
|
||||
import { memoize1 } from '../../../mol-util/memoize';
|
||||
import { BasicData } from './schema';
|
||||
import { Table } from '../../../mol-data/db';
|
||||
|
||||
function getMissingResidues(data: BasicData): Model['properties']['missingResidues'] {
|
||||
export function getMissingResidues(data: BasicData): Model['properties']['missingResidues'] {
|
||||
const map = new Map<string, MissingResidue>();
|
||||
const getKey = (model_num: number, asym_id: string, seq_id: number) => {
|
||||
return `${model_num}|${asym_id}|${seq_id}`;
|
||||
@@ -36,7 +37,7 @@ function getMissingResidues(data: BasicData): Model['properties']['missingResidu
|
||||
};
|
||||
}
|
||||
|
||||
function getChemicalComponentMap(data: BasicData): Model['properties']['chemicalComponentMap'] {
|
||||
export function getChemicalComponentMap(data: BasicData): Model['properties']['chemicalComponentMap'] {
|
||||
const map = new Map<string, ChemicalComponent>();
|
||||
|
||||
if (data.chem_comp._rowCount > 0) {
|
||||
@@ -53,7 +54,7 @@ function getChemicalComponentMap(data: BasicData): Model['properties']['chemical
|
||||
return map;
|
||||
}
|
||||
|
||||
function getSaccharideComponentMap(data: BasicData): SaccharideComponentMap {
|
||||
export function getSaccharideComponentMap(data: BasicData): SaccharideComponentMap {
|
||||
const map = new Map<string, SaccharideComponent>();
|
||||
|
||||
if (data.pdbx_chem_comp_identifier._rowCount > 0) {
|
||||
@@ -108,22 +109,18 @@ const getUniqueComponentNames = memoize1((data: BasicData) => {
|
||||
});
|
||||
|
||||
|
||||
function getStructAsymMap(data: BasicData): Model['properties']['structAsymMap'] {
|
||||
export function getStructAsymMap(atomic: AtomicHierarchy, data?: BasicData): Model['properties']['structAsymMap'] {
|
||||
const map = new Map<string, StructAsym>();
|
||||
|
||||
const { label_asym_id, auth_asym_id, label_entity_id } = data.atom_site;
|
||||
for (let i = 0, il = label_asym_id.rowCount; i < il; ++i) {
|
||||
const { auth_asym_id, label_asym_id, label_entity_id } = atomic.chains;
|
||||
|
||||
for (let i = 0, _i = atomic.chains._rowCount; i < _i; i ++) {
|
||||
const id = label_asym_id.value(i);
|
||||
if (!map.has(id)) {
|
||||
map.set(id, {
|
||||
id,
|
||||
auth_id: auth_asym_id.value(i),
|
||||
entity_id: label_entity_id.value(i)
|
||||
});
|
||||
}
|
||||
map.set(id, { id, auth_id: auth_asym_id.value(i), entity_id: label_entity_id.value(i) });
|
||||
}
|
||||
|
||||
if (data.struct_asym._rowCount > 0) {
|
||||
// to get asym mapping for coarse/ihm data
|
||||
if (data?.struct_asym._rowCount) {
|
||||
const { id, entity_id } = data.struct_asym;
|
||||
for (let i = 0, il = id.rowCount; i < il; ++i) {
|
||||
const _id = id.value(i);
|
||||
@@ -136,14 +133,6 @@ function getStructAsymMap(data: BasicData): Model['properties']['structAsymMap']
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
export function getProperties(data: BasicData): Model['properties'] {
|
||||
return {
|
||||
missingResidues: getMissingResidues(data),
|
||||
chemicalComponentMap: getChemicalComponentMap(data),
|
||||
saccharideComponentMap: getSaccharideComponentMap(data),
|
||||
structAsymMap: getStructAsymMap(data)
|
||||
};
|
||||
return map;
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
* @author Panagiotis Tourlas <panagiot_tourlov@hotmail.com>
|
||||
*/
|
||||
|
||||
import { Column, Table } from '../../mol-data/db';
|
||||
import { MolFile } from '../../mol-io/reader/mol/parser';
|
||||
import { MolFile, formalChargeMapper } from '../../mol-io/reader/mol/parser';
|
||||
import { MoleculeType } from '../../mol-model/structure/model/types';
|
||||
import { RuntimeContext, Task } from '../../mol-task';
|
||||
import { createModels } from './basic/parser';
|
||||
@@ -18,13 +19,24 @@ import { IndexPairBonds } from './property/bonds/index-pair';
|
||||
import { Trajectory } from '../../mol-model/structure';
|
||||
|
||||
export async function getMolModels(mol: MolFile, format: ModelFormat<any> | undefined, ctx: RuntimeContext) {
|
||||
const { atoms, bonds } = mol;
|
||||
const { atoms, bonds, formalCharges } = mol;
|
||||
|
||||
const MOL = Column.ofConst('MOL', mol.atoms.count, Column.Schema.str);
|
||||
const A = Column.ofConst('A', mol.atoms.count, Column.Schema.str);
|
||||
const type_symbol = Column.asArrayColumn(atoms.type_symbol);
|
||||
const seq_id = Column.ofConst(1, atoms.count, Column.Schema.int);
|
||||
|
||||
const computedFormalCharges = new Int32Array(mol.atoms.count);
|
||||
if (formalCharges.atomIdx.rowCount > 0) {
|
||||
for (let i = 0; i < formalCharges.atomIdx.rowCount; i++) {
|
||||
computedFormalCharges[formalCharges.atomIdx.value(i) - 1] = formalCharges.charge.value(i);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < mol.atoms.count; i++) {
|
||||
computedFormalCharges[i] = formalChargeMapper(atoms.formal_charge.value(i));
|
||||
}
|
||||
}
|
||||
|
||||
const atom_site = Table.ofPartialColumns(BasicSchema.atom_site, {
|
||||
auth_asym_id: A,
|
||||
auth_atom_id: type_symbol,
|
||||
@@ -45,6 +57,7 @@ export async function getMolModels(mol: MolFile, format: ModelFormat<any> | unde
|
||||
type_symbol,
|
||||
|
||||
pdbx_PDB_model_num: Column.ofConst(1, atoms.count, Column.Schema.int),
|
||||
pdbx_formal_charge: Column.ofIntArray(computedFormalCharges)
|
||||
}, atoms.count);
|
||||
|
||||
const entityBuilder = new EntityBuilder();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -98,29 +98,20 @@ class InteractionsInterContacts extends InterUnitGraph<number, Features.FeatureI
|
||||
constructor(map: Map<number, InterUnitGraph.UnitPairEdges<number, Features.FeatureIndex, InteractionsInterContacts.Props>[]>, unitsFeatures: IntMap<Features>) {
|
||||
super(map);
|
||||
|
||||
let count = 0;
|
||||
const elementKeyIndex = new Map<string, number[]>();
|
||||
|
||||
const add = (index: StructureElement.UnitIndex, unitId: number) => {
|
||||
const vertexKey = this.getElementKey(index, unitId);
|
||||
const e = elementKeyIndex.get(vertexKey);
|
||||
if (e === undefined) elementKeyIndex.set(vertexKey, [count]);
|
||||
else e.push(count);
|
||||
};
|
||||
|
||||
this.map.forEach(pairEdgesArray => {
|
||||
pairEdgesArray.forEach(({ unitA, connectedIndices }) => {
|
||||
connectedIndices.forEach(indexA => {
|
||||
const { offsets: offsetsA, members: membersA } = unitsFeatures.get(unitA);
|
||||
for (let j = offsetsA[indexA], jl = offsetsA[indexA + 1]; j < jl; ++j) {
|
||||
add(membersA[j], unitA);
|
||||
}
|
||||
count += 1;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
this.elementKeyIndex = elementKeyIndex;
|
||||
this.elementKeyIndex = new Map<string, number[]>();
|
||||
for (let i = 0, il = this.edges.length; i < il; ++i) {
|
||||
const { unitA, indexA } = this.edges[i];
|
||||
const { offsets, members } = unitsFeatures.get(unitA);
|
||||
for (let j = offsets[indexA], jl = offsets[indexA + 1]; j < jl; ++j) {
|
||||
const vertexKey = this.getElementKey(members[j], unitA);
|
||||
const e = this.elementKeyIndex.get(vertexKey);
|
||||
if (e === undefined) {
|
||||
this.elementKeyIndex.set(vertexKey, [i]);
|
||||
} else {
|
||||
e.push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace InteractionsInterContacts {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -74,10 +74,11 @@ function createInterUnitInteractionCylinderMesh(ctx: VisualContext, structure: S
|
||||
if (!childUnitA) return true;
|
||||
|
||||
const unitA = structure.unitMap.get(b.unitA);
|
||||
const fA = unitsFeatures.get(b.unitA);
|
||||
// TODO: check all members
|
||||
const eA = unitA.elements[fA.members[fA.offsets[b.indexA]]];
|
||||
if (!SortedArray.has(childUnitA.elements, eA)) return true;
|
||||
const { offsets, members } = unitsFeatures.get(b.unitA);
|
||||
for (let i = offsets[b.indexA], il = offsets[b.indexA + 1]; i < il; ++i) {
|
||||
const eA = unitA.elements[members[i]];
|
||||
if (!SortedArray.has(childUnitA.elements, eA)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -144,6 +145,9 @@ function getInteractionLoci(pickingId: PickingId, structure: Structure, id: numb
|
||||
return EmptyLoci;
|
||||
}
|
||||
|
||||
const __unitMap = new Map<number, OrderedSet<StructureElement.UnitIndex>>();
|
||||
const __contactIndicesSet = new Set<number>();
|
||||
|
||||
function eachInteraction(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean, isMarking: boolean) {
|
||||
let changed = false;
|
||||
if (Interactions.isLoci(loci)) {
|
||||
@@ -162,21 +166,48 @@ function eachInteraction(loci: Loci, structure: Structure, apply: (interval: Int
|
||||
if (!Structure.areEquivalent(loci.structure, structure)) return false;
|
||||
if (isMarking && loci.elements.length === 1) return false; // only a single unit
|
||||
|
||||
const contacts = InteractionsProvider.get(structure).value?.contacts;
|
||||
if (!contacts) return false;
|
||||
const interactions = InteractionsProvider.get(structure).value;
|
||||
if (!interactions) return false;
|
||||
|
||||
const { contacts, unitsFeatures } = interactions;
|
||||
|
||||
for (const e of loci.elements) __unitMap.set(e.unit.id, e.indices);
|
||||
|
||||
// TODO when isMarking, all elements of contact features need to be in the loci
|
||||
for (const e of loci.elements) {
|
||||
const { unit } = e;
|
||||
if (!Unit.isAtomic(unit)) continue;
|
||||
if (isMarking && OrderedSet.size(e.indices) === 1) continue;
|
||||
|
||||
OrderedSet.forEach(e.indices, v => {
|
||||
for (const idx of contacts.getContactIndicesForElement(v, unit)) {
|
||||
if (apply(Interval.ofSingleton(idx))) changed = true;
|
||||
__contactIndicesSet.add(idx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
__contactIndicesSet.forEach(i => {
|
||||
if (isMarking) {
|
||||
const { indexA, unitA, indexB, unitB } = contacts.edges[i];
|
||||
|
||||
const indicesA = __unitMap.get(unitA);
|
||||
const indicesB = __unitMap.get(unitB);
|
||||
if (!indicesA || !indicesB) return;
|
||||
|
||||
const { offsets: offsetsA, members: membersA } = unitsFeatures.get(unitA);
|
||||
for (let j = offsetsA[indexA], jl = offsetsA[indexA + 1]; j < jl; ++j) {
|
||||
if (!OrderedSet.has(indicesA, membersA[j])) return;
|
||||
}
|
||||
|
||||
const { offsets: offsetsB, members: membersB } = unitsFeatures.get(unitB);
|
||||
for (let j = offsetsB[indexB], jl = offsetsB[indexB + 1]; j < jl; ++j) {
|
||||
if (!OrderedSet.has(indicesB, membersB[j])) return;
|
||||
}
|
||||
}
|
||||
|
||||
if (apply(Interval.ofSingleton(i))) changed = true;
|
||||
});
|
||||
|
||||
__unitMap.clear();
|
||||
__contactIndicesSet.clear();
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -56,11 +56,19 @@ async function createIntraUnitInteractionsCylinderMesh(ctx: VisualContext, unit:
|
||||
const sizeB = theme.size.size(location);
|
||||
return Math.min(sizeA, sizeB) * sizeFactor;
|
||||
},
|
||||
ignore: (edgeIndex: number) => (
|
||||
flag[edgeIndex] === InteractionFlag.Filtered ||
|
||||
// TODO: check all members
|
||||
(!!childUnit && !SortedArray.has(childUnit.elements, unit.elements[members[offsets[a[edgeIndex]]]]))
|
||||
)
|
||||
ignore: (edgeIndex: number) => {
|
||||
if (flag[edgeIndex] === InteractionFlag.Filtered) return true;
|
||||
|
||||
if (childUnit) {
|
||||
const f = a[edgeIndex];
|
||||
for (let i = offsets[f], jl = offsets[f + 1]; i < jl; ++i) {
|
||||
const e = unit.elements[members[offsets[i]]];
|
||||
if (!SortedArray.has(childUnit.elements, e)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const m = createLinkCylinderMesh(ctx, builderProps, props, mesh);
|
||||
@@ -123,6 +131,8 @@ function getInteractionLoci(pickingId: PickingId, structureGroup: StructureGroup
|
||||
return EmptyLoci;
|
||||
}
|
||||
|
||||
const __contactIndicesSet = new Set<number>();
|
||||
|
||||
function eachInteraction(loci: Loci, structureGroup: StructureGroup, apply: (interval: Interval) => boolean, isMarking: boolean) {
|
||||
let changed = false;
|
||||
if (Interactions.isLoci(loci)) {
|
||||
@@ -156,21 +166,37 @@ function eachInteraction(loci: Loci, structureGroup: StructureGroup, apply: (int
|
||||
|
||||
const { offset } = contacts;
|
||||
const { offsets: fOffsets, indices: fIndices } = features.elementsIndex;
|
||||
const { members, offsets } = features;
|
||||
|
||||
// TODO: when isMarking, all elements of contact features need to be in the loci
|
||||
for (const e of loci.elements) {
|
||||
const unitIdx = group.unitIndexMap.get(e.unit.id);
|
||||
if (unitIdx !== undefined) continue;
|
||||
if (isMarking && OrderedSet.size(e.indices) === 1) continue;
|
||||
if (unitIdx === undefined) continue;
|
||||
|
||||
OrderedSet.forEach(e.indices, v => {
|
||||
for (let i = fOffsets[v], il = fOffsets[v + 1]; i < il; ++i) {
|
||||
const fI = fIndices[i];
|
||||
for (let j = offset[fI], jl = offset[fI + 1]; j < jl; ++j) {
|
||||
if (apply(Interval.ofSingleton(unitIdx * groupCount + j))) changed = true;
|
||||
__contactIndicesSet.add(j);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
__contactIndicesSet.forEach(i => {
|
||||
if (isMarking) {
|
||||
const fA = contacts.a[i];
|
||||
for (let j = offsets[fA], jl = offsets[fA + 1]; j < jl; ++j) {
|
||||
if (!OrderedSet.has(e.indices, members[j])) return;
|
||||
}
|
||||
const fB = contacts.b[i];
|
||||
for (let j = offsets[fB], jl = offsets[fB + 1]; j < jl; ++j) {
|
||||
if (!OrderedSet.has(e.indices, members[j])) return;
|
||||
}
|
||||
}
|
||||
|
||||
if (apply(Interval.ofSingleton(unitIdx * groupCount + i))) changed = true;
|
||||
});
|
||||
|
||||
__contactIndicesSet.clear();
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace BestDatabaseSequenceMapping {
|
||||
type: 'static',
|
||||
defaultParams: {},
|
||||
getParams: () => ({}),
|
||||
isApplicable: (data: Model) => MmcifFormat.is(data.sourceData) && data.sourceData.data.frame.categories?.atom_site?.fieldNames.indexOf('db_name') >= 0,
|
||||
isApplicable: (data: Model) => MmcifFormat.is(data.sourceData) && data.sourceData.data.frame.categories?.atom_site?.fieldNames.indexOf('pdbx_sifts_xref_db_name') >= 0,
|
||||
obtain: async (ctx, data) => {
|
||||
return { value: fromCif(data) };
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace BestDatabaseSequenceMapping {
|
||||
const data = Provider.get(model).value;
|
||||
if (!data) return '';
|
||||
const eI = loc.unit.elements[loc.element];
|
||||
const rI = model.atomicHierarchy.residueAtomSegments.offsets[eI];
|
||||
const rI = model.atomicHierarchy.residueAtomSegments.index[eI];
|
||||
return data.accession[rI];
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace BestDatabaseSequenceMapping {
|
||||
const data = Provider.get(model).value;
|
||||
if (!data) return;
|
||||
const eI = loc.unit.elements[loc.element];
|
||||
const rI = model.atomicHierarchy.residueAtomSegments.offsets[eI];
|
||||
const rI = model.atomicHierarchy.residueAtomSegments.index[eI];
|
||||
const dbName = data.dbName[rI];
|
||||
if (!dbName) return;
|
||||
return `${dbName} ${data.accession[rI]} ${data.num[rI]} ${data.residue[rI]}`;
|
||||
@@ -59,10 +59,10 @@ namespace BestDatabaseSequenceMapping {
|
||||
if (!MmcifFormat.is(model.sourceData)) return;
|
||||
|
||||
const { atom_site } = model.sourceData.data.frame.categories;
|
||||
const db_name = atom_site.getField('db_name');
|
||||
const db_acc = atom_site.getField('db_acc');
|
||||
const db_num = atom_site.getField('db_num');
|
||||
const db_res = atom_site.getField('db_res');
|
||||
const db_name = atom_site.getField('pdbx_sifts_xref_db_name');
|
||||
const db_acc = atom_site.getField('pdbx_sifts_xref_db_acc');
|
||||
const db_num = atom_site.getField('pdbx_sifts_xref_db_num');
|
||||
const db_res = atom_site.getField('pdbx_sifts_xref_db_res');
|
||||
|
||||
if (!db_name || !db_acc || !db_num || !db_res) return;
|
||||
|
||||
@@ -77,17 +77,17 @@ namespace BestDatabaseSequenceMapping {
|
||||
const row = atomSourceIndex.value(residueOffsets[i]);
|
||||
|
||||
if (db_name.valueKind(row) !== Column.ValueKind.Present) {
|
||||
dbName[row] = '';
|
||||
accession[row] = '';
|
||||
num[row] = 0;
|
||||
residue[row] = '';
|
||||
dbName[i] = '';
|
||||
accession[i] = '';
|
||||
num[i] = 0;
|
||||
residue[i] = '';
|
||||
continue;
|
||||
}
|
||||
|
||||
dbName[row] = db_name.str(row);
|
||||
accession[row] = db_acc.str(row);
|
||||
num[row] = db_num.int(row);
|
||||
residue[row] = db_res.str(row);
|
||||
dbName[i] = db_name.str(row);
|
||||
accession[i] = db_acc.str(row);
|
||||
num[i] = db_num.int(row);
|
||||
residue[i] = db_res.str(row);
|
||||
}
|
||||
|
||||
return { dbName, accession, num, residue };
|
||||
|
||||
@@ -52,6 +52,10 @@ function isWithoutSymmetry(structure: Structure) {
|
||||
return structure.units.every(u => u.conformation.operator.isIdentity);
|
||||
}
|
||||
|
||||
function isWithoutOperator(structure: Structure) {
|
||||
return isWithoutSymmetry(structure) && structure.units.every(u => !u.conformation.operator.assembly && !u.conformation.operator.suffix);
|
||||
}
|
||||
|
||||
const Categories = [
|
||||
// Basics
|
||||
copy_mmCif_category('entry'),
|
||||
@@ -63,9 +67,9 @@ const Categories = [
|
||||
copy_mmCif_category('symmetry', isWithoutSymmetry),
|
||||
|
||||
// Assemblies
|
||||
copy_mmCif_category('pdbx_struct_assembly', isWithoutSymmetry),
|
||||
copy_mmCif_category('pdbx_struct_assembly_gen', isWithoutSymmetry),
|
||||
copy_mmCif_category('pdbx_struct_oper_list', isWithoutSymmetry),
|
||||
copy_mmCif_category('pdbx_struct_assembly', isWithoutOperator),
|
||||
copy_mmCif_category('pdbx_struct_assembly_gen', isWithoutOperator),
|
||||
copy_mmCif_category('pdbx_struct_oper_list', isWithoutOperator),
|
||||
|
||||
// Secondary structure
|
||||
_struct_conf,
|
||||
@@ -250,10 +254,10 @@ function encode_mmCIF_categories_copyAll(encoder: CifWriter.Encoder, ctx: CifExp
|
||||
}
|
||||
|
||||
|
||||
function to_mmCIF(name: string, structure: Structure, asBinary = false) {
|
||||
function to_mmCIF(name: string, structure: Structure, asBinary = false, params?: encode_mmCIF_categories_Params) {
|
||||
const enc = CifWriter.createEncoder({ binary: asBinary });
|
||||
enc.startDataBlock(name);
|
||||
encode_mmCIF_categories(enc, structure);
|
||||
encode_mmCIF_categories(enc, structure, params);
|
||||
return enc.getData();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
@@ -63,6 +63,28 @@ export interface CoarseHierarchy {
|
||||
gaussians: CoarseElements
|
||||
}
|
||||
|
||||
const EmptyCoarseElements: CoarseElements = {
|
||||
chainKey: [],
|
||||
entityKey: [],
|
||||
findSequenceKey: () => -1 as ElementIndex,
|
||||
findChainKey: () => -1 as ChainIndex,
|
||||
getEntityFromChain: () => -1 as EntityIndex,
|
||||
|
||||
count: 0,
|
||||
entity_id: Column.Undefined(0, Column.Schema.str),
|
||||
asym_id: Column.Undefined(0, Column.Schema.str),
|
||||
seq_id_begin: Column.Undefined(0, Column.Schema.int),
|
||||
seq_id_end: Column.Undefined(0, Column.Schema.int),
|
||||
chainElementSegments: Segmentation.create([]),
|
||||
|
||||
polymerRanges: SortedRanges.ofSortedRanges([]),
|
||||
gapRanges: SortedRanges.ofSortedRanges([]),
|
||||
};
|
||||
|
||||
export namespace CoarseHierarchy {
|
||||
export const Empty: CoarseHierarchy = { isDefined: false } as any;
|
||||
export const Empty: CoarseHierarchy = {
|
||||
isDefined: false,
|
||||
spheres: EmptyCoarseElements,
|
||||
gaussians: EmptyCoarseElements
|
||||
};
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export const EntitySubtype = Column.Schema.Aliased<EntitySubtype>(Column.Schema.
|
||||
export interface Entities {
|
||||
data: mmCIF_Database['entity'],
|
||||
subtype: Column<EntitySubtype>,
|
||||
prd_id: Column<string>,
|
||||
prd_id?: Column<string>,
|
||||
getEntityIndex(id: string): EntityIndex
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2017-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
@@ -497,7 +497,9 @@ export namespace Loci {
|
||||
if (!elementIndices) continue;
|
||||
|
||||
const indices = getUnitIndices(unit.elements, elementIndices);
|
||||
elements[elements.length] = { unit, indices };
|
||||
if (OrderedSet.size(indices)) {
|
||||
elements[elements.length] = { unit, indices };
|
||||
}
|
||||
}
|
||||
|
||||
return Loci(loci.structure, elements);
|
||||
|
||||
@@ -126,6 +126,7 @@ const coarse = {
|
||||
z: atom.z,
|
||||
|
||||
asym_id: p(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.asym_id.value(l.element)),
|
||||
entity_id: p(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.entity_id.value(l.element)),
|
||||
seq_id_begin: p(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.seq_id_begin.value(l.element)),
|
||||
seq_id_end: p(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.seq_id_end.value(l.element)),
|
||||
|
||||
@@ -162,7 +163,7 @@ const entity = {
|
||||
pdbx_ec: p(l => l.unit.model.entities.data.pdbx_ec.value(eK(l))),
|
||||
|
||||
subtype: p(l => l.unit.model.entities.subtype.value(eK(l))),
|
||||
prd_id: p(l => l.unit.model.entities.prd_id.value(eK(l))),
|
||||
prd_id: p(l => l.unit.model.entities.prd_id?.value(eK(l)) ?? ''),
|
||||
};
|
||||
|
||||
const _emptyList: any[] = [];
|
||||
|
||||
@@ -184,16 +184,13 @@ function getOperatorsForRange(symmetry: Symmetry, ijkMin: Vec3, ijkMax: Vec3, mo
|
||||
operators[0] = Spacegroup.getSymmetryOperator(spacegroup, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
const { toFractional } = spacegroup.cell;
|
||||
const ref = Vec3.transformMat4(Vec3(), modelCenter, toFractional);
|
||||
|
||||
for (let op = 0; op < spacegroup.operators.length; op++) {
|
||||
for (let i = ijkMin[0]; i <= ijkMax[0]; i++) {
|
||||
for (let j = ijkMin[1]; j <= ijkMax[1]; j++) {
|
||||
for (let k = ijkMin[2]; k <= ijkMax[2]; k++) {
|
||||
// check if we have added identity as the 1st operator.
|
||||
if (!ncsCount && op === 0 && i === 0 && j === 0 && k === 0) continue;
|
||||
operators.push(...getOperatorsForIndex(symmetry, op, i, j, k, ref));
|
||||
operators.push(...getOperatorsForIndex(symmetry, op, i, j, k, modelCenter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { Segmentation } from '../../../../mol-data/int';
|
||||
import { Mat4 } from '../../../../mol-math/linear-algebra';
|
||||
import { MinimizeRmsd } from '../../../../mol-math/linear-algebra/3d/minimize-rmsd';
|
||||
import { BestDatabaseSequenceMapping } from '../../../../mol-model-props/sequence/best-database-mapping';
|
||||
import { ElementIndex } from '../../model/indexing';
|
||||
@@ -33,6 +34,7 @@ export function alignAndSuperposeWithBestDatabaseMapping(structures: Structure[]
|
||||
for (const p of pairs) {
|
||||
const [a, b] = getPositionTables(index, p.i, p.j, p.count);
|
||||
const transform = MinimizeRmsd.compute({ a, b });
|
||||
console.log(Mat4.makeTable(transform.bTransform), transform.rmsd);
|
||||
ret.push({ transform, pivot: p.i, other: p.j });
|
||||
}
|
||||
|
||||
@@ -51,6 +53,8 @@ function getPositionTables(index: IndexEntry[], pivot: number, other: number, N:
|
||||
|
||||
const l = Math.min(a[2] - a[1], b[2] - b[1]);
|
||||
|
||||
// TODO: allow to use just backbone atoms?
|
||||
// TODO: check if residue types match?
|
||||
for (let i = 0; i < l; i++) {
|
||||
let eI = (a[1] + i) as ElementIndex;
|
||||
xs.x[o] = a[0].conformation.x(eI);
|
||||
@@ -122,7 +126,6 @@ function buildIndex(structure: Structure, index: Map<string, IndexEntry>, sI: nu
|
||||
if (unit.kind !== Unit.Kind.Atomic) continue;
|
||||
|
||||
const { elements, model } = unit;
|
||||
const { offsets: residueOffset } = model.atomicHierarchy.residueAtomSegments;
|
||||
|
||||
const map = BestDatabaseSequenceMapping.Provider.get(model).value;
|
||||
if (!map) return;
|
||||
@@ -137,23 +140,27 @@ function buildIndex(structure: Structure, index: Map<string, IndexEntry>, sI: nu
|
||||
residuesIt.setSegment(chainSegment);
|
||||
while (residuesIt.hasNext) {
|
||||
const residueSegment = residuesIt.move();
|
||||
const eI = elements[residueSegment.start];
|
||||
const rI = residueOffset[eI];
|
||||
const rI = residueSegment.index;
|
||||
|
||||
if (!dbName[rI]) continue;
|
||||
|
||||
const start = elements[residueSegment.start];
|
||||
const end = elements[residueSegment.end - 1] + 1 as ElementIndex;
|
||||
|
||||
const key = `${dbName[rI]}-${accession[rI]}-${num[rI]}`;
|
||||
|
||||
if (!index.has(key)) {
|
||||
index.set(key, { key, pivots: { [sI]: [unit, eI, elements[residueSegment.end]] } });
|
||||
index.set(key, { key, pivots: { [sI]: [unit, start, end] } });
|
||||
} else {
|
||||
const entry = index.get(key)!;
|
||||
|
||||
if (!entry.pivots[sI]) {
|
||||
entry.pivots[sI] = [unit, eI, elements[residueSegment.end]];
|
||||
entry.pivots[sI] = [unit, start, end];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(index);
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import { ModelFormat } from '../../mol-model-formats/format';
|
||||
import { CustomProperties } from '../custom-property';
|
||||
import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { toPrecision } from '../../mol-util/number';
|
||||
import { DscifFormat } from '../../mol-model-formats/volume/density-server';
|
||||
|
||||
export interface Volume {
|
||||
readonly label?: string
|
||||
@@ -84,6 +85,23 @@ export namespace Volume {
|
||||
}
|
||||
}
|
||||
|
||||
// Converts iso value to relative if using downsample VolumeServer data
|
||||
export function adjustedIsoValue(volume: Volume, value: number, kind: 'absolute' | 'relative') {
|
||||
if (kind === 'relative') return IsoValue.relative(value);
|
||||
|
||||
const absolute = IsoValue.absolute(value);
|
||||
if (DscifFormat.is(volume.sourceData)) {
|
||||
const stats = {
|
||||
min: volume.sourceData.data.volume_data_3d_info.min_source.value(0),
|
||||
max: volume.sourceData.data.volume_data_3d_info.max_source.value(0),
|
||||
mean: volume.sourceData.data.volume_data_3d_info.mean_source.value(0),
|
||||
sigma: volume.sourceData.data.volume_data_3d_info.sigma_source.value(0),
|
||||
};
|
||||
return Volume.IsoValue.toRelative(absolute, stats);
|
||||
}
|
||||
return absolute;
|
||||
}
|
||||
|
||||
const defaultStats: Grid['stats'] = { min: -1, max: 1, mean: 0, sigma: 0.1 };
|
||||
export function createIsoValueParam(defaultValue: Volume.IsoValue, stats?: Grid['stats']) {
|
||||
const sts = stats || defaultStats;
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import { StateAction } from '../../mol-state';
|
||||
import { Task } from '../../mol-task';
|
||||
import { Asset } from '../../mol-util/assets';
|
||||
import { getFileInfo } from '../../mol-util/file-info';
|
||||
import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { unzip } from '../../mol-util/zip/zip';
|
||||
import { PluginStateObject } from '../objects';
|
||||
|
||||
export const OpenFiles = StateAction.build({
|
||||
@@ -33,24 +35,37 @@ export const OpenFiles = StateAction.build({
|
||||
plugin.log.error('No file(s) selected');
|
||||
return;
|
||||
}
|
||||
|
||||
const processFile = async (file: Asset.File) => {
|
||||
const info = getFileInfo(file.file!);
|
||||
const isBinary = plugin.dataFormats.binaryExtensions.has(info.ext);
|
||||
const { data } = await plugin.builders.data.readFile({ file, isBinary });
|
||||
const provider = params.format.name === 'auto'
|
||||
? plugin.dataFormats.auto(info, data.cell?.obj!)
|
||||
: plugin.dataFormats.get(params.format.params);
|
||||
|
||||
if (!provider) {
|
||||
plugin.log.warn(`OpenFiles: could not find data provider for '${info.name}.${info.ext}'`);
|
||||
return;
|
||||
}
|
||||
|
||||
// need to await so that the enclosing Task finishes after the update is done.
|
||||
const parsed = await provider.parse(plugin, data);
|
||||
if (params.visuals) {
|
||||
await provider.visuals?.(plugin, parsed);
|
||||
}
|
||||
};
|
||||
|
||||
for (const file of params.files) {
|
||||
try {
|
||||
const info = getFileInfo(file.file!);
|
||||
const isBinary = plugin.dataFormats.binaryExtensions.has(info.ext);
|
||||
const { data } = await plugin.builders.data.readFile({ file, isBinary });
|
||||
const provider = params.format.name === 'auto'
|
||||
? plugin.dataFormats.auto(info, data.cell?.obj!)
|
||||
: plugin.dataFormats.get(params.format.params);
|
||||
|
||||
if (!provider) {
|
||||
plugin.log.warn(`OpenFiles: could not find data provider for '${info.name}.${info.ext}'`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// need to await so that the enclosing Task finishes after the update is done.
|
||||
const parsed = await provider.parse(plugin, data);
|
||||
if (params.visuals) {
|
||||
await provider.visuals?.(plugin, parsed);
|
||||
if (file.file && file.name.toLowerCase().endsWith('.zip')) {
|
||||
const zippedFiles = await unzip(taskCtx, await file.file.arrayBuffer());
|
||||
for (const [fn, filedata] of Object.entries(zippedFiles)) {
|
||||
const asset = Asset.File(new File([filedata as Uint8Array], fn));
|
||||
await processFile(asset);
|
||||
}
|
||||
} else {
|
||||
await processFile(file);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
@@ -75,8 +75,8 @@ const DownloadDensity = StateAction.build({
|
||||
case 'pdb-xray':
|
||||
downloadParams = src.params.provider.server === 'pdbe' ? {
|
||||
url: Asset.Url(src.params.type === '2fofc'
|
||||
? `http://www.ebi.ac.uk/pdbe/coordinates/files/${src.params.provider.id.toLowerCase()}.ccp4`
|
||||
: `http://www.ebi.ac.uk/pdbe/coordinates/files/${src.params.provider.id.toLowerCase()}_diff.ccp4`),
|
||||
? `https://www.ebi.ac.uk/pdbe/coordinates/files/${src.params.provider.id.toLowerCase()}.ccp4`
|
||||
: `https://www.ebi.ac.uk/pdbe/coordinates/files/${src.params.provider.id.toLowerCase()}_diff.ccp4`),
|
||||
isBinary: true,
|
||||
label: `PDBe X-ray map: ${src.params.provider.id}`
|
||||
} : {
|
||||
|
||||
62
src/mol-plugin-state/animation/built-in/camera-rock.ts
Normal file
62
src/mol-plugin-state/animation/built-in/camera-rock.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Copyright (c) 2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
import { Camera } from '../../../mol-canvas3d/camera';
|
||||
import { clamp } from '../../../mol-math/interpolate';
|
||||
import { Quat } from '../../../mol-math/linear-algebra/3d/quat';
|
||||
import { Vec3 } from '../../../mol-math/linear-algebra/3d/vec3';
|
||||
import { degToRad } from '../../../mol-math/misc';
|
||||
import { ParamDefinition as PD } from '../../../mol-util/param-definition';
|
||||
import { PluginStateAnimation } from '../model';
|
||||
|
||||
const _dir = Vec3(), _axis = Vec3(), _rot = Quat();
|
||||
|
||||
type State = { snapshot: Camera.Snapshot };
|
||||
|
||||
export const AnimateCameraRock = PluginStateAnimation.create({
|
||||
name: 'built-in.animate-camera-rock',
|
||||
display: { name: 'Camera Rock', description: 'Rock the 3D scene around the x-axis in view space' },
|
||||
isExportable: true,
|
||||
params: () => ({
|
||||
durationInMs: PD.Numeric(4000, { min: 100, max: 20000, step: 100 }),
|
||||
speed: PD.Numeric(1, { min: 1, max: 10, step: 1 }, { description: 'How many times to rock from side to side.' }),
|
||||
angle: PD.Numeric(10, { min: 0, max: 180, step: 1 }, { description: 'How many degrees to rotate in each direction.' }),
|
||||
}),
|
||||
initialState: (p, ctx) => ({ snapshot: ctx.canvas3d!.camera.getSnapshot() }) as State,
|
||||
getDuration: p => ({ kind: 'fixed', durationMs: p.durationInMs }),
|
||||
teardown: (_, state: State, ctx) => {
|
||||
ctx.canvas3d?.requestCameraReset({ snapshot: state.snapshot, durationMs: 0 });
|
||||
},
|
||||
|
||||
async apply(animState: State, t, ctx) {
|
||||
if (t.current === 0) {
|
||||
return { kind: 'next', state: animState };
|
||||
}
|
||||
|
||||
const snapshot = animState.snapshot;
|
||||
if (snapshot.radiusMax < 0.0001) {
|
||||
return { kind: 'finished' };
|
||||
}
|
||||
|
||||
const phase = t.animation
|
||||
? t.animation?.currentFrame / (t.animation.frameCount + 1)
|
||||
: clamp(t.current / ctx.params.durationInMs, 0, 1);
|
||||
const angle = Math.sin(phase * ctx.params.speed * Math.PI * 2) * degToRad(ctx.params.angle);
|
||||
|
||||
Vec3.sub(_dir, snapshot.position, snapshot.target);
|
||||
Vec3.normalize(_axis, snapshot.up);
|
||||
Quat.setAxisAngle(_rot, _axis, angle);
|
||||
Vec3.transformQuat(_dir, _dir, _rot);
|
||||
const position = Vec3.add(Vec3(), snapshot.target, _dir);
|
||||
ctx.plugin.canvas3d?.requestCameraReset({ snapshot: { ...snapshot, position }, durationMs: 0 });
|
||||
|
||||
if (phase >= 0.99999) {
|
||||
return { kind: 'finished' };
|
||||
}
|
||||
|
||||
return { kind: 'next', state: animState };
|
||||
}
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
*/
|
||||
@@ -17,11 +17,11 @@ type State = { snapshot: Camera.Snapshot };
|
||||
|
||||
export const AnimateCameraSpin = PluginStateAnimation.create({
|
||||
name: 'built-in.animate-camera-spin',
|
||||
display: { name: 'Camera Spin' },
|
||||
display: { name: 'Camera Spin', description: 'Spin the 3D scene around the x-axis in view space' },
|
||||
isExportable: true,
|
||||
params: () => ({
|
||||
durationInMs: PD.Numeric(4000, { min: 100, max: 20000, step: 100 }),
|
||||
speed: PD.Numeric(1, { min: 1, max: 10, step: 1 }, { description: 'How many times to spin in the specified dutation.' }),
|
||||
speed: PD.Numeric(1, { min: 1, max: 10, step: 1 }, { description: 'How many times to spin in the specified duration.' }),
|
||||
direction: PD.Select<'cw' | 'ccw'>('cw', [['cw', 'Clockwise'], ['ccw', 'Counter Clockwise']], { cycle: true })
|
||||
}),
|
||||
initialState: (_, ctx) => ({ snapshot: ctx.canvas3d?.camera.getSnapshot()! }) as State,
|
||||
@@ -39,13 +39,9 @@ export const AnimateCameraSpin = PluginStateAnimation.create({
|
||||
return { kind: 'finished' };
|
||||
}
|
||||
|
||||
const phase = clamp(t.current / ctx.params.durationInMs, 0, 1);
|
||||
|
||||
if (phase >= 0.99999) {
|
||||
ctx.plugin.canvas3d?.requestCameraReset({ snapshot, durationMs: 0 });
|
||||
return { kind: 'finished' };
|
||||
}
|
||||
|
||||
const phase = t.animation
|
||||
? t.animation?.currentFrame / (t.animation.frameCount + 1)
|
||||
: clamp(t.current / ctx.params.durationInMs, 0, 1);
|
||||
const angle = 2 * Math.PI * phase * ctx.params.speed * (ctx.params.direction === 'ccw' ? -1 : 1);
|
||||
|
||||
Vec3.sub(_dir, snapshot.position, snapshot.target);
|
||||
@@ -55,6 +51,10 @@ export const AnimateCameraSpin = PluginStateAnimation.create({
|
||||
const position = Vec3.add(Vec3(), snapshot.target, _dir);
|
||||
ctx.plugin.canvas3d?.requestCameraReset({ snapshot: { ...snapshot, position }, durationMs: 0 });
|
||||
|
||||
if (phase >= 0.99999) {
|
||||
return { kind: 'finished' };
|
||||
}
|
||||
|
||||
return { kind: 'next', state: animState };
|
||||
}
|
||||
});
|
||||
@@ -51,7 +51,8 @@ namespace PluginStateAnimation {
|
||||
|
||||
export interface Time {
|
||||
lastApplied: number,
|
||||
current: number
|
||||
current: number,
|
||||
animation?: { currentFrame: number, frameCount: number }
|
||||
}
|
||||
|
||||
export type ApplyResult<S> = { kind: 'finished' } | { kind: 'skip' } | { kind: 'next', state: S }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
@@ -24,6 +24,8 @@ import { IndexPairBonds } from '../../../mol-model-formats/structure/property/bo
|
||||
import { StructConn } from '../../../mol-model-formats/structure/property/bonds/struct_conn';
|
||||
import { StructureRepresentationRegistry } from '../../../mol-repr/structure/registry';
|
||||
import { assertUnreachable } from '../../../mol-util/type-helpers';
|
||||
import { Color } from '../../../mol-util/color';
|
||||
import { PostprocessingParams } from '../../../mol-canvas3d/passes/postprocessing';
|
||||
|
||||
export interface StructureRepresentationPresetProvider<P = any, S extends _Result = _Result> extends PresetProvider<PluginStateObject.Molecule.Structure, P, S> { }
|
||||
export function StructureRepresentationPresetProvider<P, S extends _Result>(repr: StructureRepresentationPresetProvider<P, S>) { return repr; }
|
||||
@@ -98,6 +100,15 @@ type CommonParams = StructureRepresentationPresetProvider.CommonParams
|
||||
const reprBuilder = StructureRepresentationPresetProvider.reprBuilder;
|
||||
const updateFocusRepr = StructureRepresentationPresetProvider.updateFocusRepr;
|
||||
|
||||
function resetPostprocessingProps(plugin: PluginContext) {
|
||||
if (plugin.canvas3d) {
|
||||
const p = PD.getDefaultValues(PostprocessingParams);
|
||||
plugin.canvas3d.setProps({
|
||||
postprocessing: { outline: p.outline, occlusion: p.occlusion }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const auto = StructureRepresentationPresetProvider({
|
||||
id: 'preset-structure-representation-auto',
|
||||
display: {
|
||||
@@ -137,6 +148,7 @@ const empty = StructureRepresentationPresetProvider({
|
||||
id: 'preset-structure-representation-empty',
|
||||
display: { name: 'Empty', description: 'Removes all existing representations.' },
|
||||
async apply(ref, params, plugin) {
|
||||
resetPostprocessingProps(plugin);
|
||||
return { };
|
||||
}
|
||||
});
|
||||
@@ -191,6 +203,8 @@ const polymerAndLigand = StructureRepresentationPresetProvider({
|
||||
await update.commit({ revertOnError: false });
|
||||
await updateFocusRepr(plugin, structure, params.theme?.focus?.name, params.theme?.focus?.params);
|
||||
|
||||
resetPostprocessingProps(plugin);
|
||||
|
||||
return { components, representations };
|
||||
}
|
||||
});
|
||||
@@ -230,6 +244,8 @@ const proteinAndNucleic = StructureRepresentationPresetProvider({
|
||||
await update.commit({ revertOnError: true });
|
||||
await updateFocusRepr(plugin, structure, params.theme?.focus?.name, params.theme?.focus?.params);
|
||||
|
||||
resetPostprocessingProps(plugin);
|
||||
|
||||
return { components, representations };
|
||||
}
|
||||
});
|
||||
@@ -282,6 +298,8 @@ const coarseSurface = StructureRepresentationPresetProvider({
|
||||
await update.commit({ revertOnError: true });
|
||||
await updateFocusRepr(plugin, structure, params.theme?.focus?.name, params.theme?.focus?.params);
|
||||
|
||||
resetPostprocessingProps(plugin);
|
||||
|
||||
return { components, representations };
|
||||
}
|
||||
});
|
||||
@@ -315,6 +333,8 @@ const polymerCartoon = StructureRepresentationPresetProvider({
|
||||
await update.commit({ revertOnError: true });
|
||||
await updateFocusRepr(plugin, structure, params.theme?.focus?.name, params.theme?.focus?.params);
|
||||
|
||||
resetPostprocessingProps(plugin);
|
||||
|
||||
return { components, representations };
|
||||
}
|
||||
});
|
||||
@@ -381,6 +401,56 @@ const atomicDetail = StructureRepresentationPresetProvider({
|
||||
await update.commit({ revertOnError: true });
|
||||
await updateFocusRepr(plugin, structure, params.theme?.focus?.name ?? color, params.theme?.focus?.params ?? colorParams);
|
||||
|
||||
resetPostprocessingProps(plugin);
|
||||
|
||||
return { components, representations };
|
||||
}
|
||||
});
|
||||
|
||||
const illustrative = StructureRepresentationPresetProvider({
|
||||
id: 'preset-structure-representation-illustrative',
|
||||
display: {
|
||||
name: 'Illustrative', group: 'Miscellaneous',
|
||||
description: '...'
|
||||
},
|
||||
params: () => ({
|
||||
...CommonParams,
|
||||
showCarbohydrateSymbol: PD.Boolean(false)
|
||||
}),
|
||||
async apply(ref, params, plugin) {
|
||||
const structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref);
|
||||
if (!structureCell) return {};
|
||||
|
||||
const components = {
|
||||
all: await presetStaticComponent(plugin, structureCell, 'all'),
|
||||
branched: undefined
|
||||
};
|
||||
|
||||
const structure = structureCell.obj!.data;
|
||||
|
||||
const { update, builder, typeParams, color } = reprBuilder(plugin, params, structure);
|
||||
|
||||
const representations = {
|
||||
all: builder.buildRepresentation(update, components.all, { type: 'spacefill', typeParams: { ...typeParams, ignoreLight: true }, color: 'illustrative' }, { tag: 'all' }),
|
||||
};
|
||||
await update.commit({ revertOnError: true });
|
||||
await updateFocusRepr(plugin, structure, params.theme?.focus?.name ?? color, params.theme?.focus?.params);
|
||||
|
||||
if (plugin.canvas3d) {
|
||||
plugin.canvas3d.setProps({
|
||||
postprocessing: {
|
||||
outline: {
|
||||
name: 'on',
|
||||
params: { scale: 1, color: Color(0x000000), threshold: 0.25 }
|
||||
},
|
||||
occlusion: {
|
||||
name: 'on',
|
||||
params: { bias: 0.9, blurKernelSize: 15, radius: 5, samples: 32 }
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return { components, representations };
|
||||
}
|
||||
});
|
||||
@@ -400,6 +470,7 @@ export const PresetStructureRepresentations = {
|
||||
'polymer-cartoon': polymerCartoon,
|
||||
'polymer-and-ligand': polymerAndLigand,
|
||||
'protein-and-nucleic': proteinAndNucleic,
|
||||
'coarse-surface': coarseSurface
|
||||
'coarse-surface': coarseSurface,
|
||||
'illustrative': illustrative,
|
||||
};
|
||||
export type PresetStructureRepresentations = typeof PresetStructureRepresentations;
|
||||
@@ -18,7 +18,6 @@ import { objectForEach } from '../../mol-util/object';
|
||||
import { RecommendedIsoValue } from '../../mol-model-formats/volume/property';
|
||||
import { getContourLevelEmdb } from '../../mol-plugin/behavior/dynamic/volume-streaming/util';
|
||||
import { Task } from '../../mol-task';
|
||||
import { DscifFormat } from '../../mol-model-formats/volume/density-server';
|
||||
|
||||
export const VolumeFormatCategory = 'Volume';
|
||||
type Params = { entryId?: string };
|
||||
@@ -42,19 +41,9 @@ async function tryObtainRecommendedIsoValue(plugin: PluginContext, volume?: Volu
|
||||
function tryGetRecomendedIsoValue(volume: Volume) {
|
||||
const recommendedIsoValue = RecommendedIsoValue.Provider.get(volume);
|
||||
if (!recommendedIsoValue) return;
|
||||
|
||||
if (recommendedIsoValue.kind === 'relative') return recommendedIsoValue;
|
||||
|
||||
let stats = volume.grid.stats;
|
||||
if (DscifFormat.is(volume.sourceData)) {
|
||||
stats = {
|
||||
min: volume.sourceData.data.volume_data_3d_info.min_source.value(0),
|
||||
max: volume.sourceData.data.volume_data_3d_info.max_source.value(0),
|
||||
mean: volume.sourceData.data.volume_data_3d_info.mean_source.value(0),
|
||||
sigma: volume.sourceData.data.volume_data_3d_info.sigma_source.value(0),
|
||||
};
|
||||
}
|
||||
return Volume.IsoValue.toRelative(recommendedIsoValue, stats);
|
||||
return Volume.adjustedIsoValue(volume, recommendedIsoValue.absoluteValue, 'absolute');
|
||||
}
|
||||
|
||||
async function defaultVisuals(plugin: PluginContext, data: { volume: StateObjectSelector<PluginStateObject.Volume.Data> }) {
|
||||
|
||||
@@ -99,12 +99,12 @@ class PluginAnimationManager extends StatefulPluginComponent<PluginAnimationMana
|
||||
await this.start();
|
||||
}
|
||||
|
||||
async tick(t: number, isSynchronous?: boolean) {
|
||||
async tick(t: number, isSynchronous?: boolean, animation?: PluginAnimationManager.AnimationInfo) {
|
||||
this.currentTime = t;
|
||||
if (this.isStopped) return;
|
||||
|
||||
if (isSynchronous) {
|
||||
await this.applyFrame();
|
||||
if (isSynchronous || animation) {
|
||||
await this.applyFrame(animation);
|
||||
} else {
|
||||
this.applyAsync();
|
||||
}
|
||||
@@ -165,12 +165,12 @@ class PluginAnimationManager extends StatefulPluginComponent<PluginAnimationMana
|
||||
}
|
||||
}
|
||||
|
||||
private async applyFrame() {
|
||||
private async applyFrame(animation?: PluginAnimationManager.AnimationInfo) {
|
||||
const t = this.currentTime;
|
||||
if (this._current.startedTime < 0) this._current.startedTime = t;
|
||||
const newState = await this._current.anim.apply(
|
||||
this._current.state,
|
||||
{ lastApplied: this._current.lastTime, current: t - this._current.startedTime },
|
||||
{ lastApplied: this._current.lastTime, current: t - this._current.startedTime, animation },
|
||||
{ params: this._current.paramValues, plugin: this.context });
|
||||
|
||||
if (newState.kind === 'finished') {
|
||||
@@ -228,6 +228,11 @@ class PluginAnimationManager extends StatefulPluginComponent<PluginAnimationMana
|
||||
}
|
||||
|
||||
namespace PluginAnimationManager {
|
||||
export interface AnimationInfo {
|
||||
currentFrame: number,
|
||||
frameCount: number
|
||||
}
|
||||
|
||||
export interface Current {
|
||||
anim: PluginStateAnimation
|
||||
params: PD.Params,
|
||||
|
||||
@@ -84,7 +84,7 @@ class PluginStateSnapshotManager extends StatefulPluginComponent<{
|
||||
const from = this.getIndex(e);
|
||||
let to = (from + dir) % len;
|
||||
if (to < 0) to += len;
|
||||
const f = this.state.entries.get(to);
|
||||
const f = this.state.entries.get(to)!;
|
||||
|
||||
const entries = this.state.entries.asMutable();
|
||||
entries.set(to, e);
|
||||
@@ -115,7 +115,7 @@ class PluginStateSnapshotManager extends StatefulPluginComponent<{
|
||||
if (!id) {
|
||||
if (len === 0) return void 0;
|
||||
const idx = dir === -1 ? len - 1 : 0;
|
||||
return this.state.entries.get(idx).snapshot.id;
|
||||
return this.state.entries.get(idx)!.snapshot.id;
|
||||
}
|
||||
|
||||
const e = this.getEntry(id);
|
||||
@@ -126,7 +126,7 @@ class PluginStateSnapshotManager extends StatefulPluginComponent<{
|
||||
idx = (idx + dir) % len;
|
||||
if (idx < 0) idx += len;
|
||||
|
||||
return this.state.entries.get(idx).snapshot.id;
|
||||
return this.state.entries.get(idx)!.snapshot.id;
|
||||
}
|
||||
|
||||
async setStateSnapshot(snapshot: PluginStateSnapshotManager.StateSnapshot): Promise<PluginState.Snapshot | undefined> {
|
||||
|
||||
@@ -918,7 +918,7 @@ async function attachModelProps(model: Model, ctx: PluginContext, taskCtx: Runti
|
||||
const propertyCtx = { runtime: taskCtx, assetManager: ctx.managers.asset };
|
||||
const { autoAttach, properties } = params;
|
||||
for (const name of Object.keys(properties)) {
|
||||
const property = ctx.customModelProperties.get(name);
|
||||
const property = ctx.customModelProperties.get(name)!;
|
||||
const props = properties[name];
|
||||
if (autoAttach.includes(name) || property.isHidden) {
|
||||
try {
|
||||
@@ -973,7 +973,7 @@ async function attachStructureProps(structure: Structure, ctx: PluginContext, ta
|
||||
const propertyCtx = { runtime: taskCtx, assetManager: ctx.managers.asset };
|
||||
const { autoAttach, properties } = params;
|
||||
for (const name of Object.keys(properties)) {
|
||||
const property = ctx.customStructureProperties.get(name);
|
||||
const property = ctx.customStructureProperties.get(name)!;
|
||||
const props = properties[name];
|
||||
if (autoAttach.includes(name) || property.isHidden) {
|
||||
try {
|
||||
|
||||
@@ -125,7 +125,7 @@ export class StateSnapshotViewportControls extends PluginUIComponent<{}, { isBus
|
||||
} else if (e.keyCode === 38 || e.key === 'ArrowUp') {
|
||||
if (snapshots.state.isPlaying) snapshots.stop();
|
||||
if (snapshots.state.entries.size === 0) return;
|
||||
const e = snapshots.state.entries.get(0);
|
||||
const e = snapshots.state.entries.get(0)!;
|
||||
this.update(e.snapshot.id);
|
||||
} else if (e.keyCode === 39 || e.key === 'ArrowRight') {
|
||||
if (snapshots.state.isPlaying) snapshots.stop();
|
||||
@@ -133,7 +133,7 @@ export class StateSnapshotViewportControls extends PluginUIComponent<{}, { isBus
|
||||
} else if (e.keyCode === 40 || e.key === 'ArrowDown') {
|
||||
if (snapshots.state.isPlaying) snapshots.stop();
|
||||
if (snapshots.state.entries.size === 0) return;
|
||||
const e = snapshots.state.entries.get(snapshots.state.entries.size - 1);
|
||||
const e = snapshots.state.entries.get(snapshots.state.entries.size - 1)!;
|
||||
this.update(e.snapshot.id);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -185,9 +185,9 @@ export class SuperpositionControls extends PurePluginUIComponent<{ }, Superposit
|
||||
rmsd += xform.transform.rmsd;
|
||||
}
|
||||
|
||||
rmsd /= transforms.length - 1;
|
||||
rmsd /= Math.max(transforms.length - 1, 1);
|
||||
|
||||
this.plugin.log.info(`Superposed ${input.length} structures with avg. RMSD ${rmsd.toFixed(2)}.`);
|
||||
this.plugin.log.info(`Superposed ${input.length} structures with avg. RMSD ${rmsd.toFixed(2)} Å.`);
|
||||
await new Promise(res => requestAnimationFrame(res));
|
||||
PluginCommands.Camera.Reset(this.plugin);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
@@ -46,10 +46,7 @@ const LayoutOptions = {
|
||||
type LayoutOptions = keyof typeof LayoutOptions
|
||||
|
||||
const SimpleSettingsParams = {
|
||||
spin: PD.Group({
|
||||
spin: Canvas3DParams.trackball.params.spin,
|
||||
speed: Canvas3DParams.trackball.params.spinSpeed
|
||||
}, { pivot: 'spin' }),
|
||||
animate: Canvas3DParams.trackball.params.animate,
|
||||
camera: Canvas3DParams.camera,
|
||||
background: PD.Group({
|
||||
color: PD.Color(Color(0xFCFBF9), { label: 'Background', description: 'Custom background color' }),
|
||||
@@ -96,7 +93,7 @@ const SimpleSettingsMapping = ParamMapping({
|
||||
|
||||
return {
|
||||
layout: props.layout,
|
||||
spin: { spin: !!canvas.trackball.spin, speed: canvas.trackball.spinSpeed },
|
||||
animate: canvas.trackball.animate,
|
||||
camera: canvas.camera,
|
||||
background: {
|
||||
color: renderer.backgroundColor,
|
||||
@@ -114,8 +111,7 @@ const SimpleSettingsMapping = ParamMapping({
|
||||
},
|
||||
update(s, props) {
|
||||
const canvas = props.canvas as Mutable<Canvas3DProps>;
|
||||
canvas.trackball.spin = s.spin.spin;
|
||||
canvas.trackball.spinSpeed = s.spin.speed;
|
||||
canvas.trackball.animate = s.animate;
|
||||
canvas.camera = s.camera;
|
||||
canvas.transparentBackground = s.background.transparent;
|
||||
canvas.renderer.backgroundColor = s.background.color;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
import { PluginContext } from './context';
|
||||
import { now } from '../mol-util/now';
|
||||
import { PluginAnimationManager } from '../mol-plugin-state/manager/animation';
|
||||
|
||||
export class PluginAnimationLoop {
|
||||
private currentFrame: any = void 0;
|
||||
@@ -15,8 +16,8 @@ export class PluginAnimationLoop {
|
||||
return this._isAnimating;
|
||||
}
|
||||
|
||||
async tick(t: number, options?: { isSynchronous?: boolean, manualDraw?: boolean }) {
|
||||
await this.plugin.managers.animation.tick(t, options?.isSynchronous);
|
||||
async tick(t: number, options?: { isSynchronous?: boolean, manualDraw?: boolean, animation?: PluginAnimationManager.AnimationInfo }) {
|
||||
await this.plugin.managers.animation.tick(t, options?.isSynchronous, options?.animation);
|
||||
this.plugin.canvas3d?.tick(t as now.Timestamp, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
@@ -212,11 +212,14 @@ export const DefaultLociLabelProvider = PluginBehavior.create({
|
||||
private f = {
|
||||
label: (loci: Loci) => {
|
||||
const label: string[] = [];
|
||||
if (StructureElement.Loci.is(loci) && loci.elements.length === 1) {
|
||||
const { unit: u } = loci.elements[0];
|
||||
const l = StructureElement.Location.create(loci.structure, u, u.elements[0]);
|
||||
const name = StructureProperties.entity.pdbx_description(l).join(', ');
|
||||
label.push(name);
|
||||
if (StructureElement.Loci.is(loci)) {
|
||||
const entityNames = new Set<string>();
|
||||
for (const { unit: u } of loci.elements) {
|
||||
const l = StructureElement.Location.create(loci.structure, u, u.elements[0]);
|
||||
const name = StructureProperties.entity.pdbx_description(l).join(', ');
|
||||
entityNames.add(name);
|
||||
}
|
||||
if (entityNames.size === 1) entityNames.forEach(name => label.push(name));
|
||||
}
|
||||
label.push(lociLabel(loci));
|
||||
return label.filter(l => !!l).join('</br>');
|
||||
|
||||
@@ -84,7 +84,7 @@ export function UpdateRepresentationVisibility(ctx: PluginContext) {
|
||||
}
|
||||
|
||||
function updateVisibility(cell: StateObjectCell, r: Representation<any>) {
|
||||
if (r.state.visible === cell.state.isHidden) {
|
||||
if (r.state.visible === !!cell.state.isHidden) {
|
||||
r.setState({ visible: !cell.state.isHidden });
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
@@ -23,6 +23,7 @@ import { StateTransforms } from '../mol-plugin-state/transforms';
|
||||
import { BoxifyVolumeStreaming, CreateVolumeStreamingBehavior, InitVolumeStreaming } from '../mol-plugin/behavior/dynamic/volume-streaming/transformers';
|
||||
import { AnimateStateInterpolation } from '../mol-plugin-state/animation/built-in/state-interpolation';
|
||||
import { AnimateStructureSpin } from '../mol-plugin-state/animation/built-in/spin-structure';
|
||||
import { AnimateCameraRock } from '../mol-plugin-state/animation/built-in/camera-rock';
|
||||
|
||||
export { PluginSpec };
|
||||
|
||||
@@ -131,6 +132,7 @@ export const DefaultPluginSpec = (): PluginSpec => ({
|
||||
animations: [
|
||||
AnimateModelIndex,
|
||||
AnimateCameraSpin,
|
||||
AnimateCameraRock,
|
||||
AnimateStateSnapshots,
|
||||
AnimateAssemblyUnwind,
|
||||
AnimateStructureSpin,
|
||||
|
||||
@@ -72,7 +72,7 @@ export class PluginToastManager extends StatefulPluginComponent<{
|
||||
|
||||
if (delay < 0) delay = 500;
|
||||
return <number><any>setTimeout(() => {
|
||||
const e = this.state.entries.get(id);
|
||||
const e = this.state.entries.get(id)!;
|
||||
e.timeout = void 0;
|
||||
this.hide(e);
|
||||
}, delay);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
@@ -10,9 +10,9 @@ import { ColorNames } from '../../../mol-util/color/names';
|
||||
import { Text } from '../../../mol-geo/geometry/text/text';
|
||||
|
||||
export const MeasurementRepresentationCommonTextParams = {
|
||||
customText: PD.Text('', { label: 'Text', description: 'Override the label with custom value.' }),
|
||||
customText: PD.Text('', { label: 'Text', description: 'Override the label with custom value.', isEssential: true }),
|
||||
textColor: PD.Color(ColorNames.black, { isEssential: true }),
|
||||
textSize: PD.Numeric(0.5, { min: 0.1, max: 5, step: 0.1 }, { isEssential: true }),
|
||||
textSize: PD.Numeric(0.5, { min: 0.1, max: 10, step: 0.1 }, { isEssential: true }),
|
||||
};
|
||||
|
||||
export const LociLabelTextParams = {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -101,6 +101,8 @@ function getLinkLoci(pickingId: PickingId, structure: Structure, id: number) {
|
||||
return EmptyLoci;
|
||||
}
|
||||
|
||||
const __linkIndicesSet = new Set<number>();
|
||||
|
||||
function eachCarbohydrateLink(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean) {
|
||||
let changed = false;
|
||||
if (!StructureElement.Loci.is(loci)) return false;
|
||||
@@ -110,11 +112,14 @@ function eachCarbohydrateLink(loci: Loci, structure: Structure, apply: (interval
|
||||
for (const { unit, indices } of loci.elements) {
|
||||
if (!Unit.isAtomic(unit)) continue;
|
||||
|
||||
__linkIndicesSet.clear();
|
||||
OrderedSet.forEach(indices, v => {
|
||||
// TODO avoid duplicate calls to apply
|
||||
const linkIndices = getLinkIndices(unit, unit.elements[v]);
|
||||
for (let i = 0, il = linkIndices.length; i < il; ++i) {
|
||||
if (apply(Interval.ofSingleton(linkIndices[i]))) changed = true;
|
||||
if (!__linkIndicesSet.has(linkIndices[i])) {
|
||||
__linkIndicesSet.add(linkIndices[i]);
|
||||
if (apply(Interval.ofSingleton(linkIndices[i]))) changed = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -29,8 +29,8 @@ import { getAltResidueLociFromId } from './util/common';
|
||||
import { BaseGeometry } from '../../../mol-geo/geometry/base';
|
||||
|
||||
const t = Mat4.identity();
|
||||
const sVec = Vec3.zero();
|
||||
const pd = Vec3.zero();
|
||||
const sVec = Vec3();
|
||||
const pd = Vec3();
|
||||
|
||||
const SideFactor = 2 * 0.806; // 0.806 == Math.cos(Math.PI / 4)
|
||||
|
||||
@@ -212,6 +212,8 @@ function getCarbohydrateLoci(pickingId: PickingId, structure: Structure, id: num
|
||||
return EmptyLoci;
|
||||
}
|
||||
|
||||
const __elementIndicesSet = new Set<number>();
|
||||
|
||||
/** For each carbohydrate (usually a monosaccharide) when all its residue's elements are in a loci. */
|
||||
function eachCarbohydrate(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean) {
|
||||
const { getElementIndices } = structure.carbohydrates;
|
||||
@@ -222,11 +224,14 @@ function eachCarbohydrate(loci: Loci, structure: Structure, apply: (interval: In
|
||||
for (const { unit, indices } of loci.elements) {
|
||||
if (!Unit.isAtomic(unit)) continue;
|
||||
|
||||
__elementIndicesSet.clear();
|
||||
OrderedSet.forEach(indices, v => {
|
||||
// TODO avoid duplicate calls to apply
|
||||
const elementIndices = getElementIndices(unit, unit.elements[v]);
|
||||
for (let i = 0, il = elementIndices.length; i < il; ++i) {
|
||||
if (apply(Interval.ofSingleton(elementIndices[i] * 2))) changed = true;
|
||||
if (!__elementIndicesSet.has(elementIndices[i])) {
|
||||
__elementIndicesSet.add(elementIndices[i]);
|
||||
if (apply(Interval.ofSingleton(elementIndices[i] * 2))) changed = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -123,6 +123,8 @@ function getTerminalLinkLoci(pickingId: PickingId, structure: Structure, id: num
|
||||
return EmptyLoci;
|
||||
}
|
||||
|
||||
const __linkIndicesSet = new Set<number>();
|
||||
|
||||
function eachTerminalLink(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean) {
|
||||
let changed = false;
|
||||
if (!StructureElement.Loci.is(loci)) return false;
|
||||
@@ -132,11 +134,14 @@ function eachTerminalLink(loci: Loci, structure: Structure, apply: (interval: In
|
||||
for (const { unit, indices } of loci.elements) {
|
||||
if (!Unit.isAtomic(unit)) continue;
|
||||
|
||||
__linkIndicesSet.clear();
|
||||
OrderedSet.forEach(indices, v => {
|
||||
// TODO avoid duplicate calls to apply
|
||||
const linkIndices = getTerminalLinkIndices(unit, unit.elements[v]);
|
||||
for (let i = 0, il = linkIndices.length; i < il; ++i) {
|
||||
if (apply(Interval.ofSingleton(linkIndices[i]))) changed = true;
|
||||
if (!__linkIndicesSet.has(linkIndices[i])) {
|
||||
__linkIndicesSet.add(linkIndices[i]);
|
||||
if (apply(Interval.ofSingleton(linkIndices[i]))) changed = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -57,7 +57,7 @@ async function createMolecularSurfaceMesh(ctx: VisualContext, unit: Unit, struct
|
||||
Mesh.transform(surface, transform);
|
||||
if (ctx.webgl && !ctx.webgl.isWebGL2) Mesh.uniformTriangleGroup(surface);
|
||||
|
||||
const sphere = Sphere3D.expand(Sphere3D(), unit.boundary.sphere, props.probeRadius + getUnitExtraRadius(unit));
|
||||
const sphere = Sphere3D.expand(Sphere3D(), unit.boundary.sphere, getUnitExtraRadius(unit));
|
||||
surface.setBoundingSphere(sphere);
|
||||
(surface.meta as MolecularSurfaceMeta).resolution = resolution;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -224,6 +224,8 @@ export function getInterBondLoci(pickingId: PickingId, structure: Structure, id:
|
||||
return EmptyLoci;
|
||||
}
|
||||
|
||||
const __unitMap = new Map<number, OrderedSet<StructureElement.UnitIndex>>();
|
||||
|
||||
export function eachInterBond(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean, isMarking: boolean) {
|
||||
let changed = false;
|
||||
if (Bond.isLoci(loci)) {
|
||||
@@ -238,14 +240,13 @@ export function eachInterBond(loci: Loci, structure: Structure, apply: (interval
|
||||
if (!Structure.areEquivalent(loci.structure, structure)) return false;
|
||||
if (isMarking && loci.elements.length === 1) return false; // only a single unit
|
||||
|
||||
const map = new Map<number, OrderedSet<StructureElement.UnitIndex>>();
|
||||
for (const e of loci.elements) map.set(e.unit.id, e.indices);
|
||||
for (const e of loci.elements) __unitMap.set(e.unit.id, e.indices);
|
||||
|
||||
for (const e of loci.elements) {
|
||||
const { unit } = e;
|
||||
if (!Unit.isAtomic(unit)) continue;
|
||||
structure.interUnitBonds.getConnectedUnits(unit.id).forEach(b => {
|
||||
const otherLociIndices = map.get(b.unitB);
|
||||
const otherLociIndices = __unitMap.get(b.unitB);
|
||||
if (!isMarking || otherLociIndices) {
|
||||
OrderedSet.forEach(e.indices, v => {
|
||||
if (!b.connectedIndices.includes(v)) return;
|
||||
@@ -259,6 +260,8 @@ export function eachInterBond(loci: Loci, structure: Structure, apply: (interval
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
__unitMap.clear();
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -88,6 +88,7 @@ namespace Visual {
|
||||
const currentStatus = markerStatus.ref.value as MarkerInfo['status'];
|
||||
|
||||
if (!isEveryLoci(loci)) {
|
||||
// assume that all interval are non-overlapping
|
||||
let intervalSize = 0;
|
||||
lociApply(loci, interval => {
|
||||
intervalSize += Interval.size(interval);
|
||||
|
||||
@@ -76,14 +76,23 @@ namespace Transform {
|
||||
const s = (b as any)[k], t = (a as any)[k];
|
||||
if (!!s === !!t) continue;
|
||||
changed = true;
|
||||
(a as any)[k] = s;
|
||||
if (s !== void 0) {
|
||||
(a as any)[k] = s;
|
||||
} else {
|
||||
delete (a as any)[k];
|
||||
}
|
||||
}
|
||||
for (const k of Object.keys(a)) {
|
||||
const s = (b as any)[k], t = (a as any)[k];
|
||||
if (!!s === !!t) continue;
|
||||
changed = true;
|
||||
(a as any)[k] = s;
|
||||
if (s !== void 0) {
|
||||
(a as any)[k] = s;
|
||||
} else {
|
||||
delete (a as any)[k];
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,19 +34,38 @@ namespace StateTree {
|
||||
readonly forEach: OrderedSet<Ref>['forEach'],
|
||||
readonly map: OrderedSet<Ref>['map'],
|
||||
toArray(): Ref[],
|
||||
first(): Ref
|
||||
first(): Ref,
|
||||
asMutable(): MutableChildSet
|
||||
}
|
||||
|
||||
export interface MutableChildSet extends ChildSet {
|
||||
add(ref: Ref): MutableChildSet,
|
||||
remove(ref: Ref): MutableChildSet,
|
||||
asImmutable(): ChildSet
|
||||
}
|
||||
|
||||
|
||||
interface _Map<T> {
|
||||
readonly size: number,
|
||||
has(ref: Ref): boolean,
|
||||
get(ref: Ref): T
|
||||
get(ref: Ref): T,
|
||||
asImmutable(): _Map<T>,
|
||||
asMutable(): MutableMap<T>
|
||||
}
|
||||
|
||||
export interface MutableMap<T> extends _Map<T> {
|
||||
set(ref: Ref, value: T): MutableMap<T>,
|
||||
delete(ref: Ref): MutableMap<T>
|
||||
}
|
||||
|
||||
export interface Transforms extends _Map<StateTransform> {}
|
||||
export interface Children extends _Map<ChildSet> { }
|
||||
export interface Dependencies extends _Map<ChildSet> { }
|
||||
|
||||
export interface MutableTransforms extends MutableMap<StateTransform> {}
|
||||
export interface MutableChildren extends MutableMap<MutableChildSet> { }
|
||||
export interface MutableDependencies extends MutableMap<MutableChildSet> { }
|
||||
|
||||
class Impl implements StateTree {
|
||||
get root() { return this.transforms.get(StateTransform.RootRef)!; }
|
||||
|
||||
@@ -63,7 +82,10 @@ namespace StateTree {
|
||||
*/
|
||||
export function createEmpty(customRoot?: StateTransform): StateTree {
|
||||
const root = customRoot || StateTransform.createRoot();
|
||||
return create(ImmutableMap([[root.ref, root]]), ImmutableMap([[root.ref, OrderedSet()]]), ImmutableMap());
|
||||
return create(
|
||||
ImmutableMap([[root.ref, root] as [Ref, StateTransform]]) as Transforms,
|
||||
ImmutableMap([[root.ref, OrderedSet()] as [Ref, ChildSet]]) as Children,
|
||||
ImmutableMap() as Dependencies);
|
||||
}
|
||||
|
||||
export function create(nodes: Transforms, children: Children, dependencies: Dependencies): StateTree {
|
||||
@@ -148,13 +170,13 @@ namespace StateTree {
|
||||
children.set(transform.ref, OrderedSet<Ref>().asMutable());
|
||||
}
|
||||
|
||||
if (transform.ref !== transform.parent) children.get(transform.parent).add(transform.ref);
|
||||
if (transform.ref !== transform.parent) children.get(transform.parent)!.add(transform.ref);
|
||||
}
|
||||
|
||||
const dependent = new Set<Ref>();
|
||||
for (const t of data.transforms) {
|
||||
const ref = t.ref;
|
||||
children.set(ref, children.get(ref).asImmutable());
|
||||
children.set(ref, children.get(ref)!.asImmutable());
|
||||
|
||||
if (!t.dependsOn) continue;
|
||||
|
||||
@@ -163,16 +185,16 @@ namespace StateTree {
|
||||
if (!dependencies.has(d)) {
|
||||
dependencies.set(d, OrderedSet<Ref>([ref]).asMutable());
|
||||
} else {
|
||||
dependencies.get(d).add(ref);
|
||||
dependencies.get(d)!.add(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependent.forEach(d => {
|
||||
dependencies.set(d, dependencies.get(d).asImmutable());
|
||||
dependencies.set(d, dependencies.get(d)!.asImmutable());
|
||||
});
|
||||
|
||||
return create(nodes.asImmutable(), children.asImmutable(), dependencies.asImmutable());
|
||||
return create(nodes.asImmutable() as Transforms, children.asImmutable() as Children, dependencies.asImmutable() as Dependencies);
|
||||
}
|
||||
|
||||
export function dump(tree: StateTree) {
|
||||
|
||||
@@ -13,16 +13,16 @@ import { arrayEqual } from '../../mol-util/array';
|
||||
export { TransientTree };
|
||||
|
||||
class TransientTree implements StateTree {
|
||||
transforms = this.tree.transforms as ImmutableMap<StateTransform.Ref, StateTransform>;
|
||||
children = this.tree.children as ImmutableMap<StateTransform.Ref, OrderedSet<StateTransform.Ref>>;
|
||||
dependencies = this.tree.dependencies as ImmutableMap<StateTransform.Ref, OrderedSet<StateTransform.Ref>>;
|
||||
transforms = this.tree.transforms as StateTree.MutableTransforms;
|
||||
children = this.tree.children as StateTree.MutableChildren;
|
||||
dependencies = this.tree.dependencies as StateTree.MutableDependencies;
|
||||
|
||||
private changedNodes = false;
|
||||
private changedChildren = false;
|
||||
private changedDependencies = false;
|
||||
|
||||
private _childMutations: Map<StateTransform.Ref, OrderedSet<StateTransform.Ref>> | undefined = void 0;
|
||||
private _dependencyMutations: Map<StateTransform.Ref, OrderedSet<StateTransform.Ref>> | undefined = void 0;
|
||||
private _dependencyMutations: Map<StateTransform.Ref, StateTree.MutableChildSet> | undefined = void 0;
|
||||
private _stateUpdates: Set<StateTransform.Ref> | undefined = void 0;
|
||||
|
||||
private get childMutations() {
|
||||
@@ -99,12 +99,11 @@ class TransientTree implements StateTree {
|
||||
}
|
||||
|
||||
private mutateDependency(parent: StateTransform.Ref, child: StateTransform.Ref, action: 'add' | 'remove') {
|
||||
let set = this.dependencyMutations.get(parent);
|
||||
let set: StateTree.MutableChildSet | undefined = this.dependencyMutations.get(parent);
|
||||
|
||||
if (!set) {
|
||||
const src = this.dependencies.get(parent);
|
||||
if (!src && action === 'remove') return;
|
||||
|
||||
this.changeDependencies();
|
||||
set = src ? src.asMutable() : OrderedSet<string>().asMutable();
|
||||
this.dependencyMutations.set(parent, set);
|
||||
@@ -275,7 +274,7 @@ class TransientTree implements StateTree {
|
||||
asImmutable() {
|
||||
if (!this.changedNodes && !this.changedChildren && !this._childMutations) return this.tree;
|
||||
if (this._childMutations) this._childMutations.forEach(fixChildMutations, this.children);
|
||||
if (this._dependencyMutations) this._dependencyMutations.forEach(fixDependencyMutations, this.dependencies);
|
||||
if (this._dependencyMutations) this._dependencyMutations.forEach(fixDependencyMutations as any, this.dependencies);
|
||||
return StateTree.create(
|
||||
this.changedNodes ? this.transforms.asImmutable() : this.transforms,
|
||||
this.changedChildren ? this.children.asImmutable() : this.children,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -13,8 +13,12 @@ import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { ThemeDataContext } from '../theme';
|
||||
import { TableLegend } from '../../mol-util/legend';
|
||||
import { getAdjustedColorMap } from '../../mol-util/color/color';
|
||||
import { getColorMapParams } from '../../mol-util/color/params';
|
||||
import { ChainIdColorTheme, ChainIdColorThemeParams } from './chain-id';
|
||||
import { OperatorNameColorThemeParams, OperatorNameColorTheme } from './operator-name';
|
||||
import { EntityIdColorTheme, EntityIdColorThemeParams } from './entity-id';
|
||||
import { assertUnreachable } from '../../mol-util/type-helpers';
|
||||
import { EntitySourceColorTheme, EntitySourceColorThemeParams } from './entity-source';
|
||||
|
||||
// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)
|
||||
export const ElementSymbolColors = ColorMap({
|
||||
@@ -25,16 +29,20 @@ export type ElementSymbolColors = typeof ElementSymbolColors
|
||||
const DefaultElementSymbolColor = Color(0xFFFFFF);
|
||||
const Description = 'Assigns a color to every atom according to its chemical element.';
|
||||
|
||||
// TODO generalise `carbonColor` param to all themes?
|
||||
|
||||
export const ElementSymbolColorThemeParams = {
|
||||
carbonColor: PD.MappedStatic('chain-id', {
|
||||
'chain-id': PD.Group({ ...ChainIdColorThemeParams }),
|
||||
'operator-name': PD.Group({ ...OperatorNameColorThemeParams }),
|
||||
'element-symbol': PD.Group({})
|
||||
'chain-id': PD.Group(ChainIdColorThemeParams),
|
||||
'entity-id': PD.Group(EntityIdColorThemeParams),
|
||||
'entity-source': PD.Group(EntitySourceColorThemeParams),
|
||||
'operator-name': PD.Group(OperatorNameColorThemeParams),
|
||||
'element-symbol': PD.EmptyGroup()
|
||||
}, { description: 'Use chain-id coloring for carbon atoms.' }),
|
||||
saturation: PD.Numeric(0, { min: -6, max: 6, step: 0.1 }),
|
||||
lightness: PD.Numeric(0.2, { min: -6, max: 6, step: 0.1 })
|
||||
lightness: PD.Numeric(0.2, { min: -6, max: 6, step: 0.1 }),
|
||||
colors: PD.MappedStatic('default', {
|
||||
'default': PD.EmptyGroup(),
|
||||
'custom': PD.Group(getColorMapParams(ElementSymbolColors))
|
||||
})
|
||||
};
|
||||
export type ElementSymbolColorThemeParams = typeof ElementSymbolColorThemeParams
|
||||
export function getElementSymbolColorThemeParams(ctx: ThemeDataContext) {
|
||||
@@ -47,13 +55,16 @@ export function elementSymbolColor(colorMap: ElementSymbolColors, element: Eleme
|
||||
}
|
||||
|
||||
export function ElementSymbolColorTheme(ctx: ThemeDataContext, props: PD.Values<ElementSymbolColorThemeParams>): ColorTheme<ElementSymbolColorThemeParams> {
|
||||
const colorMap = getAdjustedColorMap(ElementSymbolColors, props.saturation, props.lightness);
|
||||
const colorMap = getAdjustedColorMap(props.colors.name === 'default' ? ElementSymbolColors : props.colors.params, props.saturation, props.lightness);
|
||||
|
||||
const carbonColor = props.carbonColor.name === 'chain-id'
|
||||
? ChainIdColorTheme(ctx, props.carbonColor.params).color
|
||||
: props.carbonColor.name === 'operator-name'
|
||||
? OperatorNameColorTheme(ctx, props.carbonColor.params).color
|
||||
: undefined;
|
||||
const pcc = props.carbonColor;
|
||||
const carbonColor =
|
||||
pcc.name === 'chain-id' ? ChainIdColorTheme(ctx, pcc.params).color :
|
||||
pcc.name === 'entity-id' ? EntityIdColorTheme(ctx, pcc.params).color :
|
||||
pcc.name === 'entity-source' ? EntitySourceColorTheme(ctx, pcc.params).color :
|
||||
pcc.name === 'operator-name' ? OperatorNameColorTheme(ctx, pcc.params).color :
|
||||
pcc.name === 'element-symbol' ? undefined :
|
||||
assertUnreachable(pcc);
|
||||
|
||||
function elementColor(element: ElementSymbol, location: Location) {
|
||||
return (carbonColor && element === 'C')
|
||||
@@ -86,8 +97,8 @@ export function ElementSymbolColorTheme(ctx: ThemeDataContext, props: PD.Values<
|
||||
color,
|
||||
props,
|
||||
description: Description,
|
||||
legend: TableLegend(Object.keys(ElementSymbolColors).map(name => {
|
||||
return [name, (ElementSymbolColors as any)[name] as Color] as [string, Color];
|
||||
legend: TableLegend(Object.keys(colorMap).map(name => {
|
||||
return [name, (colorMap as any)[name] as Color] as [string, Color];
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2021-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
import { StructureProperties, StructureElement, Bond, Structure } from '../../mol-model/structure';
|
||||
import { StructureProperties, StructureElement, Bond, Structure, Unit } from '../../mol-model/structure';
|
||||
import { Color } from '../../mol-util/color';
|
||||
import { Location } from '../../mol-model/location';
|
||||
import { ColorTheme, LocationColor } from '../color';
|
||||
@@ -38,10 +38,33 @@ function getEntityIdSerialMap(structure: Structure) {
|
||||
const k = key(label_entity_id.value(j), i);
|
||||
if (!map.has(k)) map.set(k, map.size);
|
||||
}
|
||||
const { coarseHierarchy } = structure.models[i];
|
||||
if (coarseHierarchy.isDefined) {
|
||||
const { entity_id: spheres_entity_id } = coarseHierarchy.spheres;
|
||||
for (let j = 0, jl = spheres_entity_id.rowCount; j < jl; ++j) {
|
||||
const k = key(spheres_entity_id.value(j), i);
|
||||
if (!map.has(k)) map.set(k, map.size);
|
||||
}
|
||||
const { entity_id: gaussians_entity_id } = coarseHierarchy.gaussians;
|
||||
for (let j = 0, jl = gaussians_entity_id.rowCount; j < jl; ++j) {
|
||||
const k = key(gaussians_entity_id.value(j), i);
|
||||
if (!map.has(k)) map.set(k, map.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
function getEntityId(location: StructureElement.Location): string {
|
||||
switch (location.unit.kind) {
|
||||
case Unit.Kind.Atomic:
|
||||
return StructureProperties.chain.label_entity_id(location);
|
||||
case Unit.Kind.Spheres:
|
||||
case Unit.Kind.Gaussians:
|
||||
return StructureProperties.coarse.entity_id(location);
|
||||
}
|
||||
}
|
||||
|
||||
export function EntityIdColorTheme(ctx: ThemeDataContext, props: PD.Values<EntityIdColorThemeParams>): ColorTheme<EntityIdColorThemeParams> {
|
||||
let color: LocationColor;
|
||||
let legend: ScaleLegend | TableLegend | undefined;
|
||||
@@ -59,16 +82,16 @@ export function EntityIdColorTheme(ctx: ThemeDataContext, props: PD.Values<Entit
|
||||
color = (location: Location): Color => {
|
||||
let serial: number | undefined = undefined;
|
||||
if (StructureElement.Location.is(location)) {
|
||||
const atomId = StructureProperties.chain.label_entity_id(location);
|
||||
const entityId = getEntityId(location);
|
||||
const modelIndex = location.structure.models.indexOf(location.unit.model);
|
||||
const k = key(atomId, modelIndex);
|
||||
const k = key(entityId, modelIndex);
|
||||
serial = entityIdSerialMap.get(k);
|
||||
} else if (Bond.isLocation(location)) {
|
||||
l.unit = location.aUnit;
|
||||
l.element = location.aUnit.elements[location.aIndex];
|
||||
const atomId = StructureProperties.chain.label_entity_id(l);
|
||||
const entityId = getEntityId(l);
|
||||
const modelIndex = l.structure.models.indexOf(l.unit.model);
|
||||
const k = key(atomId, modelIndex);
|
||||
const k = key(entityId, modelIndex);
|
||||
serial = entityIdSerialMap.get(k);
|
||||
}
|
||||
return serial === undefined ? DefaultColor : palette.color(serial);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -12,24 +12,42 @@ import { ColorTheme } from '../color';
|
||||
import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { ThemeDataContext } from '../theme';
|
||||
import { ChainIdColorTheme, ChainIdColorThemeParams } from './chain-id';
|
||||
import { UniformColorTheme, UniformColorThemeParams } from './uniform';
|
||||
import { assertUnreachable } from '../../mol-util/type-helpers';
|
||||
import { EntityIdColorTheme, EntityIdColorThemeParams } from './entity-id';
|
||||
import { MoleculeTypeColorTheme, MoleculeTypeColorThemeParams } from './molecule-type';
|
||||
import { EntitySourceColorTheme, EntitySourceColorThemeParams } from './entity-source';
|
||||
|
||||
const DefaultIllustrativeColor = Color(0xEEEEEE);
|
||||
const Description = `Assigns an illustrative color that gives every chain a unique color with lighter carbons (inspired by David Goodsell's Molecule of the Month style).`;
|
||||
const Description = `Assigns an illustrative color that gives every chain a color based on the choosen style but with lighter carbons (inspired by David Goodsell's Molecule of the Month style).`;
|
||||
|
||||
export const IllustrativeColorThemeParams = {
|
||||
...ChainIdColorThemeParams,
|
||||
style: PD.MappedStatic('entity-id', {
|
||||
uniform: PD.Group(UniformColorThemeParams),
|
||||
'chain-id': PD.Group(ChainIdColorThemeParams),
|
||||
'entity-id': PD.Group(EntityIdColorThemeParams),
|
||||
'entity-source': PD.Group(EntitySourceColorThemeParams),
|
||||
'molecule-type': PD.Group(MoleculeTypeColorThemeParams),
|
||||
}),
|
||||
carbonLightness: PD.Numeric(0.8, { min: -6, max: 6, step: 0.1 })
|
||||
};
|
||||
export type IllustrativeColorThemeParams = typeof IllustrativeColorThemeParams
|
||||
export function getIllustrativeColorThemeParams(ctx: ThemeDataContext) {
|
||||
return IllustrativeColorThemeParams; // TODO return copy
|
||||
const params = PD.clone(IllustrativeColorThemeParams);
|
||||
return params;
|
||||
}
|
||||
|
||||
export function IllustrativeColorTheme(ctx: ThemeDataContext, props: PD.Values<IllustrativeColorThemeParams>): ColorTheme<IllustrativeColorThemeParams> {
|
||||
const { color: chainIdColor, legend } = ChainIdColorTheme(ctx, props);
|
||||
const { color: styleColor, legend } =
|
||||
props.style.name === 'uniform' ? UniformColorTheme(ctx, props.style.params) :
|
||||
props.style.name === 'chain-id' ? ChainIdColorTheme(ctx, props.style.params) :
|
||||
props.style.name === 'entity-id' ? EntityIdColorTheme(ctx, props.style.params) :
|
||||
props.style.name === 'entity-source' ? EntitySourceColorTheme(ctx, props.style.params) :
|
||||
props.style.name === 'molecule-type' ? MoleculeTypeColorTheme(ctx, props.style.params) :
|
||||
assertUnreachable(props.style);
|
||||
|
||||
function illustrativeColor(location: Location, typeSymbol: ElementSymbol) {
|
||||
const baseColor = chainIdColor(location, false);
|
||||
const baseColor = styleColor(location, false);
|
||||
return typeSymbol === 'C' ? Color.lighten(baseColor, props.carbonLightness) : baseColor;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -14,6 +14,7 @@ import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { ThemeDataContext } from '../theme';
|
||||
import { TableLegend } from '../../mol-util/legend';
|
||||
import { getAdjustedColorMap } from '../../mol-util/color/color';
|
||||
import { getColorMapParams } from '../../mol-util/color/params';
|
||||
|
||||
export const MoleculeTypeColors = ColorMap({
|
||||
water: 0x386cb0,
|
||||
@@ -31,7 +32,11 @@ const Description = 'Assigns a color based on the molecule type of a residue.';
|
||||
|
||||
export const MoleculeTypeColorThemeParams = {
|
||||
saturation: PD.Numeric(0, { min: -6, max: 6, step: 0.1 }),
|
||||
lightness: PD.Numeric(0, { min: -6, max: 6, step: 0.1 })
|
||||
lightness: PD.Numeric(0, { min: -6, max: 6, step: 0.1 }),
|
||||
colors: PD.MappedStatic('default', {
|
||||
'default': PD.EmptyGroup(),
|
||||
'custom': PD.Group(getColorMapParams(MoleculeTypeColors))
|
||||
})
|
||||
};
|
||||
export type MoleculeTypeColorThemeParams = typeof MoleculeTypeColorThemeParams
|
||||
export function getMoleculeTypeColorThemeParams(ctx: ThemeDataContext) {
|
||||
@@ -53,7 +58,7 @@ export function moleculeTypeColor(colorMap: MoleculeTypeColors, unit: Unit, elem
|
||||
}
|
||||
|
||||
export function MoleculeTypeColorTheme(ctx: ThemeDataContext, props: PD.Values<MoleculeTypeColorThemeParams>): ColorTheme<MoleculeTypeColorThemeParams> {
|
||||
const colorMap = getAdjustedColorMap(MoleculeTypeColors, props.saturation, props.lightness);
|
||||
const colorMap = getAdjustedColorMap(props.colors.name === 'default' ? MoleculeTypeColors : props.colors.params, props.saturation, props.lightness);
|
||||
|
||||
function color(location: Location): Color {
|
||||
if (StructureElement.Location.is(location)) {
|
||||
@@ -70,8 +75,8 @@ export function MoleculeTypeColorTheme(ctx: ThemeDataContext, props: PD.Values<M
|
||||
color,
|
||||
props,
|
||||
description: Description,
|
||||
legend: TableLegend(Object.keys(MoleculeTypeColors).map(name => {
|
||||
return [name, (MoleculeTypeColors as any)[name] as Color] as [string, Color];
|
||||
legend: TableLegend(Object.keys(colorMap).map(name => {
|
||||
return [name, (colorMap as any)[name] as Color] as [string, Color];
|
||||
}).concat([['Other/unknown', DefaultMoleculeTypeColor]]))
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -12,6 +12,7 @@ import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { ThemeDataContext } from '../theme';
|
||||
import { TableLegend } from '../../mol-util/legend';
|
||||
import { getAdjustedColorMap } from '../../mol-util/color/color';
|
||||
import { getColorMapParams } from '../../mol-util/color/params';
|
||||
|
||||
// protein colors from Jmol http://jmol.sourceforge.net/jscolors/
|
||||
export const ResidueNameColors = ColorMap({
|
||||
@@ -66,7 +67,11 @@ const Description = 'Assigns a color to every residue according to its name.';
|
||||
|
||||
export const ResidueNameColorThemeParams = {
|
||||
saturation: PD.Numeric(0, { min: -6, max: 6, step: 0.1 }),
|
||||
lightness: PD.Numeric(1, { min: -6, max: 6, step: 0.1 })
|
||||
lightness: PD.Numeric(1, { min: -6, max: 6, step: 0.1 }),
|
||||
colors: PD.MappedStatic('default', {
|
||||
'default': PD.EmptyGroup(),
|
||||
'custom': PD.Group(getColorMapParams(ResidueNameColors))
|
||||
})
|
||||
};
|
||||
export type ResidueNameColorThemeParams = typeof ResidueNameColorThemeParams
|
||||
export function getResidueNameColorThemeParams(ctx: ThemeDataContext) {
|
||||
@@ -93,7 +98,7 @@ export function residueNameColor(colorMap: ResidueNameColors, residueName: strin
|
||||
}
|
||||
|
||||
export function ResidueNameColorTheme(ctx: ThemeDataContext, props: PD.Values<ResidueNameColorThemeParams>): ColorTheme<ResidueNameColorThemeParams> {
|
||||
const colorMap = getAdjustedColorMap(ResidueNameColors, props.saturation, props.lightness);
|
||||
const colorMap = getAdjustedColorMap(props.colors.name === 'default' ? ResidueNameColors : props.colors.params, props.saturation, props.lightness);
|
||||
|
||||
function color(location: Location): Color {
|
||||
if (StructureElement.Location.is(location)) {
|
||||
@@ -123,8 +128,8 @@ export function ResidueNameColorTheme(ctx: ThemeDataContext, props: PD.Values<Re
|
||||
color,
|
||||
props,
|
||||
description: Description,
|
||||
legend: TableLegend(Object.keys(ResidueNameColors).map(name => {
|
||||
return [name, (ResidueNameColors as any)[name] as Color] as [string, Color];
|
||||
legend: TableLegend(Object.keys(colorMap).map(name => {
|
||||
return [name, (colorMap as any)[name] as Color] as [string, Color];
|
||||
}).concat([['Unknown', DefaultResidueNameColor]]))
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -15,6 +15,7 @@ import { ThemeDataContext } from '../theme';
|
||||
import { TableLegend } from '../../mol-util/legend';
|
||||
import { SecondaryStructureProvider, SecondaryStructureValue } from '../../mol-model-props/computed/secondary-structure';
|
||||
import { getAdjustedColorMap } from '../../mol-util/color/color';
|
||||
import { getColorMapParams } from '../../mol-util/color/params';
|
||||
import { CustomProperty } from '../../mol-model-props/common/custom-property';
|
||||
import { hash2 } from '../../mol-data/util';
|
||||
|
||||
@@ -41,7 +42,11 @@ const Description = 'Assigns a color based on the type of secondary structure an
|
||||
|
||||
export const SecondaryStructureColorThemeParams = {
|
||||
saturation: PD.Numeric(-1, { min: -6, max: 6, step: 0.1 }),
|
||||
lightness: PD.Numeric(0, { min: -6, max: 6, step: 0.1 })
|
||||
lightness: PD.Numeric(0, { min: -6, max: 6, step: 0.1 }),
|
||||
colors: PD.MappedStatic('default', {
|
||||
'default': PD.EmptyGroup(),
|
||||
'custom': PD.Group(getColorMapParams(SecondaryStructureColors))
|
||||
})
|
||||
};
|
||||
export type SecondaryStructureColorThemeParams = typeof SecondaryStructureColorThemeParams
|
||||
export function getSecondaryStructureColorThemeParams(ctx: ThemeDataContext) {
|
||||
@@ -88,7 +93,7 @@ export function SecondaryStructureColorTheme(ctx: ThemeDataContext, props: PD.Va
|
||||
const computedSecondaryStructure = ctx.structure && SecondaryStructureProvider.get(ctx.structure);
|
||||
const contextHash = computedSecondaryStructure ? hash2(computedSecondaryStructure.id, computedSecondaryStructure.version) : -1;
|
||||
|
||||
const colorMap = getAdjustedColorMap(SecondaryStructureColors, props.saturation, props.lightness);
|
||||
const colorMap = getAdjustedColorMap(props.colors.name === 'default' ? SecondaryStructureColors : props.colors.params, props.saturation, props.lightness);
|
||||
|
||||
function color(location: Location): Color {
|
||||
if (StructureElement.Location.is(location)) {
|
||||
@@ -107,8 +112,8 @@ export function SecondaryStructureColorTheme(ctx: ThemeDataContext, props: PD.Va
|
||||
props,
|
||||
contextHash,
|
||||
description: Description,
|
||||
legend: TableLegend(Object.keys(SecondaryStructureColors).map(name => {
|
||||
return [name, (SecondaryStructureColors as any)[name] as Color] as [string, Color];
|
||||
legend: TableLegend(Object.keys(colorMap).map(name => {
|
||||
return [name, (colorMap as any)[name] as Color] as [string, Color];
|
||||
}).concat([['Other', DefaultSecondaryStructureColor]]))
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
17
src/mol-util/color/params.ts
Normal file
17
src/mol-util/color/params.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) 2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { objectForEach } from '../object';
|
||||
import { ColorMap } from './color';
|
||||
|
||||
export function getColorMapParams<T extends { [k: string]: number }>(map: ColorMap<T>) {
|
||||
const colors: Record<string, PD.Color> = {};
|
||||
objectForEach(map, (_, k) => {
|
||||
colors[k] = PD.Color(map[k]);
|
||||
});
|
||||
return colors as { [k in keyof T]: PD.Color };
|
||||
}
|
||||
@@ -197,13 +197,13 @@ export function configureLocal() {
|
||||
description: VOLUME_SERVER_HEADER
|
||||
});
|
||||
parser.add_argument('--jobs', { help: `Path to a JSON file with job specification.`, required: false });
|
||||
parser.add_argument('--jobsTemplate', { help: 'Print example template for jobs.json and exit.', required: false, nargs: 0 });
|
||||
parser.add_argument('--jobsTemplate', { help: 'Print example template for jobs.json and exit.', required: false, action: 'store_true' });
|
||||
addJsonConfigArgs(parser);
|
||||
addLimitsArgs(parser);
|
||||
|
||||
const config = parser.parse_args() as LimitsConfig & ServerJsonConfig;
|
||||
|
||||
if (config.cfgTemplate !== null) {
|
||||
if (config.cfgTemplate) {
|
||||
console.log(JSON.stringify(DefaultLimitsConfig, null, 2));
|
||||
process.exit(0);
|
||||
}
|
||||
@@ -216,7 +216,7 @@ export function configureLocal() {
|
||||
setLimitsConfig(cfg);
|
||||
}
|
||||
|
||||
if (config.printCfg !== null) {
|
||||
if (config.printCfg) {
|
||||
console.log(JSON.stringify(LimitsConfig, null, 2));
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import * as LocalApi from './server/local-api';
|
||||
|
||||
const config = configureLocal();
|
||||
|
||||
if (config.jobsTemplate !== null) {
|
||||
if (config.jobsTemplate) {
|
||||
const exampleJobs: LocalApi.JobEntry[] = [{
|
||||
source: {
|
||||
filename: `g:/test/mdb/xray-1tqn.mdb`,
|
||||
|
||||
Reference in New Issue
Block a user