mirror of
https://github.com/molstar/molstar.git
synced 2026-06-05 22:31:26 +08:00
Compare commits
89 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eae7c11c55 | ||
|
|
b8251e1ade | ||
|
|
2ff2b9f348 | ||
|
|
164e3f3343 | ||
|
|
4901a1bd87 | ||
|
|
cd194cca65 | ||
|
|
1748efbc18 | ||
|
|
4d60b40403 | ||
|
|
6e5a41879f | ||
|
|
c5f9eb54da | ||
|
|
aebbfeb061 | ||
|
|
a0a5a6b578 | ||
|
|
6bdafb85d7 | ||
|
|
0dd7debf5d | ||
|
|
962b9ee7af | ||
|
|
15bcc5df88 | ||
|
|
8495d834c8 | ||
|
|
7282399709 | ||
|
|
780bdd6e7e | ||
|
|
ad08e7c67f | ||
|
|
ff089964ca | ||
|
|
990191529a | ||
|
|
ce1bec12b4 | ||
|
|
703ea9af53 | ||
|
|
df0227ae1e | ||
|
|
486d12b6ac | ||
|
|
9c18375ab4 | ||
|
|
e1708aed68 | ||
|
|
a42d778b84 | ||
|
|
7692b59c7c | ||
|
|
82de9b36b3 | ||
|
|
49b3c8f65f | ||
|
|
90ad32d936 | ||
|
|
2509e91f1a | ||
|
|
80dc2219e4 | ||
|
|
931cb0fa7d | ||
|
|
4383f2ea90 | ||
|
|
add79dc242 | ||
|
|
b6e142f04c | ||
|
|
105f6c3041 | ||
|
|
4babbb65c1 | ||
|
|
878159f7ed | ||
|
|
c320386019 | ||
|
|
1e7a0159f0 | ||
|
|
bbf4f1d1d3 | ||
|
|
8cd1c69c76 | ||
|
|
2372a878ac | ||
|
|
9bec644997 | ||
|
|
650d38dff8 | ||
|
|
097277e397 | ||
|
|
82a4d5eedf | ||
|
|
2a00248812 | ||
|
|
9841c773cb | ||
|
|
b21a78ad14 | ||
|
|
7329fa597d | ||
|
|
f1d8f0ecb4 | ||
|
|
1d127f2364 | ||
|
|
b244405cc3 | ||
|
|
38adfe0ca6 | ||
|
|
6f0d798847 | ||
|
|
6e58bfd2b0 | ||
|
|
bc2e8d8ac4 | ||
|
|
7be654d47f | ||
|
|
bfe46e3604 | ||
|
|
008b597fc5 | ||
|
|
c4b4f2e3b1 | ||
|
|
76ee97301b | ||
|
|
289dc09eae | ||
|
|
f23f84f0f3 | ||
|
|
62259f3295 | ||
|
|
854a430a12 | ||
|
|
d27cdb5637 | ||
|
|
7d12d9ee90 | ||
|
|
d70a4ff347 | ||
|
|
49541558d1 | ||
|
|
7b00a1227c | ||
|
|
7800603c81 | ||
|
|
fca00c8116 | ||
|
|
00fa549e44 | ||
|
|
36181b6b87 | ||
|
|
88a95162e9 | ||
|
|
9c1d59a2c8 | ||
|
|
fdd894956a | ||
|
|
eb6dc0859d | ||
|
|
b99026bba2 | ||
|
|
6fa50eb8d5 | ||
|
|
e5046f15a9 | ||
|
|
09f1c066a0 | ||
|
|
ed2f0b34c9 |
43
CHANGELOG.md
43
CHANGELOG.md
@@ -6,6 +6,49 @@ Note that since we don't clearly distinguish between a public and private interf
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [v3.3.0] - 2022-02-27
|
||||
|
||||
- Fix parsing contour-level from emdb v3 header files
|
||||
- Fix invalid CSS (#376)
|
||||
- Fix "texture not renderable" & "texture not bound" warnings (#319)
|
||||
- Fix visual for bonds between two aromatic rings
|
||||
- Fix visual for delocalized bonds (parsed from mmcif and mol2)
|
||||
- Fix ring computation algorithm
|
||||
- Add ``UnitResonance`` property with info about delocalized triplets
|
||||
- Resolve marking in main renderer loop to improve overall performance
|
||||
- Use ``throttleTime`` instead of ``debounceTime`` in sequence viewer for better responsiveness
|
||||
- Change line geometry default ``scaleFactor`` to 2 (3 is too big after fixing line rendering)
|
||||
- Trajectory animation performance improvements
|
||||
- Reuse ``Model.CoarseGrained`` for coordinate trajectories
|
||||
- Avoid calculating ``InterUnitBonds`` when ``Structure.parent`` ones are empty
|
||||
- Reuse unit boundary if sphere has not changed too much
|
||||
- Don't show 'inter-bond' and 'element-cross' visuals in line representations of polymerAndLigand preset
|
||||
- Fix additional mononucleotides detected as polymer components
|
||||
- Fix and improve ``canRemap`` handling in ``IntraUnitBonds``
|
||||
- Reuse occlusion for secondary passes during multi-sampling
|
||||
- Check if marking passes are needed before doing them
|
||||
- Add ``resolutionScale`` parameter to allow trading quality of occlusion for performance
|
||||
|
||||
## [v3.2.0] - 2022-02-17
|
||||
|
||||
- Rename "best database mapping" to "SIFTS Mapping"
|
||||
- Add schema and export support for ``atom_site.pdbx_sifts_xref_*`` fields
|
||||
- Add schema export support for ``atom_site.pdbx_label_index`` field
|
||||
- Add `traceOnly` parameter to chain/UniProt-based structure alignment
|
||||
- Store ``IndexPairBonds`` as a dynamic property.
|
||||
|
||||
## [v3.1.0] - 2022-02-06
|
||||
|
||||
- Fix ``xrayShaded`` & ``ignoreLight`` params not working at the same time
|
||||
- Add ``ignoreLight`` to component params
|
||||
- Tweaks for cleaner default representation style
|
||||
- Cartoon: use ``nucleotide-ring`` instead of ``nucleotide-block``
|
||||
- Focus: use ``xrayShaded`` instead of opacity; adjust target size; don't show non-covalent interactions twice
|
||||
- Fix representation preset side effects (changing post-processing parameters, see #363)
|
||||
- Add Quick Styles panel (default, illustrative, stylized)
|
||||
- Fix exported structure missing secondary-structure categories (#364)
|
||||
- Fix volume streaming error message: distinguish between missing data and server error (#364)
|
||||
|
||||
## [v3.0.2] - 2022-01-30
|
||||
|
||||
- Fix color smoothing of elongated structures (by fixing ``Sphere.expand`` for spheres with highly directional extrema)
|
||||
|
||||
@@ -24,6 +24,11 @@ atom_site.auth_asym_id
|
||||
atom_site.auth_seq_id
|
||||
atom_site.pdbx_PDB_model_num
|
||||
atom_site.ihm_model_id
|
||||
atom_site.pdbx_label_index
|
||||
atom_site.pdbx_sifts_xref_db_name
|
||||
atom_site.pdbx_sifts_xref_db_acc
|
||||
atom_site.pdbx_sifts_xref_db_num
|
||||
atom_site.pdbx_sifts_xref_db_res
|
||||
|
||||
atom_site_anisotrop.id
|
||||
atom_site_anisotrop.U
|
||||
|
||||
|
@@ -34,6 +34,14 @@
|
||||
* ACE (many, e.g. 5AGU, 1E1X)
|
||||
* ACY in 7ABY
|
||||
* NH2 (many, e.g. 6Y13)
|
||||
* Ligands with many rings
|
||||
* STU (e.g. 1U59) - many fused rings
|
||||
* HT (e.g. 127D) - rings connected by a single bond
|
||||
* J2C (e.g. 7EFJ) - rings connected by a single atom
|
||||
* RBF (e.g. 7QF2) - three linearly fused rings
|
||||
* TA1 (e.g. 1JFF) - many fused rings (incl. a 8-member rings)
|
||||
* BPA (e.g. 1JDG) - many fused rings
|
||||
* CLR (e.g. 3GKI) - four fused rings
|
||||
|
||||
Assembly symmetries
|
||||
* 5M30 (Assembly 1, C3 local and pseudo)
|
||||
|
||||
2364
package-lock.json
generated
2364
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
58
package.json
58
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "molstar",
|
||||
"version": "3.0.2",
|
||||
"version": "3.3.0",
|
||||
"description": "A comprehensive macromolecular library.",
|
||||
"homepage": "https://github.com/molstar/molstar#readme",
|
||||
"repository": {
|
||||
@@ -92,69 +92,69 @@
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@graphql-codegen/add": "^3.1.1",
|
||||
"@graphql-codegen/cli": "^2.4.0",
|
||||
"@graphql-codegen/cli": "^2.6.2",
|
||||
"@graphql-codegen/time": "^3.1.1",
|
||||
"@graphql-codegen/typescript": "^2.4.2",
|
||||
"@graphql-codegen/typescript": "^2.4.5",
|
||||
"@graphql-codegen/typescript-graphql-files-modules": "^2.1.1",
|
||||
"@graphql-codegen/typescript-graphql-request": "^4.3.3",
|
||||
"@graphql-codegen/typescript-operations": "^2.2.2",
|
||||
"@graphql-codegen/typescript-graphql-request": "^4.3.7",
|
||||
"@graphql-codegen/typescript-operations": "^2.3.2",
|
||||
"@types/cors": "^2.8.12",
|
||||
"@types/gl": "^4.1.0",
|
||||
"@types/jest": "^27.4.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
||||
"@typescript-eslint/parser": "^5.10.0",
|
||||
"@types/jest": "^27.4.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.12.1",
|
||||
"@typescript-eslint/parser": "^5.12.1",
|
||||
"benchmark": "^2.1.4",
|
||||
"concurrently": "^7.0.0",
|
||||
"cpx2": "^4.1.2",
|
||||
"cpx2": "^4.2.0",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"css-loader": "^6.5.1",
|
||||
"eslint": "^8.7.0",
|
||||
"css-loader": "^6.6.0",
|
||||
"eslint": "^8.10.0",
|
||||
"extra-watch-webpack-plugin": "^1.0.3",
|
||||
"file-loader": "^6.2.0",
|
||||
"fs-extra": "^10.0.0",
|
||||
"graphql": "^16.2.0",
|
||||
"fs-extra": "^10.0.1",
|
||||
"graphql": "^16.3.0",
|
||||
"http-server": "^14.1.0",
|
||||
"jest": "^27.4.7",
|
||||
"mini-css-extract-plugin": "^2.5.2",
|
||||
"jest": "^27.5.1",
|
||||
"mini-css-extract-plugin": "^2.5.3",
|
||||
"path-browserify": "^1.0.1",
|
||||
"raw-loader": "^4.0.2",
|
||||
"sass": "^1.49.0",
|
||||
"sass-loader": "^12.4.0",
|
||||
"simple-git": "^2.48.0",
|
||||
"sass": "^1.49.9",
|
||||
"sass-loader": "^12.6.0",
|
||||
"simple-git": "^3.2.6",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"style-loader": "^3.3.1",
|
||||
"ts-jest": "^27.1.3",
|
||||
"typescript": "^4.5.5",
|
||||
"webpack": "^5.67.0",
|
||||
"webpack-cli": "^4.9.1"
|
||||
"webpack": "^5.69.1",
|
||||
"webpack-cli": "^4.9.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/argparse": "^2.0.10",
|
||||
"@types/benchmark": "^2.1.1",
|
||||
"@types/compression": "1.7.2",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/node": "^16.11.21",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"@types/react": "^17.0.38",
|
||||
"@types/node": "^16.11.26",
|
||||
"@types/node-fetch": "^2.6.1",
|
||||
"@types/react": "^17.0.39",
|
||||
"@types/react-dom": "^17.0.11",
|
||||
"@types/swagger-ui-dist": "3.30.1",
|
||||
"argparse": "^2.0.1",
|
||||
"body-parser": "^1.19.1",
|
||||
"body-parser": "^1.19.2",
|
||||
"compression": "^1.7.4",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.2",
|
||||
"express": "^4.17.3",
|
||||
"h264-mp4-encoder": "^1.0.12",
|
||||
"immer": "^9.0.12",
|
||||
"immutable": "^4.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"rxjs": "^7.5.2",
|
||||
"swagger-ui-dist": "^4.2.1",
|
||||
"rxjs": "^7.5.4",
|
||||
"swagger-ui-dist": "^4.5.2",
|
||||
"tslib": "^2.3.1",
|
||||
"util.promisify": "^1.1.1",
|
||||
"xhr2": "^0.2.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
"react": "^17.0.2 || ^16.14.0",
|
||||
"react-dom": "^17.0.2 || ^16.14.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,10 +44,11 @@ function occlusionStyle(plugin: PluginContext) {
|
||||
postprocessing: {
|
||||
...plugin.canvas3d!.props.postprocessing,
|
||||
occlusion: { name: 'on', params: {
|
||||
samples: 64,
|
||||
radius: 8,
|
||||
bias: 1.0,
|
||||
blurKernelSize: 13
|
||||
bias: 0.8,
|
||||
blurKernelSize: 15,
|
||||
radius: 5,
|
||||
samples: 32,
|
||||
resolutionScale: 1
|
||||
} },
|
||||
outline: { name: 'on', params: {
|
||||
scale: 1.0,
|
||||
|
||||
@@ -24,7 +24,7 @@ const Canvas3DPresets = {
|
||||
illustrative: {
|
||||
canvas3d: <Preset>{
|
||||
postprocessing: {
|
||||
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } },
|
||||
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15, resolutionScale: 1 } },
|
||||
outline: { name: 'on', params: { scale: 1, threshold: 0.33, color: Color(0x000000) } }
|
||||
},
|
||||
renderer: {
|
||||
@@ -36,7 +36,7 @@ const Canvas3DPresets = {
|
||||
occlusion: {
|
||||
canvas3d: <Preset>{
|
||||
postprocessing: {
|
||||
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } },
|
||||
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15, resolutionScale: 1 } },
|
||||
outline: { name: 'off', params: {} }
|
||||
},
|
||||
renderer: {
|
||||
|
||||
@@ -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 2022-01-15T19:52:34-08:00
|
||||
// Generated on 2022-02-27T12:49:36-08:00
|
||||
|
||||
/** All built-in and custom scalars, mapped to their actual values */
|
||||
export type Scalars = {
|
||||
@@ -477,6 +477,8 @@ export type ClustersMembers = {
|
||||
export type CoreAssembly = {
|
||||
/** Get PDB entry that includes this assembly. */
|
||||
readonly entry?: Maybe<CoreEntry>;
|
||||
/** Get all pairwise polymer interfaces for this PDB assembly. */
|
||||
readonly interfaces?: Maybe<ReadonlyArray<Maybe<CoreInterface>>>;
|
||||
readonly pdbx_struct_assembly?: Maybe<PdbxStructAssembly>;
|
||||
readonly pdbx_struct_assembly_auth_evidence?: Maybe<ReadonlyArray<Maybe<PdbxStructAssemblyAuthEvidence>>>;
|
||||
readonly pdbx_struct_assembly_gen?: Maybe<ReadonlyArray<Maybe<PdbxStructAssemblyGen>>>;
|
||||
@@ -724,6 +726,16 @@ export type CoreEntry = {
|
||||
readonly symmetry?: Maybe<Symmetry>;
|
||||
};
|
||||
|
||||
export type CoreInterface = {
|
||||
readonly rcsb_id: Scalars['String'];
|
||||
readonly rcsb_interface_container_identifiers: RcsbInterfaceContainerIdentifiers;
|
||||
readonly rcsb_interface_info?: Maybe<RcsbInterfaceInfo>;
|
||||
/** List of operations for each interface partner. */
|
||||
readonly rcsb_interface_operator: ReadonlyArray<Maybe<ReadonlyArray<Maybe<ReadonlyArray<Maybe<Scalars['String']>>>>>>;
|
||||
readonly rcsb_interface_partner: ReadonlyArray<Maybe<RcsbInterfacePartner>>;
|
||||
readonly rcsb_latest_revision?: Maybe<RcsbLatestRevision>;
|
||||
};
|
||||
|
||||
export type CoreNonpolymerEntity = {
|
||||
/** Get PDB entry that contains this non-polymer entity. */
|
||||
readonly entry?: Maybe<CoreEntry>;
|
||||
@@ -3186,6 +3198,28 @@ export type GeneName = {
|
||||
readonly value?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type InterfacePartnerFeatureAdditionalProperties = {
|
||||
/**
|
||||
* The additional property name.
|
||||
*
|
||||
* Allowable values:
|
||||
* TO_BE_DEFINED
|
||||
*
|
||||
*/
|
||||
readonly name?: Maybe<Scalars['String']>;
|
||||
/** The value(s) of the additional property. */
|
||||
readonly values?: Maybe<ReadonlyArray<Maybe<Scalars['ObjectScalar']>>>;
|
||||
};
|
||||
|
||||
export type InterfacePartnerFeatureFeaturePositions = {
|
||||
/** An identifier for the monomer at which this segment of the feature begins. */
|
||||
readonly beg_seq_id: Scalars['Int'];
|
||||
/** An identifier for the monomer at which this segment of the feature ends. */
|
||||
readonly end_seq_id?: Maybe<Scalars['Int']>;
|
||||
/** The value(s) of the feature over the monomer segment. */
|
||||
readonly values?: Maybe<ReadonlyArray<Maybe<Scalars['Float']>>>;
|
||||
};
|
||||
|
||||
export type PdbxAuditRevisionCategory = {
|
||||
/**
|
||||
* The category updated in the pdbx_audit_revision_category record.
|
||||
@@ -6745,6 +6779,10 @@ export type Query = {
|
||||
readonly entries?: Maybe<ReadonlyArray<Maybe<CoreEntry>>>;
|
||||
/** Get PDB entry given the PDB id. */
|
||||
readonly entry?: Maybe<CoreEntry>;
|
||||
/** Get a pairwise polymeric interface given the PDB ID, ASSEMBLY ID and INTERFACE ID. */
|
||||
readonly interface?: Maybe<CoreInterface>;
|
||||
/** Get a list of pairwise polymeric interfaces given a list of INTERFACE IDs. Here INTERFACE ID is a compound identifier that includes entry_id, assembly_id and interface_id e.g. 1XXX-1.1. */
|
||||
readonly interfaces?: Maybe<ReadonlyArray<Maybe<CoreInterface>>>;
|
||||
/** Get a list of PDB non-polymer entities given a list of ENTITY IDs. Here ENTITY ID is a compound identifier that includes entry_id and entity_id separated by '_', e.g. 1XXX_1. */
|
||||
readonly nonpolymer_entities?: Maybe<ReadonlyArray<Maybe<CoreNonpolymerEntity>>>;
|
||||
/** Get a PDB non-polymer entity, given the PDB ID and ENTITY ID. Here ENTITY ID is a '1', '2', '3', etc. */
|
||||
@@ -6831,6 +6869,20 @@ export type QueryEntryArgs = {
|
||||
};
|
||||
|
||||
|
||||
/** Query root */
|
||||
export type QueryInterfaceArgs = {
|
||||
assembly_id: Scalars['String'];
|
||||
entry_id: Scalars['String'];
|
||||
interface_id: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
/** Query root */
|
||||
export type QueryInterfacesArgs = {
|
||||
interface_ids: ReadonlyArray<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
/** Query root */
|
||||
export type QueryNonpolymer_EntitiesArgs = {
|
||||
entity_ids: ReadonlyArray<Scalars['String']>;
|
||||
@@ -6952,6 +7004,8 @@ export type RcsbAssemblyContainerIdentifiers = {
|
||||
readonly assembly_id: Scalars['String'];
|
||||
/** Entry identifier for the container. */
|
||||
readonly entry_id: Scalars['String'];
|
||||
/** List of binary interface Ids within the assembly (it points to interface id collection). */
|
||||
readonly interface_ids?: Maybe<ReadonlyArray<Maybe<Scalars['String']>>>;
|
||||
/**
|
||||
* A unique identifier for each object in this assembly container formed by
|
||||
* a dash separated concatenation of entry and assembly identifiers.
|
||||
@@ -7010,6 +7064,24 @@ export type RcsbAssemblyInfo = {
|
||||
* This is the total count of non-polymer entity instances generated in the assembly coordinate data.
|
||||
*/
|
||||
readonly nonpolymer_entity_instance_count?: Maybe<Scalars['Int']>;
|
||||
/** Number of heterologous (both binding sites are different) interface entities */
|
||||
readonly num_heterologous_interface_entities?: Maybe<Scalars['Int']>;
|
||||
/** Number of heteromeric (both partners are different polymeric entities) interface entities */
|
||||
readonly num_heteromeric_interface_entities?: Maybe<Scalars['Int']>;
|
||||
/** Number of homomeric (both partners are the same polymeric entity) interface entities */
|
||||
readonly num_homomeric_interface_entities?: Maybe<Scalars['Int']>;
|
||||
/** Number of polymer-polymer interface entities, grouping equivalent interfaces at the entity level (i.e. same entity_ids on either side, with similar but not identical binding sites) */
|
||||
readonly num_interface_entities?: Maybe<Scalars['Int']>;
|
||||
/** Number of geometrically equivalent (i.e. same asym_ids on either side) polymer-polymer interfaces in the assembly */
|
||||
readonly num_interfaces?: Maybe<Scalars['Int']>;
|
||||
/** Number of isologous (both binding sites are same, i.e. interface is symmetric) interface entities */
|
||||
readonly num_isologous_interface_entities?: Maybe<Scalars['Int']>;
|
||||
/** Number of nucleic acid-nucleic acid interface entities */
|
||||
readonly num_na_interface_entities?: Maybe<Scalars['Int']>;
|
||||
/** Number of protein-nucleic acid interface entities */
|
||||
readonly num_prot_na_interface_entities?: Maybe<Scalars['Int']>;
|
||||
/** Number of protein-protein interface entities */
|
||||
readonly num_protein_interface_entities?: Maybe<Scalars['Int']>;
|
||||
/** The assembly non-hydrogen polymer entity atomic coordinate count. */
|
||||
readonly polymer_atom_count?: Maybe<Scalars['Int']>;
|
||||
/**
|
||||
@@ -7085,6 +7157,10 @@ export type RcsbAssemblyInfo = {
|
||||
* This is the total count of solvent entity instances generated in the assembly coordinate data.
|
||||
*/
|
||||
readonly solvent_entity_instance_count?: Maybe<Scalars['Int']>;
|
||||
/** Total buried surface area calculated as the sum of buried surface areas over all interfaces */
|
||||
readonly total_assembly_buried_surface_area?: Maybe<Scalars['Float']>;
|
||||
/** Total number of interfacing residues in the assembly, calculated as the sum of interfacing residues over all interfaces */
|
||||
readonly total_number_interface_residues?: Maybe<Scalars['Int']>;
|
||||
/**
|
||||
* The number of unmodeled polymer monomers in the assembly coordinate data. This is
|
||||
* the total count of monomers with unreported coordinate data for all polymer
|
||||
@@ -8817,6 +8893,99 @@ export type RcsbGenomicLineage = {
|
||||
readonly name?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type RcsbInterfaceContainerIdentifiers = {
|
||||
/** This item references an assembly in pdbx_struct_assembly */
|
||||
readonly assembly_id: Scalars['String'];
|
||||
/** Entry identifier for the container. */
|
||||
readonly entry_id: Scalars['String'];
|
||||
/**
|
||||
* Identifier for NCS-equivalent interfaces within the assembly (same entity_ids on both sides)
|
||||
*
|
||||
* Examples:
|
||||
* 1, 2
|
||||
*
|
||||
*/
|
||||
readonly interface_entity_id?: Maybe<Scalars['String']>;
|
||||
/**
|
||||
* Identifier for the geometrically equivalent (same asym_ids on either side) interfaces within the assembly
|
||||
*
|
||||
* Examples:
|
||||
* 1, 2
|
||||
*
|
||||
*/
|
||||
readonly interface_id: Scalars['String'];
|
||||
/**
|
||||
* Unique identifier for the document
|
||||
*
|
||||
* Examples:
|
||||
* 2UZI-1.A.B?1
|
||||
*
|
||||
*/
|
||||
readonly rcsb_id: Scalars['String'];
|
||||
};
|
||||
|
||||
export type RcsbInterfaceInfo = {
|
||||
/** Total interface buried surface area */
|
||||
readonly interface_area?: Maybe<Scalars['Float']>;
|
||||
/** Allowable values: homo, hetero. */
|
||||
readonly interface_character?: Maybe<Scalars['String']>;
|
||||
/** Number of core interface residues, defined as those that bury >90% accessible surface area with respect to the unbound state */
|
||||
readonly num_core_interface_residues?: Maybe<Scalars['Int']>;
|
||||
/** Number of interface residues, defined as those with burial fraction > 0 */
|
||||
readonly num_interface_residues?: Maybe<Scalars['Int']>;
|
||||
/** Allowable values: Nucleic acid (only), Protein (only), Protein/NA. */
|
||||
readonly polymer_composition?: Maybe<Scalars['String']>;
|
||||
/** The Jaccard score (intersection over union) of interface contacts in homomeric interfaces, comparing contact sets left-right vs right-left. High values indicate isologous (symmetric) interfaces, with value=1 if perfectly symmetric (e.g. crystallographic symmetry) */
|
||||
readonly self_jaccard_contact_score?: Maybe<Scalars['Float']>;
|
||||
};
|
||||
|
||||
export type RcsbInterfacePartner = {
|
||||
readonly interface_partner_feature?: Maybe<ReadonlyArray<Maybe<RcsbInterfacePartnerInterfacePartnerFeature>>>;
|
||||
readonly interface_partner_identifier?: Maybe<RcsbInterfacePartnerInterfacePartnerIdentifier>;
|
||||
};
|
||||
|
||||
export type RcsbInterfacePartnerInterfacePartnerFeature = {
|
||||
readonly additional_properties?: Maybe<ReadonlyArray<Maybe<InterfacePartnerFeatureAdditionalProperties>>>;
|
||||
/**
|
||||
* Identifies the version of the feature assignment.
|
||||
*
|
||||
* Examples:
|
||||
* V4_0_2
|
||||
*
|
||||
*/
|
||||
readonly assignment_version?: Maybe<Scalars['String']>;
|
||||
/** A description for the feature. */
|
||||
readonly description?: Maybe<Scalars['String']>;
|
||||
/** An identifier for the feature. */
|
||||
readonly feature_id?: Maybe<Scalars['String']>;
|
||||
readonly feature_positions?: Maybe<ReadonlyArray<Maybe<InterfacePartnerFeatureFeaturePositions>>>;
|
||||
/** A name for the feature. */
|
||||
readonly name?: Maybe<Scalars['String']>;
|
||||
/**
|
||||
* Code identifying the individual, organization or program that assigned the feature.
|
||||
*
|
||||
* Examples:
|
||||
* NACCESS
|
||||
*
|
||||
*/
|
||||
readonly provenance_source?: Maybe<Scalars['String']>;
|
||||
/**
|
||||
* A type or category of the feature.
|
||||
*
|
||||
* Allowable values:
|
||||
* ASA_UNBOUND, ASA_BOUND
|
||||
*
|
||||
*/
|
||||
readonly type?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type RcsbInterfacePartnerInterfacePartnerIdentifier = {
|
||||
/** Instance identifier for this container. */
|
||||
readonly asym_id: Scalars['String'];
|
||||
/** Polymer entity identifier for the container. */
|
||||
readonly entity_id: Scalars['String'];
|
||||
};
|
||||
|
||||
export type RcsbLatestRevision = {
|
||||
/** The major version number of the latest revision. */
|
||||
readonly major_revision?: Maybe<Scalars['Int']>;
|
||||
@@ -10263,7 +10432,7 @@ export type RcsbPolymerInstanceFeature = {
|
||||
* A type or category of the feature.
|
||||
*
|
||||
* Allowable values:
|
||||
* ANGLE_OUTLIER, BINDING_SITE, BOND_OUTLIER, C-MANNOSYLATION_SITE, CATH, CIS-PEPTIDE, ECOD, HELIX_P, MEMBRANE_SEGMENT, MOGUL_ANGLE_OUTLIER, MOGUL_BOND_OUTLIER, N-GLYCOSYLATION_SITE, O-GLYCOSYLATION_SITE, RAMACHANDRAN_OUTLIER, ROTAMER_OUTLIER, RSCC_OUTLIER, RSRZ_OUTLIER, S-GLYCOSYLATION_SITE, SABDAB_ANTIBODY_HEAVY_CHAIN_SUBCLASS, SABDAB_ANTIBODY_LIGHT_CHAIN_SUBCLASS, SABDAB_ANTIBODY_LIGHT_CHAIN_TYPE, SCOP, SCOP2B_SUPERFAMILY, SCOP2_FAMILY, SCOP2_SUPERFAMILY, SHEET, STEREO_OUTLIER, UNASSIGNED_SEC_STRUCT, UNOBSERVED_ATOM_XYZ, UNOBSERVED_RESIDUE_XYZ, ZERO_OCCUPANCY_ATOM_XYZ, ZERO_OCCUPANCY_RESIDUE_XYZ
|
||||
* ANGLE_OUTLIER, BINDING_SITE, BOND_OUTLIER, C-MANNOSYLATION_SITE, CATH, CIS-PEPTIDE, ECOD, HELIX_P, MEMBRANE_SEGMENT, MOGUL_ANGLE_OUTLIER, MOGUL_BOND_OUTLIER, N-GLYCOSYLATION_SITE, O-GLYCOSYLATION_SITE, RAMACHANDRAN_OUTLIER, ROTAMER_OUTLIER, RSCC_OUTLIER, RSRZ_OUTLIER, S-GLYCOSYLATION_SITE, SABDAB_ANTIBODY_HEAVY_CHAIN_SUBCLASS, SABDAB_ANTIBODY_LIGHT_CHAIN_SUBCLASS, SABDAB_ANTIBODY_LIGHT_CHAIN_TYPE, SCOP, SCOP2B_SUPERFAMILY, SCOP2_FAMILY, SCOP2_SUPERFAMILY, SHEET, STEREO_OUTLIER, UNASSIGNED_SEC_STRUCT, UNOBSERVED_ATOM_XYZ, UNOBSERVED_RESIDUE_XYZ, ZERO_OCCUPANCY_ATOM_XYZ, ZERO_OCCUPANCY_RESIDUE_XYZ, ASA
|
||||
*
|
||||
*/
|
||||
readonly type?: Maybe<Scalars['String']>;
|
||||
@@ -13145,4 +13314,4 @@ export type AssemblySymmetryQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type AssemblySymmetryQuery = { readonly assembly?: { readonly rcsb_struct_symmetry?: ReadonlyArray<{ readonly kind: string, readonly oligomeric_state: string, readonly stoichiometry: ReadonlyArray<string | null | undefined>, readonly symbol: string, readonly type: string, readonly clusters: ReadonlyArray<{ readonly avg_rmsd?: number | null | undefined, readonly members: ReadonlyArray<{ readonly asym_id: string, readonly pdbx_struct_oper_list_ids?: ReadonlyArray<string | null | undefined> | null | undefined } | null | undefined> } | null | undefined>, readonly rotation_axes?: ReadonlyArray<{ readonly order?: number | null | undefined, readonly start: ReadonlyArray<number | null | undefined>, readonly end: ReadonlyArray<number | null | undefined> } | null | undefined> | null | undefined } | null | undefined> | null | undefined } | null | undefined };
|
||||
export type AssemblySymmetryQuery = { readonly assembly?: { readonly rcsb_struct_symmetry?: ReadonlyArray<{ readonly kind: string, readonly oligomeric_state: string, readonly stoichiometry: ReadonlyArray<string | null>, readonly symbol: string, readonly type: string, readonly clusters: ReadonlyArray<{ readonly avg_rmsd?: number | null, readonly members: ReadonlyArray<{ readonly asym_id: string, readonly pdbx_struct_oper_list_ids?: ReadonlyArray<string | null> | null } | null> } | null>, readonly rotation_axes?: ReadonlyArray<{ readonly order?: number | null, readonly start: ReadonlyArray<number | null>, readonly end: ReadonlyArray<number | null> } | null> | null } | null> | null } | null };
|
||||
|
||||
@@ -236,7 +236,7 @@ interface Canvas3D {
|
||||
/** Sets drawPaused = false without starting the built in animation loop */
|
||||
resume(): void
|
||||
identify(x: number, y: number): PickData | undefined
|
||||
mark(loci: Representation.Loci, action: MarkerAction, noDraw?: boolean): void
|
||||
mark(loci: Representation.Loci, action: MarkerAction): void
|
||||
getLoci(pickingId: PickingId | undefined): Representation.Loci
|
||||
|
||||
notifyDidDraw: boolean,
|
||||
@@ -345,7 +345,30 @@ namespace Canvas3D {
|
||||
return { loci, repr };
|
||||
}
|
||||
|
||||
function mark(reprLoci: Representation.Loci, action: MarkerAction, noDraw = false) {
|
||||
let markBuffer: [reprLoci: Representation.Loci, action: MarkerAction][] = [];
|
||||
|
||||
function mark(reprLoci: Representation.Loci, action: MarkerAction) {
|
||||
// NOTE: might try to optimize a case with opposite actions for the
|
||||
// same loci. Tho this might end up being more expensive (and error prone)
|
||||
// then just applying everything "naively".
|
||||
markBuffer.push([reprLoci, action]);
|
||||
}
|
||||
|
||||
function resolveMarking() {
|
||||
let changed = false;
|
||||
for (const [r, l] of markBuffer) {
|
||||
changed = applyMark(r, l) || changed;
|
||||
}
|
||||
markBuffer = [];
|
||||
if (changed) {
|
||||
scene.update(void 0, true);
|
||||
helper.handle.scene.update(void 0, true);
|
||||
helper.camera.scene.update(void 0, true);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
function applyMark(reprLoci: Representation.Loci, action: MarkerAction) {
|
||||
const { repr, loci } = reprLoci;
|
||||
let changed = false;
|
||||
if (repr) {
|
||||
@@ -355,24 +378,10 @@ namespace Canvas3D {
|
||||
changed = helper.camera.mark(loci, action) || changed;
|
||||
reprRenderObjects.forEach((_, _repr) => { changed = _repr.mark(loci, action) || changed; });
|
||||
}
|
||||
if (changed) {
|
||||
if (noDraw) {
|
||||
// Even with `noDraw` make sure changes will be rendered.
|
||||
// Note that with this calling mark (with or without `noDraw`) multiple times
|
||||
// during a JS event loop iteration will only result in a single render call.
|
||||
forceNextRender = true;
|
||||
} else {
|
||||
scene.update(void 0, true);
|
||||
helper.handle.scene.update(void 0, true);
|
||||
helper.camera.scene.update(void 0, true);
|
||||
const prevPickDirty = pickHelper.dirty;
|
||||
draw({ force: true, allowMulti: true });
|
||||
pickHelper.dirty = prevPickDirty; // marking does not change picking buffers
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
function render(force: boolean, allowMulti: boolean) {
|
||||
function render(force: boolean) {
|
||||
if (webgl.isContextLost) return false;
|
||||
|
||||
let resized = false;
|
||||
@@ -386,6 +395,8 @@ namespace Canvas3D {
|
||||
y > gl.drawingBufferHeight || y + height < 0
|
||||
) return false;
|
||||
|
||||
const markingUpdated = resolveMarking();
|
||||
|
||||
let didRender = false;
|
||||
controls.update(currentTime);
|
||||
const cameraChanged = camera.update();
|
||||
@@ -393,9 +404,9 @@ namespace Canvas3D {
|
||||
const shouldRender = force || cameraChanged || resized || forceNextRender;
|
||||
forceNextRender = false;
|
||||
|
||||
const multiSampleChanged = multiSampleHelper.update(shouldRender, p.multiSample);
|
||||
const multiSampleChanged = multiSampleHelper.update(markingUpdated || shouldRender, p.multiSample);
|
||||
|
||||
if (shouldRender || multiSampleChanged) {
|
||||
if (shouldRender || multiSampleChanged || markingUpdated) {
|
||||
let cam: Camera | StereoCamera = camera;
|
||||
if (p.camera.stereo.name === 'on') {
|
||||
stereoCamera.update();
|
||||
@@ -404,12 +415,13 @@ namespace Canvas3D {
|
||||
|
||||
const ctx = { renderer, camera: cam, scene, helper };
|
||||
if (MultiSamplePass.isEnabled(p.multiSample)) {
|
||||
const forceOn = !cameraChanged && allowMulti && !controls.isAnimating;
|
||||
const forceOn = !cameraChanged && markingUpdated && !controls.isAnimating;
|
||||
multiSampleHelper.render(ctx, p, true, forceOn);
|
||||
} else {
|
||||
passes.draw.render(ctx, p, true);
|
||||
}
|
||||
pickHelper.dirty = true;
|
||||
// if only marking has updated, do not set the flag to dirty
|
||||
pickHelper.dirty = pickHelper.dirty || shouldRender;
|
||||
didRender = true;
|
||||
}
|
||||
|
||||
@@ -421,9 +433,9 @@ namespace Canvas3D {
|
||||
let currentTime = 0;
|
||||
let drawPaused = false;
|
||||
|
||||
function draw(options?: { force?: boolean, allowMulti?: boolean }) {
|
||||
function draw(options?: { force?: boolean }) {
|
||||
if (drawPaused) return;
|
||||
if (render(!!options?.force, !!options?.allowMulti) && notifyDidDraw) {
|
||||
if (render(!!options?.force) && notifyDidDraw) {
|
||||
didDraw.next(now() - startTime as now.Timestamp);
|
||||
}
|
||||
}
|
||||
@@ -831,6 +843,8 @@ namespace Canvas3D {
|
||||
dispose: () => {
|
||||
contextRestoredSub.unsubscribe();
|
||||
|
||||
markBuffer = [];
|
||||
|
||||
scene.clear();
|
||||
helper.debug.clear();
|
||||
controls.dispose();
|
||||
|
||||
@@ -307,19 +307,22 @@ export class DrawPass {
|
||||
}
|
||||
|
||||
if (markingEnabled) {
|
||||
const markingDepthTest = props.marking.ghostEdgeStrength < 1;
|
||||
if (markingDepthTest) {
|
||||
this.marking.depthTarget.bind();
|
||||
const markerAverage = scene.getMarkerAverage();
|
||||
if (markerAverage > 0) {
|
||||
const markingDepthTest = props.marking.ghostEdgeStrength < 1;
|
||||
if (markingDepthTest && markerAverage !== 1) {
|
||||
this.marking.depthTarget.bind();
|
||||
renderer.clear(false, true);
|
||||
renderer.renderMarkingDepth(scene.primitives, camera, null);
|
||||
}
|
||||
|
||||
this.marking.maskTarget.bind();
|
||||
renderer.clear(false, true);
|
||||
renderer.renderMarkingDepth(scene.primitives, camera, null);
|
||||
renderer.renderMarkingMask(scene.primitives, camera, markingDepthTest ? this.marking.depthTarget.texture : null);
|
||||
|
||||
this.marking.update(props.marking);
|
||||
this.marking.render(camera.viewport, postprocessingEnabled ? this.postprocessing.target : this.colorTarget);
|
||||
}
|
||||
|
||||
this.marking.maskTarget.bind();
|
||||
renderer.clear(false, true);
|
||||
renderer.renderMarkingMask(scene.primitives, camera, markingDepthTest ? this.marking.depthTarget.texture : null);
|
||||
|
||||
this.marking.update(props.marking);
|
||||
this.marking.render(camera.viewport, postprocessingEnabled ? this.postprocessing.target : this.colorTarget);
|
||||
}
|
||||
|
||||
if (helper.debug.isEnabled) {
|
||||
|
||||
@@ -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>
|
||||
*/
|
||||
@@ -157,6 +157,14 @@ export class MultiSamplePass {
|
||||
ValueCell.update(compose.values.uWeight, sampleWeight);
|
||||
|
||||
// render scene
|
||||
if (i === 0) {
|
||||
drawPass.postprocessing.setOcclusionOffset(0, 0);
|
||||
} else {
|
||||
drawPass.postprocessing.setOcclusionOffset(
|
||||
offset[0] / width,
|
||||
offset[1] / height
|
||||
);
|
||||
}
|
||||
drawPass.render(ctx, props, false);
|
||||
|
||||
// compose rendered scene with compose target
|
||||
@@ -175,6 +183,8 @@ export class MultiSamplePass {
|
||||
compose.render();
|
||||
}
|
||||
|
||||
drawPass.postprocessing.setOcclusionOffset(0, 0);
|
||||
|
||||
ValueCell.update(compose.values.uWeight, 1.0);
|
||||
ValueCell.update(compose.values.tColor, composeTarget.texture);
|
||||
compose.update();
|
||||
@@ -236,6 +246,14 @@ export class MultiSamplePass {
|
||||
camera.update();
|
||||
|
||||
// render scene
|
||||
if (sampleIndex === 0) {
|
||||
drawPass.postprocessing.setOcclusionOffset(0, 0);
|
||||
} else {
|
||||
drawPass.postprocessing.setOcclusionOffset(
|
||||
offset[0] / width,
|
||||
offset[1] / height
|
||||
);
|
||||
}
|
||||
drawPass.render(ctx, props, false);
|
||||
|
||||
// compose rendered scene with compose target
|
||||
@@ -258,6 +276,8 @@ export class MultiSamplePass {
|
||||
}
|
||||
}
|
||||
|
||||
drawPass.postprocessing.setOcclusionOffset(0, 0);
|
||||
|
||||
this.bindOutputTarget(toDrawingBuffer);
|
||||
gl.viewport(x, y, width, height);
|
||||
gl.scissor(x, y, width, height);
|
||||
@@ -291,23 +311,23 @@ const JitterVectors = [
|
||||
[0, 0]
|
||||
],
|
||||
[
|
||||
[4, 4], [-4, -4]
|
||||
[0, 0], [-4, -4]
|
||||
],
|
||||
[
|
||||
[-2, -6], [6, -2], [-6, 2], [2, 6]
|
||||
[0, 0], [6, -2], [-6, 2], [2, 6]
|
||||
],
|
||||
[
|
||||
[1, -3], [-1, 3], [5, 1], [-3, -5],
|
||||
[0, 0], [-1, 3], [5, 1], [-3, -5],
|
||||
[-5, 5], [-7, -1], [3, 7], [7, -7]
|
||||
],
|
||||
[
|
||||
[1, 1], [-1, -3], [-3, 2], [4, -1],
|
||||
[0, 0], [-1, -3], [-3, 2], [4, -1],
|
||||
[-5, -2], [2, 5], [5, 3], [3, -5],
|
||||
[-2, 6], [0, -7], [-4, -6], [-6, 4],
|
||||
[-8, 0], [7, -4], [6, 7], [-7, -8]
|
||||
],
|
||||
[
|
||||
[-4, -7], [-7, -5], [-3, -5], [-5, -4],
|
||||
[0, 0], [-7, -5], [-3, -5], [-5, -4],
|
||||
[-1, -4], [-2, -2], [-6, -1], [-4, 0],
|
||||
[-7, 1], [-1, 2], [-6, 3], [-3, 3],
|
||||
[-7, 6], [-3, 6], [-5, 7], [-1, 7],
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
|
||||
import { QuadSchema, QuadValues } from '../../mol-gl/compute/util';
|
||||
import { CopyRenderable, createCopyRenderable, QuadSchema, QuadValues } from '../../mol-gl/compute/util';
|
||||
import { TextureSpec, Values, UniformSpec, DefineSpec } from '../../mol-gl/renderable/schema';
|
||||
import { ShaderCode } from '../../mol-gl/shader-code';
|
||||
import { WebGLContext } from '../../mol-gl/webgl/context';
|
||||
@@ -199,6 +199,7 @@ const PostprocessingSchema = {
|
||||
uMaxPossibleViewZDiff: UniformSpec('f'),
|
||||
|
||||
dOcclusionEnable: DefineSpec('boolean'),
|
||||
uOcclusionOffset: UniformSpec('v2'),
|
||||
|
||||
dOutlineEnable: DefineSpec('boolean'),
|
||||
dOutlineScale: DefineSpec('number'),
|
||||
@@ -227,6 +228,7 @@ function getPostprocessingRenderable(ctx: WebGLContext, colorTexture: Texture, d
|
||||
uMaxPossibleViewZDiff: ValueCell.create(0.5),
|
||||
|
||||
dOcclusionEnable: ValueCell.create(true),
|
||||
uOcclusionOffset: ValueCell.create(Vec2.create(0, 0)),
|
||||
|
||||
dOutlineEnable: ValueCell.create(false),
|
||||
dOutlineScale: ValueCell.create(1),
|
||||
@@ -244,9 +246,10 @@ export const PostprocessingParams = {
|
||||
occlusion: PD.MappedStatic('on', {
|
||||
on: PD.Group({
|
||||
samples: PD.Numeric(32, { min: 1, max: 256, step: 1 }),
|
||||
radius: PD.Numeric(5, { min: 0, max: 10, step: 0.1 }, { description: 'Final radius is 2^x.' }),
|
||||
radius: PD.Numeric(5, { min: 0, max: 10, step: 0.1 }, { description: 'Final occlusion radius is 2^x' }),
|
||||
bias: PD.Numeric(0.8, { min: 0, max: 3, step: 0.1 }),
|
||||
blurKernelSize: PD.Numeric(15, { min: 1, max: 25, step: 2 }),
|
||||
resolutionScale: PD.Numeric(1, { min: 0.1, max: 1, step: 0.05 }, { description: 'Adjust resolution of occlusion calculation' }),
|
||||
}),
|
||||
off: PD.Group({})
|
||||
}, { cycle: true, description: 'Darken occluded crevices with the ambient occlusion effect' }),
|
||||
@@ -281,6 +284,9 @@ export class PostprocessingPass {
|
||||
private readonly ssaoBlurFirstPassFramebuffer: Framebuffer;
|
||||
private readonly ssaoBlurSecondPassFramebuffer: Framebuffer;
|
||||
|
||||
private readonly downsampledDepthTarget: RenderTarget;
|
||||
private readonly downsampleDepthRenderable: CopyRenderable;
|
||||
|
||||
private readonly ssaoDepthTexture: Texture;
|
||||
private readonly ssaoDepthBlurProxyTexture: Texture;
|
||||
|
||||
@@ -290,24 +296,25 @@ export class PostprocessingPass {
|
||||
|
||||
private nSamples: number;
|
||||
private blurKernelSize: number;
|
||||
private downsampleFactor: number;
|
||||
|
||||
private readonly renderable: PostprocessingRenderable;
|
||||
|
||||
private ssaoScale: number;
|
||||
private calcSsaoScale() {
|
||||
// downscale ssao for high pixel-ratios
|
||||
return Math.min(1, 1 / this.webgl.pixelRatio);
|
||||
return Math.min(1, 1 / this.webgl.pixelRatio) * this.downsampleFactor;
|
||||
}
|
||||
|
||||
constructor(private webgl: WebGLContext, drawPass: DrawPass) {
|
||||
this.ssaoScale = this.calcSsaoScale();
|
||||
|
||||
constructor(private webgl: WebGLContext, private drawPass: DrawPass) {
|
||||
const { colorTarget, depthTexture } = drawPass;
|
||||
const width = colorTarget.getWidth();
|
||||
const height = colorTarget.getHeight();
|
||||
|
||||
this.nSamples = 1;
|
||||
this.blurKernelSize = 1;
|
||||
this.downsampleFactor = 1;
|
||||
this.ssaoScale = this.calcSsaoScale();
|
||||
|
||||
// needs to be linear for anti-aliasing pass
|
||||
this.target = webgl.createRenderTarget(width, height, false, 'uint8', 'linear');
|
||||
@@ -332,17 +339,20 @@ export class PostprocessingPass {
|
||||
const sw = Math.floor(width * this.ssaoScale);
|
||||
const sh = Math.floor(height * this.ssaoScale);
|
||||
|
||||
this.ssaoDepthTexture = webgl.resources.texture('image-uint8', 'rgba', 'ubyte', 'nearest');
|
||||
this.downsampledDepthTarget = webgl.createRenderTarget(sw, sh, false, 'uint8', 'linear');
|
||||
this.downsampleDepthRenderable = createCopyRenderable(webgl, depthTexture);
|
||||
|
||||
this.ssaoDepthTexture = webgl.resources.texture('image-uint8', 'rgba', 'ubyte', 'linear');
|
||||
this.ssaoDepthTexture.define(sw, sh);
|
||||
this.ssaoDepthTexture.attachFramebuffer(this.ssaoFramebuffer, 'color0');
|
||||
|
||||
this.ssaoDepthBlurProxyTexture = webgl.resources.texture('image-uint8', 'rgba', 'ubyte', 'nearest');
|
||||
this.ssaoDepthBlurProxyTexture = webgl.resources.texture('image-uint8', 'rgba', 'ubyte', 'linear');
|
||||
this.ssaoDepthBlurProxyTexture.define(sw, sh);
|
||||
this.ssaoDepthBlurProxyTexture.attachFramebuffer(this.ssaoBlurFirstPassFramebuffer, 'color0');
|
||||
|
||||
this.ssaoDepthTexture.attachFramebuffer(this.ssaoBlurSecondPassFramebuffer, 'color0');
|
||||
|
||||
this.ssaoRenderable = getSsaoRenderable(webgl, depthTexture);
|
||||
this.ssaoRenderable = getSsaoRenderable(webgl, this.downsampleFactor === 1 ? depthTexture : this.downsampledDepthTarget.texture);
|
||||
this.ssaoBlurFirstPassRenderable = getSsaoBlurRenderable(webgl, this.ssaoDepthTexture, 'horizontal');
|
||||
this.ssaoBlurSecondPassRenderable = getSsaoBlurRenderable(webgl, this.ssaoDepthBlurProxyTexture, 'vertical');
|
||||
this.renderable = getPostprocessingRenderable(webgl, colorTarget.texture, depthTexture, this.outlinesTarget.texture, this.ssaoDepthTexture);
|
||||
@@ -359,11 +369,13 @@ export class PostprocessingPass {
|
||||
const sh = Math.floor(height * this.ssaoScale);
|
||||
this.target.setSize(width, height);
|
||||
this.outlinesTarget.setSize(width, height);
|
||||
this.downsampledDepthTarget.setSize(sw, sh);
|
||||
this.ssaoDepthTexture.define(sw, sh);
|
||||
this.ssaoDepthBlurProxyTexture.define(sw, sh);
|
||||
|
||||
ValueCell.update(this.renderable.values.uTexSize, Vec2.set(this.renderable.values.uTexSize.ref.value, width, height));
|
||||
ValueCell.update(this.outlinesRenderable.values.uTexSize, Vec2.set(this.outlinesRenderable.values.uTexSize.ref.value, width, height));
|
||||
ValueCell.update(this.downsampleDepthRenderable.values.uTexSize, Vec2.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, sw, sh));
|
||||
ValueCell.update(this.ssaoRenderable.values.uTexSize, Vec2.set(this.ssaoRenderable.values.uTexSize.ref.value, sw, sh));
|
||||
ValueCell.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, Vec2.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, sw, sh));
|
||||
ValueCell.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, Vec2.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, sw, sh));
|
||||
@@ -434,6 +446,30 @@ export class PostprocessingPass {
|
||||
ValueCell.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize);
|
||||
}
|
||||
|
||||
if (this.downsampleFactor !== props.occlusion.params.resolutionScale) {
|
||||
needsUpdateSsao = true;
|
||||
|
||||
this.downsampleFactor = props.occlusion.params.resolutionScale;
|
||||
this.ssaoScale = this.calcSsaoScale();
|
||||
|
||||
const sw = Math.floor(w * this.ssaoScale);
|
||||
const sh = Math.floor(h * this.ssaoScale);
|
||||
|
||||
this.downsampledDepthTarget.setSize(sw, sh);
|
||||
this.ssaoDepthTexture.define(sw, sh);
|
||||
this.ssaoDepthBlurProxyTexture.define(sw, sh);
|
||||
|
||||
if (this.ssaoScale === 1) {
|
||||
ValueCell.update(this.ssaoRenderable.values.tDepth, this.drawPass.depthTexture);
|
||||
} else {
|
||||
ValueCell.update(this.ssaoRenderable.values.tDepth, this.downsampledDepthTarget.texture);
|
||||
}
|
||||
|
||||
ValueCell.update(this.downsampleDepthRenderable.values.uTexSize, Vec2.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, sw, sh));
|
||||
ValueCell.update(this.ssaoRenderable.values.uTexSize, Vec2.set(this.ssaoRenderable.values.uTexSize.ref.value, sw, sh));
|
||||
ValueCell.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, Vec2.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, sw, sh));
|
||||
ValueCell.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, Vec2.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, sw, sh));
|
||||
}
|
||||
}
|
||||
|
||||
if (props.outline.name === 'on') {
|
||||
@@ -494,6 +530,13 @@ export class PostprocessingPass {
|
||||
gl.scissor(x, y, width, height);
|
||||
}
|
||||
|
||||
private occlusionOffset: [x: number, y: number] = [0, 0];
|
||||
setOcclusionOffset(x: number, y: number) {
|
||||
this.occlusionOffset[0] = x;
|
||||
this.occlusionOffset[1] = y;
|
||||
ValueCell.update(this.renderable.values.uOcclusionOffset, Vec2.set(this.renderable.values.uOcclusionOffset.ref.value, x, y));
|
||||
}
|
||||
|
||||
render(camera: ICamera, toDrawingBuffer: boolean, transparentBackground: boolean, backgroundColor: Color, props: PostprocessingProps) {
|
||||
this.updateState(camera, transparentBackground, backgroundColor, props);
|
||||
|
||||
@@ -502,14 +545,13 @@ export class PostprocessingPass {
|
||||
this.outlinesRenderable.render();
|
||||
}
|
||||
|
||||
if (props.occlusion.name === 'on') {
|
||||
const { x, y, width, height } = camera.viewport;
|
||||
const sx = Math.floor(x * this.ssaoScale);
|
||||
const sy = Math.floor(y * this.ssaoScale);
|
||||
const sw = Math.ceil(width * this.ssaoScale);
|
||||
const sh = Math.ceil(height * this.ssaoScale);
|
||||
this.webgl.gl.viewport(sx, sy, sw, sh);
|
||||
this.webgl.gl.scissor(sx, sy, sw, sh);
|
||||
// don't render occlusion if offset is given,
|
||||
// which will reuse the existing occlusion
|
||||
if (props.occlusion.name === 'on' && this.occlusionOffset[0] === 0 && this.occlusionOffset[1] === 0) {
|
||||
if (this.ssaoScale < 1) {
|
||||
this.downsampledDepthTarget.bind();
|
||||
this.downsampleDepthRenderable.render();
|
||||
}
|
||||
|
||||
this.ssaoFramebuffer.bind();
|
||||
this.ssaoRenderable.render();
|
||||
@@ -519,9 +561,6 @@ export class PostprocessingPass {
|
||||
|
||||
this.ssaoBlurSecondPassFramebuffer.bind();
|
||||
this.ssaoBlurSecondPassRenderable.render();
|
||||
|
||||
this.webgl.gl.viewport(x, y, width, height);
|
||||
this.webgl.gl.scissor(x, y, width, height);
|
||||
}
|
||||
|
||||
if (toDrawingBuffer) {
|
||||
|
||||
@@ -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>
|
||||
*/
|
||||
@@ -165,7 +165,7 @@ export namespace Lines {
|
||||
|
||||
export const Params = {
|
||||
...BaseGeometry.Params,
|
||||
sizeFactor: PD.Numeric(3, { min: 0, max: 10, step: 0.1 }),
|
||||
sizeFactor: PD.Numeric(2, { min: 0, max: 10, step: 0.1 }),
|
||||
lineSizeAttenuation: PD.Boolean(false),
|
||||
};
|
||||
export type Params = typeof Params
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('renderer', () => {
|
||||
expect(ctx.gl.drawingBufferHeight).toBe(32);
|
||||
|
||||
expect(ctx.stats.resourceCounts.attribute).toBe(0);
|
||||
expect(ctx.stats.resourceCounts.texture).toBe(0);
|
||||
expect(ctx.stats.resourceCounts.texture).toBe(1);
|
||||
expect(ctx.stats.resourceCounts.vertexArray).toBe(0);
|
||||
expect(ctx.stats.resourceCounts.program).toBe(0);
|
||||
expect(ctx.stats.resourceCounts.shader).toBe(0);
|
||||
@@ -52,7 +52,7 @@ describe('renderer', () => {
|
||||
scene.add(points);
|
||||
scene.commit();
|
||||
expect(ctx.stats.resourceCounts.attribute).toBe(ctx.isWebGL2 ? 4 : 5);
|
||||
expect(ctx.stats.resourceCounts.texture).toBe(8);
|
||||
expect(ctx.stats.resourceCounts.texture).toBe(9);
|
||||
expect(ctx.stats.resourceCounts.vertexArray).toBe(ctx.extensions.vertexArrayObject ? 5 : 0);
|
||||
expect(ctx.stats.resourceCounts.program).toBe(5);
|
||||
expect(ctx.stats.resourceCounts.shader).toBe(10);
|
||||
@@ -60,7 +60,7 @@ describe('renderer', () => {
|
||||
scene.remove(points);
|
||||
scene.commit();
|
||||
expect(ctx.stats.resourceCounts.attribute).toBe(0);
|
||||
expect(ctx.stats.resourceCounts.texture).toBe(0);
|
||||
expect(ctx.stats.resourceCounts.texture).toBe(1);
|
||||
expect(ctx.stats.resourceCounts.vertexArray).toBe(0);
|
||||
expect(ctx.stats.resourceCounts.program).toBe(5);
|
||||
expect(ctx.stats.resourceCounts.shader).toBe(10);
|
||||
|
||||
@@ -16,7 +16,7 @@ import { GlobalUniformValues } from './renderable/schema';
|
||||
import { GraphicsRenderVariant } from './webgl/render-item';
|
||||
import { ParamDefinition as PD } from '../mol-util/param-definition';
|
||||
import { degToRad } from '../mol-math/misc';
|
||||
import { createNullTexture, Texture, Textures } from './webgl/texture';
|
||||
import { Texture, Textures } from './webgl/texture';
|
||||
import { arrayMapUpsert } from '../mol-util/array';
|
||||
import { clamp } from '../mol-math/interpolate';
|
||||
|
||||
@@ -146,9 +146,9 @@ namespace Renderer {
|
||||
|
||||
let transparentBackground = false;
|
||||
|
||||
const nullDepthTexture = createNullTexture(gl);
|
||||
const emptyDepthTexture = ctx.resources.texture('image-depth', 'depth', 'ushort', 'nearest');
|
||||
const sharedTexturesList: Textures = [
|
||||
['tDepth', nullDepthTexture]
|
||||
['tDepth', emptyDepthTexture]
|
||||
];
|
||||
|
||||
const view = Mat4();
|
||||
@@ -309,7 +309,7 @@ namespace Renderer {
|
||||
};
|
||||
|
||||
const updateInternal = (group: Scene.Group, camera: ICamera, depthTexture: Texture | null, renderWboit: boolean, markingDepthTest: boolean) => {
|
||||
arrayMapUpsert(sharedTexturesList, 'tDepth', depthTexture || nullDepthTexture);
|
||||
arrayMapUpsert(sharedTexturesList, 'tDepth', depthTexture || emptyDepthTexture);
|
||||
|
||||
ValueCell.update(globalUniforms.uModel, group.view);
|
||||
ValueCell.update(globalUniforms.uModelView, Mat4.mul(modelView, group.view, camera.view));
|
||||
|
||||
@@ -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>
|
||||
@@ -79,6 +79,7 @@ interface Scene extends Object3D {
|
||||
has: (o: GraphicsRenderObject) => boolean
|
||||
clear: () => void
|
||||
forEach: (callbackFn: (value: GraphicsRenderable, key: GraphicsRenderObject) => void) => void
|
||||
getMarkerAverage: () => number
|
||||
}
|
||||
|
||||
namespace Scene {
|
||||
@@ -243,7 +244,18 @@ namespace Scene {
|
||||
visibleHash = computeVisibleHash();
|
||||
}
|
||||
return boundingSphereVisible;
|
||||
}
|
||||
},
|
||||
getMarkerAverage() {
|
||||
if (primitives.length === 0 && volumes.length === 0) return 0;
|
||||
let markerAverage = 0;
|
||||
for (let i = 0, il = primitives.length; i < il; ++i) {
|
||||
markerAverage += primitives[i].values.markerAverage.ref.value;
|
||||
}
|
||||
for (let i = 0, il = volumes.length; i < il; ++i) {
|
||||
markerAverage += volumes[i].values.markerAverage.ref.value;
|
||||
}
|
||||
return markerAverage / (primitives.length + volumes.length);
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*
|
||||
@@ -8,61 +8,65 @@
|
||||
*/
|
||||
|
||||
export const apply_light_color = `
|
||||
#ifdef bumpEnabled
|
||||
if (uBumpFrequency > 0.0 && uBumpAmplitude > 0.0) {
|
||||
vec3 bumpNormal = perturbNormal(-vViewPosition, normal, fbm(vModelPosition * uBumpFrequency), (uBumpAmplitude * bumpiness) / uBumpFrequency);
|
||||
#ifdef enabledFragDepth
|
||||
if (!isNaN(bumpNormal.x) && !isNaN(bumpNormal.y) && !isNaN(bumpNormal.z)) {
|
||||
normal = bumpNormal;
|
||||
}
|
||||
#else
|
||||
normal = bumpNormal;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
vec4 color = material;
|
||||
|
||||
ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));
|
||||
|
||||
PhysicalMaterial physicalMaterial;
|
||||
physicalMaterial.diffuseColor = color.rgb * (1.0 - metalness);
|
||||
#ifdef enabledFragDepth
|
||||
physicalMaterial.roughness = min(max(roughness, 0.0525), 1.0);
|
||||
#ifdef dIgnoreLight
|
||||
gl_FragColor = material;
|
||||
#else
|
||||
vec3 dxy = max(abs(dFdx(normal)), abs(dFdy(normal)));
|
||||
float geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);
|
||||
physicalMaterial.roughness = min(max(roughness, 0.0525) + geometryRoughness, 1.0);
|
||||
#ifdef bumpEnabled
|
||||
if (uBumpFrequency > 0.0 && uBumpAmplitude > 0.0) {
|
||||
vec3 bumpNormal = perturbNormal(-vViewPosition, normal, fbm(vModelPosition * uBumpFrequency), (uBumpAmplitude * bumpiness) / uBumpFrequency);
|
||||
#ifdef enabledFragDepth
|
||||
if (!isNaN(bumpNormal.x) && !isNaN(bumpNormal.y) && !isNaN(bumpNormal.z)) {
|
||||
normal = bumpNormal;
|
||||
}
|
||||
#else
|
||||
normal = bumpNormal;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
vec4 color = material;
|
||||
|
||||
ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));
|
||||
|
||||
PhysicalMaterial physicalMaterial;
|
||||
physicalMaterial.diffuseColor = color.rgb * (1.0 - metalness);
|
||||
#ifdef enabledFragDepth
|
||||
physicalMaterial.roughness = min(max(roughness, 0.0525), 1.0);
|
||||
#else
|
||||
vec3 dxy = max(abs(dFdx(normal)), abs(dFdy(normal)));
|
||||
float geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);
|
||||
physicalMaterial.roughness = min(max(roughness, 0.0525) + geometryRoughness, 1.0);
|
||||
#endif
|
||||
physicalMaterial.specularColor = mix(vec3(0.04), color.rgb, metalness);
|
||||
physicalMaterial.specularF90 = 1.0;
|
||||
|
||||
GeometricContext geometry;
|
||||
geometry.position = -vViewPosition;
|
||||
geometry.normal = normal;
|
||||
geometry.viewDir = normalize(vViewPosition);
|
||||
|
||||
IncidentLight directLight;
|
||||
#pragma unroll_loop_start
|
||||
for (int i = 0; i < dLightCount; ++i) {
|
||||
directLight.direction = uLightDirection[i];
|
||||
directLight.color = uLightColor[i] * PI; // * PI for punctual light
|
||||
RE_Direct_Physical(directLight, geometry, physicalMaterial, reflectedLight);
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
vec3 irradiance = uAmbientColor * PI; // * PI for punctual light
|
||||
RE_IndirectDiffuse_Physical(irradiance, geometry, physicalMaterial, reflectedLight);
|
||||
|
||||
// indirect specular only metals
|
||||
vec3 radiance = uAmbientColor * metalness;
|
||||
vec3 iblIrradiance = uAmbientColor * metalness;
|
||||
vec3 clearcoatRadiance = vec3(0.0);
|
||||
RE_IndirectSpecular_Physical(radiance, iblIrradiance, clearcoatRadiance, geometry, physicalMaterial, reflectedLight);
|
||||
|
||||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
||||
|
||||
gl_FragColor = vec4(outgoingLight, color.a);
|
||||
#endif
|
||||
physicalMaterial.specularColor = mix(vec3(0.04), color.rgb, metalness);
|
||||
physicalMaterial.specularF90 = 1.0;
|
||||
|
||||
GeometricContext geometry;
|
||||
geometry.position = -vViewPosition;
|
||||
geometry.normal = normal;
|
||||
geometry.viewDir = normalize(vViewPosition);
|
||||
|
||||
IncidentLight directLight;
|
||||
#pragma unroll_loop_start
|
||||
for (int i = 0; i < dLightCount; ++i) {
|
||||
directLight.direction = uLightDirection[i];
|
||||
directLight.color = uLightColor[i] * PI; // * PI for punctual light
|
||||
RE_Direct_Physical(directLight, geometry, physicalMaterial, reflectedLight);
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
vec3 irradiance = uAmbientColor * PI; // * PI for punctual light
|
||||
RE_IndirectDiffuse_Physical(irradiance, geometry, physicalMaterial, reflectedLight);
|
||||
|
||||
// indirect specular only metals
|
||||
vec3 radiance = uAmbientColor * metalness;
|
||||
vec3 iblIrradiance = uAmbientColor * metalness;
|
||||
vec3 clearcoatRadiance = vec3(0.0);
|
||||
RE_IndirectSpecular_Physical(radiance, iblIrradiance, clearcoatRadiance, geometry, physicalMaterial, reflectedLight);
|
||||
|
||||
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
||||
|
||||
gl_FragColor = vec4(outgoingLight, color.a);
|
||||
|
||||
#ifdef dXrayShaded
|
||||
gl_FragColor.a *= 1.0 - pow(abs(dot(normal, vec3(0.0, 0.0, 1.0))), uXrayEdgeFalloff);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* 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 Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -127,13 +127,9 @@ void main() {
|
||||
#elif defined(dRenderVariant_marking)
|
||||
gl_FragColor = material;
|
||||
#elif defined(dRenderVariant_color)
|
||||
#ifdef dIgnoreLight
|
||||
gl_FragColor = material;
|
||||
#else
|
||||
mat3 normalMatrix = transpose3(inverse3(mat3(uView)));
|
||||
vec3 normal = normalize(normalMatrix * -normalize(intersection.yzw));
|
||||
#include apply_light_color
|
||||
#endif
|
||||
mat3 normalMatrix = transpose3(inverse3(mat3(uView)));
|
||||
vec3 normal = normalize(normalMatrix * -normalize(intersection.yzw));
|
||||
#include apply_light_color
|
||||
|
||||
#include apply_interior_color
|
||||
#include apply_marker_color
|
||||
|
||||
@@ -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 Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
* @author Michael Krone <michael.krone@uni-tuebingen.de>
|
||||
@@ -166,9 +166,7 @@ vec3 v3m4(vec3 p, mat4 m) {
|
||||
float preFogAlphaBlended = 0.0;
|
||||
|
||||
vec4 raymarch(vec3 startLoc, vec3 step, vec3 rayDir) {
|
||||
#if !defined(dIgnoreLight)
|
||||
mat3 normalMatrix = transpose3(inverse3(mat3(uModelView * vTransform)));
|
||||
#endif
|
||||
mat3 normalMatrix = transpose3(inverse3(mat3(uModelView * vTransform)));
|
||||
mat4 cartnToUnit = uCartnToUnit * inverse4(vTransform);
|
||||
#if defined(dClipVariant_pixel) && dClipObjectCount != 0
|
||||
mat4 modelTransform = uModel * vTransform * uTransform;
|
||||
@@ -296,24 +294,20 @@ vec4 raymarch(vec3 startLoc, vec3 step, vec3 rayDir) {
|
||||
material.rgb = mix(material.rgb, overpaint.rgb, overpaint.a);
|
||||
#endif
|
||||
|
||||
#ifdef dIgnoreLight
|
||||
if (material.a >= 0.01) {
|
||||
#ifdef dPackedGroup
|
||||
// compute gradient by central differences
|
||||
gradient.x = textureVal(unitPos - dx).a - textureVal(unitPos + dx).a;
|
||||
gradient.y = textureVal(unitPos - dy).a - textureVal(unitPos + dy).a;
|
||||
gradient.z = textureVal(unitPos - dz).a - textureVal(unitPos + dz).a;
|
||||
#else
|
||||
gradient = cell.xyz * 2.0 - 1.0;
|
||||
#endif
|
||||
vec3 normal = -normalize(normalMatrix * normalize(gradient));
|
||||
#include apply_light_color
|
||||
} else {
|
||||
gl_FragColor.rgb = material.rgb;
|
||||
#else
|
||||
if (material.a >= 0.01) {
|
||||
#ifdef dPackedGroup
|
||||
// compute gradient by central differences
|
||||
gradient.x = textureVal(unitPos - dx).a - textureVal(unitPos + dx).a;
|
||||
gradient.y = textureVal(unitPos - dy).a - textureVal(unitPos + dy).a;
|
||||
gradient.z = textureVal(unitPos - dz).a - textureVal(unitPos + dz).a;
|
||||
#else
|
||||
gradient = cell.xyz * 2.0 - 1.0;
|
||||
#endif
|
||||
vec3 normal = -normalize(normalMatrix * normalize(gradient));
|
||||
#include apply_light_color
|
||||
} else {
|
||||
gl_FragColor.rgb = material.rgb;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
gl_FragColor.a = material.a * uAlpha * uTransferScale;
|
||||
|
||||
|
||||
@@ -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>
|
||||
*/
|
||||
@@ -43,17 +43,13 @@ void main() {
|
||||
#elif defined(dRenderVariant_marking)
|
||||
gl_FragColor = material;
|
||||
#elif defined(dRenderVariant_color)
|
||||
#ifdef dIgnoreLight
|
||||
gl_FragColor = material;
|
||||
#if defined(dFlatShaded)
|
||||
vec3 normal = -faceNormal;
|
||||
#else
|
||||
#if defined(dFlatShaded)
|
||||
vec3 normal = -faceNormal;
|
||||
#else
|
||||
vec3 normal = -normalize(vNormal);
|
||||
if (uDoubleSided) normal *= float(frontFacing) * 2.0 - 1.0;
|
||||
#endif
|
||||
#include apply_light_color
|
||||
vec3 normal = -normalize(vNormal);
|
||||
if (uDoubleSided) normal *= float(frontFacing) * 2.0 - 1.0;
|
||||
#endif
|
||||
#include apply_light_color
|
||||
|
||||
#include apply_interior_color
|
||||
#include apply_marker_color
|
||||
|
||||
@@ -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>
|
||||
@@ -24,8 +24,7 @@ uniform vec3 uFogColor;
|
||||
uniform vec3 uOutlineColor;
|
||||
uniform bool uTransparentBackground;
|
||||
|
||||
uniform float uOcclusionBias;
|
||||
uniform float uOcclusionRadius;
|
||||
uniform vec2 uOcclusionOffset;
|
||||
|
||||
uniform float uMaxPossibleViewZDiff;
|
||||
|
||||
@@ -102,7 +101,7 @@ void main(void) {
|
||||
if (!isBackground(depth)) {
|
||||
viewDist = abs(getViewZ(depth));
|
||||
fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
|
||||
float occlusionFactor = getSsao(coords);
|
||||
float occlusionFactor = getSsao(coords + uOcclusionOffset);
|
||||
if (!uTransparentBackground) {
|
||||
color.rgb = mix(mix(occlusionColor, uFogColor, fogFactor), color.rgb, occlusionFactor);
|
||||
} else {
|
||||
|
||||
@@ -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>
|
||||
*/
|
||||
@@ -92,12 +92,8 @@ void main(void){
|
||||
#elif defined(dRenderVariant_marking)
|
||||
gl_FragColor = material;
|
||||
#elif defined(dRenderVariant_color)
|
||||
#ifdef dIgnoreLight
|
||||
gl_FragColor = material;
|
||||
#else
|
||||
vec3 normal = -cameraNormal;
|
||||
#include apply_light_color
|
||||
#endif
|
||||
vec3 normal = -cameraNormal;
|
||||
#include apply_light_color
|
||||
|
||||
#include apply_interior_color
|
||||
#include apply_marker_color
|
||||
|
||||
@@ -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>
|
||||
*/
|
||||
@@ -176,7 +176,7 @@ function isTexture2d(x: TextureImage<any> | TextureVolume<any>, target: number,
|
||||
return target === gl.TEXTURE_2D;
|
||||
}
|
||||
|
||||
function isTexture3d(x: TextureImage<any> | TextureVolume<any>, target: number, gl: WebGL2RenderingContext): x is TextureImage<any> {
|
||||
function isTexture3d(x: TextureImage<any> | TextureVolume<any>, target: number, gl: WebGL2RenderingContext): x is TextureVolume<any> {
|
||||
return target === gl.TEXTURE_3D;
|
||||
}
|
||||
|
||||
@@ -260,6 +260,10 @@ export function createTexture(gl: GLRenderingContext, extensions: WebGLExtension
|
||||
let destroyed = false;
|
||||
|
||||
function define(_width: number, _height: number, _depth?: number) {
|
||||
if (_width === 0 || _height === 0 || (isWebGL2(gl) && target === gl.TEXTURE_3D && _depth === 0)) {
|
||||
throw new Error('empty textures are not allowed');
|
||||
}
|
||||
|
||||
if (width === _width && height === _height && depth === (_depth || 0)) return;
|
||||
|
||||
width = _width, height = _height, depth = _depth || 0;
|
||||
@@ -272,14 +276,20 @@ export function createTexture(gl: GLRenderingContext, extensions: WebGLExtension
|
||||
throw new Error('unknown texture target');
|
||||
}
|
||||
}
|
||||
define(1, 1, isWebGL2(gl) && target === gl.TEXTURE_3D ? 1 : 0);
|
||||
|
||||
function load(data: TextureImage<any> | TextureVolume<any> | HTMLImageElement, sub = false) {
|
||||
if (data.width === 0 || data.height === 0 || (!isImage(data) && isWebGL2(gl) && isTexture3d(data, target, gl) && data.depth === 0)) {
|
||||
throw new Error('empty textures are not allowed');
|
||||
}
|
||||
|
||||
gl.bindTexture(target, texture);
|
||||
// unpack alignment of 1 since we use textures only for data
|
||||
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
|
||||
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
|
||||
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
|
||||
if (isImage(data)) {
|
||||
width = data.width, height = data.height;
|
||||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
||||
gl.bindTexture(gl.TEXTURE_2D, texture);
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, format, type, data);
|
||||
|
||||
28
src/mol-io/common/_spec/encoder.spec.ts
Normal file
28
src/mol-io/common/_spec/encoder.spec.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { ArrayEncoding } from '../binary-cif/array-encoder';
|
||||
import { decode } from '../binary-cif/decoder';
|
||||
|
||||
const E = ArrayEncoding;
|
||||
|
||||
test('fixedPoint2', async () => {
|
||||
const fixedPoint2 = E.by(E.fixedPoint(100)).and(E.delta).and(E.integerPacking);
|
||||
|
||||
const x = [1.092, 1.960, 0.666, 0.480, 1.267];
|
||||
const y = [7.428, 7.026, 6.851, 7.524, 8.333];
|
||||
const z = [26.270, 26.561, 25.573, 27.055, 25.881];
|
||||
|
||||
const xEnc = fixedPoint2.encode(new Float32Array(x));
|
||||
const yEnc = fixedPoint2.encode(new Float32Array(y));
|
||||
const zEnc = fixedPoint2.encode(new Float32Array(z));
|
||||
|
||||
expect(xEnc.data.length).toEqual(6);
|
||||
expect(yEnc.data.length).toEqual(5);
|
||||
expect(zEnc.data.length).toEqual(6);
|
||||
|
||||
const xDec = decode(xEnc);
|
||||
const yDec = decode(yEnc);
|
||||
const zDec = decode(zEnc);
|
||||
|
||||
x.forEach((a, i) => expect(xDec[i]).toBeCloseTo(a, 2));
|
||||
y.forEach((a, i) => expect(yDec[i]).toBeCloseTo(a, 2));
|
||||
z.forEach((a, i) => expect(zDec[i]).toBeCloseTo(a, 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.354, IHM 1.17, MA 1.3.3.
|
||||
* Code-generated 'BIRD' schema file. Dictionary versions: mmCIF 5.356, IHM 1.17, MA 1.3.5.
|
||||
*
|
||||
* @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.354, IHM 1.17, MA 1.3.3.
|
||||
* Code-generated 'CCD' schema file. Dictionary versions: mmCIF 5.356, IHM 1.17, MA 1.3.5.
|
||||
*
|
||||
* @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.354, IHM 1.17, MA 1.3.3.
|
||||
* Code-generated 'mmCIF' schema file. Dictionary versions: mmCIF 5.356, IHM 1.17, MA 1.3.5.
|
||||
*
|
||||
* @author molstar/ciftools package
|
||||
*/
|
||||
@@ -215,6 +215,28 @@ export const mmCIF_Schema = {
|
||||
* formal charge assignment normally found in chemical diagrams.
|
||||
*/
|
||||
pdbx_formal_charge: int,
|
||||
/**
|
||||
* This data item is an ordinal which identifies distinct chemical components in the atom_site category, both
|
||||
* polymeric and non-polymeric.
|
||||
*/
|
||||
pdbx_label_index: int,
|
||||
/**
|
||||
* The name of additional external databases with residue level mapping.
|
||||
*/
|
||||
pdbx_sifts_xref_db_name: str,
|
||||
/**
|
||||
* The accession code related to the additional external database entry.
|
||||
*/
|
||||
pdbx_sifts_xref_db_acc: str,
|
||||
/**
|
||||
* The sequence position of the external database entry that corresponds
|
||||
* to the residue mapping defined by the SIFTS process.
|
||||
*/
|
||||
pdbx_sifts_xref_db_num: str,
|
||||
/**
|
||||
* Describes the residue type of the given UniProt match
|
||||
*/
|
||||
pdbx_sifts_xref_db_res: str,
|
||||
/**
|
||||
* The model id corresponding to the atom site.
|
||||
* This data item is a pointer to _ihm_model_list.model_id
|
||||
@@ -682,7 +704,7 @@ export const mmCIF_Schema = {
|
||||
/**
|
||||
* An abbreviation that identifies the database.
|
||||
*/
|
||||
database_id: Aliased<'AFDB' | 'CAS' | 'CSD' | 'EMDB' | 'ICSD' | 'MA' | 'MDF' | 'MODBASE' | 'NDB' | 'NBS' | 'PDB' | 'PDF' | 'RCSB' | 'SMR' | 'EBI' | 'PDBE' | 'BMRB' | 'WWPDB' | 'PDB_ACC'>(str),
|
||||
database_id: Aliased<'AlphaFoldDB' | 'CAS' | 'CSD' | 'EMDB' | 'ICSD' | 'ModelArchive' | 'MDF' | 'MODBASE' | 'NDB' | 'NBS' | 'PDB' | 'PDF' | 'RCSB' | 'SWISS-MODEL_REPOSITORY' | 'EBI' | 'PDBE' | 'BMRB' | 'WWPDB' | 'PDB_ACC'>(str),
|
||||
/**
|
||||
* The code assigned by the database identified in
|
||||
* _database_2.database_id.
|
||||
@@ -2211,6 +2233,10 @@ export const mmCIF_Schema = {
|
||||
oligomeric_count: int,
|
||||
/**
|
||||
* A description of special aspects of the macromolecular assembly.
|
||||
*
|
||||
* In the PDB, 'representative helical assembly', 'complete point assembly',
|
||||
* 'complete icosahedral assembly', 'software_defined_assembly', 'author_defined_assembly',
|
||||
* and 'author_and_software_defined_assembly' are considered "biologically relevant assemblies.
|
||||
*/
|
||||
details: str,
|
||||
/**
|
||||
|
||||
@@ -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>
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ const DnaAtomIdsList = [
|
||||
|
||||
/** Used to reduce false positives for atom name-based type guessing */
|
||||
const NonPolymerNames = new Set([
|
||||
'FMN', 'NCN', 'FNS', 'FMA' // Mononucleotides
|
||||
'FMN', 'NCN', 'FNS', 'FMA', 'ATP', 'ADP', 'AMP', 'GTP', 'GDP', 'GMP' // Mononucleotides
|
||||
]);
|
||||
|
||||
const StandardComponents = (function () {
|
||||
@@ -156,7 +156,7 @@ export class ComponentBuilder {
|
||||
this.set(StandardComponents.get(compId)!);
|
||||
} else if (WaterNames.has(compId)) {
|
||||
this.set({ id: compId, name: 'WATER', type: 'non-polymer' });
|
||||
} else if (NonPolymerNames.has(compId)) {
|
||||
} else if (NonPolymerNames.has(compId.toUpperCase())) {
|
||||
this.set({ id: compId, name: this.namesMap.get(compId) || compId, type: 'non-polymer' });
|
||||
} else {
|
||||
const atomIds = this.getAtomIds(index);
|
||||
|
||||
@@ -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 Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
*/
|
||||
|
||||
import { Model } from '../../../mol-model/structure';
|
||||
@@ -44,7 +45,7 @@ interface FormatPropertyProvider<T> {
|
||||
}
|
||||
|
||||
namespace FormatPropertyProvider {
|
||||
export function create<T>(descriptor: CustomPropertyDescriptor): FormatPropertyProvider<T> {
|
||||
export function create<T>(descriptor: CustomPropertyDescriptor, options?: { asDynamic?: boolean }): FormatPropertyProvider<T> {
|
||||
const { name } = descriptor;
|
||||
const formatRegistry = new FormatRegistry<T>();
|
||||
|
||||
@@ -55,21 +56,31 @@ namespace FormatPropertyProvider {
|
||||
return formatRegistry.isApplicable(model);
|
||||
},
|
||||
get(model: Model): T | undefined {
|
||||
if (model._staticPropertyData[name]) return model._staticPropertyData[name];
|
||||
const store = options?.asDynamic ? model._dynamicPropertyData : model._staticPropertyData;
|
||||
|
||||
if (store[name]) return store[name];
|
||||
if (model.customProperties.has(descriptor)) return;
|
||||
|
||||
const obtain = formatRegistry.get(model.sourceData.kind);
|
||||
if (!obtain) return;
|
||||
|
||||
model._staticPropertyData[name] = obtain(model);
|
||||
store[name] = obtain(model);
|
||||
model.customProperties.add(descriptor);
|
||||
return model._staticPropertyData[name];
|
||||
return store[name];
|
||||
},
|
||||
set(model: Model, value: T) {
|
||||
model._staticPropertyData[name] = value;
|
||||
if (options?.asDynamic) {
|
||||
model._dynamicPropertyData[name] = value;
|
||||
} else {
|
||||
model._staticPropertyData[name] = value;
|
||||
}
|
||||
},
|
||||
delete(model: Model) {
|
||||
delete model._staticPropertyData[name];
|
||||
if (options?.asDynamic) {
|
||||
delete model._dynamicPropertyData[name];
|
||||
} else {
|
||||
delete model._staticPropertyData[name];
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -103,11 +103,11 @@ async function getModels(mol2: Mol2File, ctx: RuntimeContext) {
|
||||
const flag = Column.ofIntArray(Column.mapToArray(bonds.bond_type, x => {
|
||||
switch (x) {
|
||||
case 'ar': // aromatic
|
||||
case 'am': // amide
|
||||
return BondType.Flag.Aromatic | BondType.Flag.Covalent;
|
||||
case 'du': // dummy
|
||||
case 'nc': // not connected
|
||||
return BondType.Flag.None;
|
||||
case 'am': // amide
|
||||
case 'un': // unknown
|
||||
default:
|
||||
return BondType.Flag.Covalent;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2017-2020 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>
|
||||
@@ -56,10 +56,10 @@ export namespace ComponentBond {
|
||||
const entries: Map<string, Entry> = new Map();
|
||||
|
||||
function addEntry(id: string) {
|
||||
// weird behavior when 'PRO' is requested - will report a single bond between N and H because a later operation would override real content
|
||||
if (entries.has(id)) {
|
||||
return entries.get(id)!;
|
||||
}
|
||||
// weird behavior when 'PRO' is requested - will report a single bond
|
||||
// between N and H because a later operation would override real content
|
||||
if (entries.has(id)) return entries.get(id)!;
|
||||
|
||||
const e = new Entry(id);
|
||||
entries.set(id, e);
|
||||
return e;
|
||||
@@ -83,10 +83,8 @@ export namespace ComponentBond {
|
||||
let ord = 1;
|
||||
if (aromatic) flags |= BondType.Flag.Aromatic;
|
||||
switch (order.toLowerCase()) {
|
||||
case 'doub':
|
||||
case 'delo':
|
||||
ord = 2;
|
||||
break;
|
||||
case 'delo': flags |= BondType.Flag.Aromatic; break;
|
||||
case 'doub': ord = 2; break;
|
||||
case 'trip': ord = 3; break;
|
||||
case 'quad': ord = 4; break;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* 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>
|
||||
*/
|
||||
|
||||
import { CustomPropertyDescriptor } from '../../../../mol-model/custom-property';
|
||||
@@ -42,7 +43,7 @@ export namespace IndexPairBonds {
|
||||
name: 'index_pair_bonds',
|
||||
};
|
||||
|
||||
export const Provider = FormatPropertyProvider.create<IndexPairBonds>(Descriptor);
|
||||
export const Provider = FormatPropertyProvider.create<IndexPairBonds>(Descriptor, { asDynamic: true });
|
||||
|
||||
export type Data = {
|
||||
pairs: {
|
||||
|
||||
@@ -11,30 +11,43 @@ import { Model } from '../../mol-model/structure';
|
||||
import { StructureElement } from '../../mol-model/structure/structure';
|
||||
import { CustomModelProperty } from '../common/custom-model-property';
|
||||
|
||||
export { BestDatabaseSequenceMapping };
|
||||
export { SIFTSMapping as SIFTSMapping };
|
||||
|
||||
interface BestDatabaseSequenceMapping {
|
||||
interface SIFTSMappingMapping {
|
||||
readonly dbName: string[],
|
||||
readonly accession: string[],
|
||||
readonly num: number[],
|
||||
readonly num: string[],
|
||||
readonly residue: string[]
|
||||
}
|
||||
|
||||
namespace BestDatabaseSequenceMapping {
|
||||
export const Provider: CustomModelProperty.Provider<{}, BestDatabaseSequenceMapping> = CustomModelProperty.createProvider({
|
||||
label: 'Best Database Sequence Mapping',
|
||||
namespace SIFTSMapping {
|
||||
export const Provider: CustomModelProperty.Provider<{}, SIFTSMappingMapping> = CustomModelProperty.createProvider({
|
||||
label: 'SIFTS Mapping',
|
||||
descriptor: CustomPropertyDescriptor({
|
||||
name: 'molstar_best_database_sequence_mapping'
|
||||
name: 'sifts_sequence_mapping'
|
||||
}),
|
||||
type: 'static',
|
||||
defaultParams: {},
|
||||
getParams: () => ({}),
|
||||
isApplicable: (data: Model) => MmcifFormat.is(data.sourceData) && data.sourceData.data.frame.categories?.atom_site?.fieldNames.indexOf('pdbx_sifts_xref_db_name') >= 0,
|
||||
isApplicable: (data: Model) => isAvailable(data),
|
||||
obtain: async (ctx, data) => {
|
||||
return { value: fromCif(data) };
|
||||
}
|
||||
});
|
||||
|
||||
export function isAvailable(model: Model) {
|
||||
if (!MmcifFormat.is(model.sourceData)) return false;
|
||||
|
||||
const {
|
||||
pdbx_sifts_xref_db_name: db_name,
|
||||
pdbx_sifts_xref_db_acc: db_acc,
|
||||
pdbx_sifts_xref_db_num: db_num,
|
||||
pdbx_sifts_xref_db_res: db_res
|
||||
} = model.sourceData.data.db.atom_site;
|
||||
|
||||
return db_name.isDefined && db_acc.isDefined && db_num.isDefined && db_res.isDefined;
|
||||
}
|
||||
|
||||
export function getKey(loc: StructureElement.Location) {
|
||||
const model = loc.unit.model;
|
||||
const data = Provider.get(model).value;
|
||||
@@ -55,22 +68,23 @@ namespace BestDatabaseSequenceMapping {
|
||||
return `${dbName} ${data.accession[rI]} ${data.num[rI]} ${data.residue[rI]}`;
|
||||
}
|
||||
|
||||
function fromCif(model: Model): BestDatabaseSequenceMapping | undefined {
|
||||
function fromCif(model: Model): SIFTSMappingMapping | undefined {
|
||||
if (!MmcifFormat.is(model.sourceData)) return;
|
||||
|
||||
const { atom_site } = model.sourceData.data.frame.categories;
|
||||
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');
|
||||
const {
|
||||
pdbx_sifts_xref_db_name: db_name,
|
||||
pdbx_sifts_xref_db_acc: db_acc,
|
||||
pdbx_sifts_xref_db_num: db_num,
|
||||
pdbx_sifts_xref_db_res: db_res
|
||||
} = model.sourceData.data.db.atom_site;
|
||||
|
||||
if (!db_name || !db_acc || !db_num || !db_res) return;
|
||||
if (!db_name.isDefined || !db_acc.isDefined || !db_num.isDefined || !db_res.isDefined) return;
|
||||
|
||||
const { atomSourceIndex } = model.atomicHierarchy;
|
||||
const { count, offsets: residueOffsets } = model.atomicHierarchy.residueAtomSegments;
|
||||
const dbName = new Array<string>(count);
|
||||
const accession = new Array<string>(count);
|
||||
const num = new Array<number>(count);
|
||||
const num = new Array<string>(count);
|
||||
const residue = new Array<string>(count);
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
@@ -79,15 +93,15 @@ namespace BestDatabaseSequenceMapping {
|
||||
if (db_name.valueKind(row) !== Column.ValueKind.Present) {
|
||||
dbName[i] = '';
|
||||
accession[i] = '';
|
||||
num[i] = 0;
|
||||
num[i] = '';
|
||||
residue[i] = '';
|
||||
continue;
|
||||
}
|
||||
|
||||
dbName[i] = db_name.str(row);
|
||||
accession[i] = db_acc.str(row);
|
||||
num[i] = db_num.int(row);
|
||||
residue[i] = db_res.str(row);
|
||||
dbName[i] = db_name.value(row);
|
||||
accession[i] = db_acc.value(row);
|
||||
num[i] = db_num.value(row);
|
||||
residue[i] = db_res.value(row);
|
||||
}
|
||||
|
||||
return { dbName, accession, num, residue };
|
||||
@@ -12,27 +12,27 @@ import { Color } from '../../../mol-util/color';
|
||||
import { getPalette, getPaletteParams } from '../../../mol-util/color/palette';
|
||||
import { ParamDefinition as PD } from '../../../mol-util/param-definition';
|
||||
import { CustomProperty } from '../../common/custom-property';
|
||||
import { BestDatabaseSequenceMapping } from '../best-database-mapping';
|
||||
import { SIFTSMapping } from '../sifts-mapping';
|
||||
|
||||
const DefaultColor = Color(0xFAFAFA);
|
||||
const Description = 'Assigns a color based on best dababase sequence mapping.';
|
||||
const Description = 'Assigns a color based on SIFTS mapping.';
|
||||
|
||||
// same colors for same accessions
|
||||
const globalAccessionMap = new Map<string, number>();
|
||||
|
||||
export const BestDatabaseSequenceMappingColorThemeParams = {
|
||||
export const SIFTSMappingColorThemeParams = {
|
||||
...getPaletteParams({ type: 'colors', colorList: 'set-1' }),
|
||||
};
|
||||
export type BestDatabaseSequenceMappingColorThemeParams = typeof BestDatabaseSequenceMappingColorThemeParams
|
||||
export function getBestDatabaseSequenceMappingColorThemeParams(ctx: ThemeDataContext) {
|
||||
return BestDatabaseSequenceMappingColorThemeParams; // TODO return copy
|
||||
export type SIFTSMappingColorThemeParams = typeof SIFTSMappingColorThemeParams
|
||||
export function getSIFTSMappingColorThemeParams(ctx: ThemeDataContext) {
|
||||
return SIFTSMappingColorThemeParams; // TODO return copy
|
||||
}
|
||||
export function BestDatabaseSequenceMappingColorTheme(ctx: ThemeDataContext, props: PD.Values<BestDatabaseSequenceMappingColorThemeParams>): ColorTheme<BestDatabaseSequenceMappingColorThemeParams> {
|
||||
export function SIFTSMappingColorTheme(ctx: ThemeDataContext, props: PD.Values<SIFTSMappingColorThemeParams>): ColorTheme<SIFTSMappingColorThemeParams> {
|
||||
let color: LocationColor;
|
||||
|
||||
if (ctx.structure) {
|
||||
for (const m of ctx.structure.models) {
|
||||
const mapping = BestDatabaseSequenceMapping.Provider.get(m).value;
|
||||
const mapping = SIFTSMapping.Provider.get(m).value;
|
||||
if (!mapping) continue;
|
||||
for (const acc of mapping.accession) {
|
||||
if (!acc || globalAccessionMap.has(acc)) continue;
|
||||
@@ -45,7 +45,7 @@ export function BestDatabaseSequenceMappingColorTheme(ctx: ThemeDataContext, pro
|
||||
const colorMap = new Map<string, Color>();
|
||||
|
||||
const getColor = (location: StructureElement.Location) => {
|
||||
const key = BestDatabaseSequenceMapping.getKey(location);
|
||||
const key = SIFTSMapping.getKey(location);
|
||||
if (!key) return DefaultColor;
|
||||
|
||||
if (colorMap.has(key)) return colorMap.get(key)!;
|
||||
@@ -70,7 +70,7 @@ export function BestDatabaseSequenceMappingColorTheme(ctx: ThemeDataContext, pro
|
||||
}
|
||||
|
||||
return {
|
||||
factory: BestDatabaseSequenceMappingColorTheme,
|
||||
factory: SIFTSMappingColorTheme,
|
||||
granularity: 'group',
|
||||
preferSmoothing: true,
|
||||
color,
|
||||
@@ -79,26 +79,26 @@ export function BestDatabaseSequenceMappingColorTheme(ctx: ThemeDataContext, pro
|
||||
};
|
||||
}
|
||||
|
||||
export const BestDatabaseSequenceMappingColorThemeProvider: ColorTheme.Provider<BestDatabaseSequenceMappingColorThemeParams, 'best-sequence-database-mapping'> = {
|
||||
name: 'best-sequence-database-mapping',
|
||||
label: 'Best Database Sequence Mapping',
|
||||
export const SIFTSMappingColorThemeProvider: ColorTheme.Provider<SIFTSMappingColorThemeParams, 'sifts-mapping'> = {
|
||||
name: 'sifts-mapping',
|
||||
label: 'SIFTS Mapping',
|
||||
category: ColorTheme.Category.Residue,
|
||||
factory: BestDatabaseSequenceMappingColorTheme,
|
||||
getParams: getBestDatabaseSequenceMappingColorThemeParams,
|
||||
defaultValues: PD.getDefaultValues(BestDatabaseSequenceMappingColorThemeParams),
|
||||
isApplicable: (ctx: ThemeDataContext) => !!ctx.structure?.models.some(m => BestDatabaseSequenceMapping.Provider.isApplicable(m)),
|
||||
factory: SIFTSMappingColorTheme,
|
||||
getParams: getSIFTSMappingColorThemeParams,
|
||||
defaultValues: PD.getDefaultValues(SIFTSMappingColorThemeParams),
|
||||
isApplicable: (ctx: ThemeDataContext) => !!ctx.structure?.models.some(m => SIFTSMapping.Provider.isApplicable(m)),
|
||||
ensureCustomProperties: {
|
||||
attach: async (ctx: CustomProperty.Context, data: ThemeDataContext) => {
|
||||
if (!data.structure) return;
|
||||
|
||||
for (const m of data.structure.models) {
|
||||
await BestDatabaseSequenceMapping.Provider.attach(ctx, m, void 0, true);
|
||||
await SIFTSMapping.Provider.attach(ctx, m, void 0, true);
|
||||
}
|
||||
},
|
||||
detach: (data) => {
|
||||
if (!data.structure) return;
|
||||
for (const m of data.structure.models) {
|
||||
BestDatabaseSequenceMapping.Provider.ref(m, false);
|
||||
SIFTSMapping.Provider.ref(m, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,11 @@
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
import { Column } from '../../../../mol-data/db';
|
||||
import { mmCIF_Database } from '../../../../mol-io/reader/cif/schema/mmcif';
|
||||
import { CifWriter } from '../../../../mol-io/writer/cif';
|
||||
import { MmcifFormat } from '../../../../mol-model-formats/structure/mmcif';
|
||||
import { SIFTSMapping } from '../../../../mol-model-props/sequence/sifts-mapping';
|
||||
import { StructureElement, Structure, StructureProperties as P } from '../../structure';
|
||||
import { CifExportContext } from '../mmcif';
|
||||
import CifField = CifWriter.Field
|
||||
@@ -26,7 +30,64 @@ function atom_site_auth_asym_id(e: StructureElement.Location) {
|
||||
return l + suffix;
|
||||
}
|
||||
|
||||
const atom_site_fields = () => CifWriter.fields<StructureElement.Location, Structure>()
|
||||
|
||||
const atom_site_pdbx_label_index = {
|
||||
shouldInclude(s: AtomSiteData) {
|
||||
return !!s.atom_site?.pdbx_label_index.isDefined;
|
||||
},
|
||||
value(e: StructureElement.Location, d: AtomSiteData) {
|
||||
const srcIndex = d.sourceIndex.value(e.element);
|
||||
return d.atom_site!.pdbx_label_index.value(srcIndex);
|
||||
},
|
||||
};
|
||||
|
||||
const SIFTS = {
|
||||
shouldInclude(s: AtomSiteData) {
|
||||
return SIFTSMapping.isAvailable(s.structure.models[0]);
|
||||
},
|
||||
pdbx_sifts_xref_db_name: {
|
||||
value(e: StructureElement.Location, d: AtomSiteData) {
|
||||
const srcIndex = d.sourceIndex.value(e.element);
|
||||
return d.atom_site!.pdbx_sifts_xref_db_name.value(srcIndex);
|
||||
},
|
||||
valueKind(e: StructureElement.Location, d: any) {
|
||||
const srcIndex = d.sourceIndex.value(e.element);
|
||||
return d.atom_site!.pdbx_sifts_xref_db_name.valueKind(srcIndex);
|
||||
},
|
||||
},
|
||||
pdbx_sifts_xref_db_acc: {
|
||||
value(e: StructureElement.Location, d: AtomSiteData) {
|
||||
const srcIndex = d.sourceIndex.value(e.element);
|
||||
return d.atom_site!.pdbx_sifts_xref_db_acc.value(srcIndex);
|
||||
},
|
||||
valueKind(e: StructureElement.Location, d: any) {
|
||||
const srcIndex = d.sourceIndex.value(e.element);
|
||||
return d.atom_site!.pdbx_sifts_xref_db_acc.valueKind(srcIndex);
|
||||
},
|
||||
},
|
||||
pdbx_sifts_xref_db_num: {
|
||||
value(e: StructureElement.Location, d: AtomSiteData) {
|
||||
const srcIndex = d.sourceIndex.value(e.element);
|
||||
return d.atom_site!.pdbx_sifts_xref_db_num.value(srcIndex);
|
||||
},
|
||||
valueKind(e: StructureElement.Location, d: any) {
|
||||
const srcIndex = d.sourceIndex.value(e.element);
|
||||
return d.atom_site!.pdbx_sifts_xref_db_num.valueKind(srcIndex);
|
||||
},
|
||||
},
|
||||
pdbx_sifts_xref_db_res: {
|
||||
value(e: StructureElement.Location, d: AtomSiteData) {
|
||||
const srcIndex = d.sourceIndex.value(e.element);
|
||||
return d.atom_site!.pdbx_sifts_xref_db_res.value(srcIndex);
|
||||
},
|
||||
valueKind(e: StructureElement.Location, d: any) {
|
||||
const srcIndex = d.sourceIndex.value(e.element);
|
||||
return d.atom_site!.pdbx_sifts_xref_db_res.valueKind(srcIndex);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
const atom_site_fields = () => CifWriter.fields<StructureElement.Location, AtomSiteData>()
|
||||
.str('group_PDB', P.residue.group_PDB)
|
||||
.index('id')
|
||||
.str('type_symbol', P.atom.type_symbol as any)
|
||||
@@ -62,18 +123,37 @@ const atom_site_fields = () => CifWriter.fields<StructureElement.Location, Struc
|
||||
.str('auth_asym_id', atom_site_auth_asym_id)
|
||||
|
||||
.int('pdbx_PDB_model_num', P.unit.model_num, { encoder: E.deltaRLE })
|
||||
|
||||
.int('pdbx_label_index', atom_site_pdbx_label_index.value, { shouldInclude: atom_site_pdbx_label_index.shouldInclude })
|
||||
|
||||
// SIFTS
|
||||
.str('pdbx_sifts_xref_db_name', SIFTS.pdbx_sifts_xref_db_name.value, { shouldInclude: SIFTS.shouldInclude, valueKind: SIFTS.pdbx_sifts_xref_db_name.valueKind })
|
||||
.str('pdbx_sifts_xref_db_acc', SIFTS.pdbx_sifts_xref_db_acc.value, { shouldInclude: SIFTS.shouldInclude, valueKind: SIFTS.pdbx_sifts_xref_db_acc.valueKind })
|
||||
.str('pdbx_sifts_xref_db_num', SIFTS.pdbx_sifts_xref_db_num.value, { shouldInclude: SIFTS.shouldInclude, valueKind: SIFTS.pdbx_sifts_xref_db_num.valueKind })
|
||||
.str('pdbx_sifts_xref_db_res', SIFTS.pdbx_sifts_xref_db_res.value, { shouldInclude: SIFTS.shouldInclude, valueKind: SIFTS.pdbx_sifts_xref_db_res.valueKind })
|
||||
|
||||
// .str('operator_name', P.unit.operator_name, {
|
||||
// shouldInclude: structure => structure.units.some(u => !u.conformation.operator.isIdentity)
|
||||
// })
|
||||
.getFields();
|
||||
|
||||
interface AtomSiteData {
|
||||
structure: Structure,
|
||||
sourceIndex: Column<number>,
|
||||
atom_site?: mmCIF_Database['atom_site']
|
||||
}
|
||||
|
||||
export const _atom_site: CifCategory<CifExportContext> = {
|
||||
name: 'atom_site',
|
||||
instance({ structures }: CifExportContext) {
|
||||
return {
|
||||
fields: atom_site_fields(),
|
||||
source: structures.map(s => ({
|
||||
data: s,
|
||||
data: {
|
||||
structure: s,
|
||||
sourceIndex: s.model.atomicHierarchy.atomSourceIndex,
|
||||
atom_site: MmcifFormat.is(s.model.sourceData) ? s.model.sourceData.data.db.atom_site : void 0
|
||||
} as AtomSiteData,
|
||||
rowCount: s.elementCount,
|
||||
keys: () => s.elementLocations()
|
||||
}))
|
||||
|
||||
@@ -78,12 +78,12 @@ function findElements<T extends SecondaryStructure.Element>(ctx: CifExportContex
|
||||
const ssElements: SSElement<any>[] = [];
|
||||
|
||||
const structure = ctx.structures[0];
|
||||
for (const unit of structure.units) {
|
||||
// currently can only support this for "identity" operators.
|
||||
if (!Unit.isAtomic(unit) || !unit.conformation.operator.isIdentity) continue;
|
||||
for (const { units } of structure.unitSymmetryGroups) {
|
||||
const u = units[0];
|
||||
if (!Unit.isAtomic(u)) continue;
|
||||
|
||||
const segs = unit.model.atomicHierarchy.residueAtomSegments;
|
||||
const residues = Segmentation.transientSegments(segs, unit.elements);
|
||||
const segs = u.model.atomicHierarchy.residueAtomSegments;
|
||||
const residues = Segmentation.transientSegments(segs, u.elements);
|
||||
|
||||
let current: Segmentation.Segment, move = true;
|
||||
while (residues.hasNext) {
|
||||
@@ -104,8 +104,8 @@ function findElements<T extends SecondaryStructure.Element>(ctx: CifExportContex
|
||||
if (startIdx !== key[current.index]) {
|
||||
move = false;
|
||||
ssElements[ssElements.length] = {
|
||||
start: StructureElement.Location.create(structure, unit, segs.offsets[start]),
|
||||
end: StructureElement.Location.create(structure, unit, segs.offsets[prev]),
|
||||
start: StructureElement.Location.create(structure, u, segs.offsets[start]),
|
||||
end: StructureElement.Location.create(structure, u, segs.offsets[prev]),
|
||||
length: prev - start + 1,
|
||||
element
|
||||
};
|
||||
|
||||
@@ -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>
|
||||
@@ -98,6 +98,7 @@ export namespace Model {
|
||||
const srcIndex = model.atomicHierarchy.atomSourceIndex;
|
||||
const isIdentity = Column.isIdentity(srcIndex);
|
||||
const srcIndexArray = isIdentity ? void 0 : srcIndex.toArray({ array: Int32Array });
|
||||
const coarseGrained = isCoarseGrained(model);
|
||||
|
||||
for (let i = 0, il = frames.length; i < il; ++i) {
|
||||
const f = frames[i];
|
||||
@@ -119,6 +120,7 @@ export namespace Model {
|
||||
}
|
||||
|
||||
TrajectoryInfo.set(m, { index: i, size: frames.length });
|
||||
CoarseGrained.set(m, coarseGrained);
|
||||
|
||||
trajectory.push(m);
|
||||
}
|
||||
@@ -138,11 +140,13 @@ export namespace Model {
|
||||
|
||||
const bondData = { pairs: topology.bonds, count: model.atomicHierarchy.atoms._rowCount };
|
||||
const indexPairBonds = IndexPairBonds.fromData(bondData);
|
||||
const coarseGrained = isCoarseGrained(model);
|
||||
|
||||
let index = 0;
|
||||
for (const m of trajectory) {
|
||||
IndexPairBonds.Provider.set(m, indexPairBonds);
|
||||
TrajectoryInfo.set(m, { index: index++, size: trajectory.length });
|
||||
CoarseGrained.set(m, coarseGrained);
|
||||
}
|
||||
return new ArrayTrajectory(trajectory);
|
||||
});
|
||||
@@ -225,35 +229,44 @@ export namespace Model {
|
||||
};
|
||||
|
||||
const CoarseGrainedProp = '__CoarseGrained__';
|
||||
export const CoarseGrained = {
|
||||
get(model: Model): boolean | undefined {
|
||||
return model._staticPropertyData[CoarseGrainedProp];
|
||||
},
|
||||
set(model: Model, coarseGrained: boolean) {
|
||||
return model._staticPropertyData[CoarseGrainedProp] = coarseGrained;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Has typical coarse grained atom names (BB, SC1) or less than three times as many
|
||||
* atoms as polymer residues (C-alpha only models).
|
||||
*/
|
||||
export function isCoarseGrained(model: Model): boolean {
|
||||
if (model._staticPropertyData[CoarseGrainedProp] !== undefined) return model._staticPropertyData[CoarseGrainedProp];
|
||||
let coarseGrained = CoarseGrained.get(model);
|
||||
if (coarseGrained === undefined) {
|
||||
let polymerResidueCount = 0;
|
||||
const { polymerType } = model.atomicHierarchy.derived.residue;
|
||||
for (let i = 0; i < polymerType.length; ++i) {
|
||||
if (polymerType[i] !== PolymerType.NA) polymerResidueCount += 1;
|
||||
}
|
||||
|
||||
let polymerResidueCount = 0;
|
||||
const { polymerType } = model.atomicHierarchy.derived.residue;
|
||||
for (let i = 0; i < polymerType.length; ++i) {
|
||||
if (polymerType[i] !== PolymerType.NA) polymerResidueCount += 1;
|
||||
// check for coarse grained atom names
|
||||
let hasBB = false, hasSC1 = false;
|
||||
const { label_atom_id, _rowCount: atomCount } = model.atomicHierarchy.atoms;
|
||||
for (let i = 0; i < atomCount; ++i) {
|
||||
const atomName = label_atom_id.value(i);
|
||||
if (!hasBB && atomName === 'BB') hasBB = true;
|
||||
if (!hasSC1 && atomName === 'SC1') hasSC1 = true;
|
||||
if (hasBB && hasSC1) break;
|
||||
}
|
||||
|
||||
coarseGrained = (hasBB && hasSC1) || (
|
||||
polymerResidueCount && atomCount
|
||||
? atomCount / polymerResidueCount < 3
|
||||
: false
|
||||
);
|
||||
CoarseGrained.set(model, coarseGrained);
|
||||
}
|
||||
|
||||
// check for coarse grained atom names
|
||||
let hasBB = false, hasSC1 = false;
|
||||
const { label_atom_id, _rowCount: atomCount } = model.atomicHierarchy.atoms;
|
||||
for (let i = 0; i < atomCount; ++i) {
|
||||
const atomName = label_atom_id.value(i);
|
||||
if (!hasBB && atomName === 'BB') hasBB = true;
|
||||
if (!hasSC1 && atomName === 'SC1') hasSC1 = true;
|
||||
if (hasBB && hasSC1) break;
|
||||
}
|
||||
|
||||
const coarseGrained = (hasBB && hasSC1) || (
|
||||
polymerResidueCount && atomCount
|
||||
? atomCount / polymerResidueCount < 3
|
||||
: false
|
||||
);
|
||||
model._staticPropertyData[CoarseGrainedProp] = coarseGrained;
|
||||
return coarseGrained;
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -232,7 +232,14 @@ class Structure {
|
||||
|
||||
get interUnitBonds() {
|
||||
if (this.state.interUnitBonds) return this.state.interUnitBonds;
|
||||
this.state.interUnitBonds = computeInterUnitBonds(this, { ignoreWater: !this.dynamicBonds });
|
||||
if (this.parent && this.state.dynamicBonds === this.parent.state.dynamicBonds &&
|
||||
this.parent.state.interUnitBonds && this.parent.state.interUnitBonds.edgeCount === 0
|
||||
) {
|
||||
// no need to compute InterUnitBonds if parent's ones are empty
|
||||
this.state.interUnitBonds = new InterUnitBonds(new Map());
|
||||
} else {
|
||||
this.state.interUnitBonds = computeInterUnitBonds(this, { ignoreWater: !this.dynamicBonds });
|
||||
}
|
||||
return this.state.interUnitBonds;
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -25,6 +25,10 @@ import { Mat4, Vec3 } from '../../../mol-math/linear-algebra';
|
||||
import { IndexPairBonds } from '../../../mol-model-formats/structure/property/bonds/index-pair';
|
||||
import { ElementSetIntraBondCache } from './unit/bonds/element-set-intra-bond-cache';
|
||||
import { ModelSymmetry } from '../../../mol-model-formats/structure/property/symmetry';
|
||||
import { getResonance, UnitResonance } from './unit/resonance';
|
||||
|
||||
// avoiding namespace lookup improved performance in Chrome (Aug 2020)
|
||||
const v3add = Vec3.add;
|
||||
|
||||
/**
|
||||
* A building block of a structure that corresponds to an atomic or
|
||||
@@ -220,9 +224,32 @@ namespace Unit {
|
||||
|
||||
remapModel(model: Model, dynamicBonds: boolean, props?: AtomicProperties) {
|
||||
if (!props) {
|
||||
props = { ...this.props, bonds: dynamicBonds ? undefined : tryRemapBonds(this, this.props.bonds, model) };
|
||||
props = {
|
||||
...this.props,
|
||||
bonds: dynamicBonds && !this.props.bonds?.props?.canRemap
|
||||
? undefined
|
||||
: tryRemapBonds(this, this.props.bonds, model, dynamicBonds)
|
||||
};
|
||||
if (!Unit.isSameConformation(this, model)) {
|
||||
props.boundary = undefined;
|
||||
const b = props.boundary;
|
||||
if (b) {
|
||||
const { elements } = this;
|
||||
const pos = this.conformation.invariantPosition;
|
||||
const v = Vec3();
|
||||
const center = Vec3();
|
||||
|
||||
for (let i = 0, il = elements.length; i < il; i++) {
|
||||
pos(elements[i], v);
|
||||
v3add(center, center, v);
|
||||
}
|
||||
Vec3.scale(center, center, 1 / elements.length);
|
||||
|
||||
// only invalidate boundary if sphere has changed too much
|
||||
if (Vec3.distance(center, b.sphere.center) / b.sphere.radius >= 1.0) {
|
||||
props.boundary = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
props.lookup3d = undefined;
|
||||
props.principalAxes = undefined;
|
||||
}
|
||||
@@ -282,6 +309,12 @@ namespace Unit {
|
||||
return this.props.rings;
|
||||
}
|
||||
|
||||
get resonance() {
|
||||
if (this.props.resonance) return this.props.resonance;
|
||||
this.props.resonance = getResonance(this);
|
||||
return this.props.resonance;
|
||||
}
|
||||
|
||||
get polymerElements() {
|
||||
if (this.props.polymerElements) return this.props.polymerElements;
|
||||
this.props.polymerElements = getAtomicPolymerElements(this);
|
||||
@@ -342,6 +375,7 @@ namespace Unit {
|
||||
interface AtomicProperties extends BaseProperties {
|
||||
bonds?: IntraUnitBonds
|
||||
rings?: UnitRings
|
||||
resonance?: UnitResonance
|
||||
nucleotideElements?: SortedArray<ElementIndex>
|
||||
proteinElements?: SortedArray<ElementIndex>
|
||||
residueCount?: number
|
||||
@@ -481,7 +515,7 @@ namespace Unit {
|
||||
return isSameConformation(a, b.model);
|
||||
}
|
||||
|
||||
function tryRemapBonds(a: Atomic, old: IntraUnitBonds | undefined, model: Model) {
|
||||
function tryRemapBonds(a: Atomic, old: IntraUnitBonds | undefined, model: Model, dynamicBonds: boolean) {
|
||||
// TODO: should include additional checks?
|
||||
|
||||
if (!old) return void 0;
|
||||
@@ -495,7 +529,7 @@ namespace Unit {
|
||||
return void 0;
|
||||
}
|
||||
|
||||
if (old.props?.canRemap) {
|
||||
if (old.props?.canRemap || !dynamicBonds) {
|
||||
return old;
|
||||
}
|
||||
return isSameConformation(a, model) ? old : void 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2017-2020 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>
|
||||
@@ -12,7 +12,13 @@ import { StructureElement } from '../../element';
|
||||
import { Bond } from '../bonds';
|
||||
import { InterUnitGraph } from '../../../../../mol-math/graph/inter-unit-graph';
|
||||
|
||||
type IntraUnitBonds = IntAdjacencyGraph<StructureElement.UnitIndex, { readonly order: ArrayLike<number>, readonly flags: ArrayLike<BondType.Flag> }, { readonly canRemap?: boolean }>
|
||||
type IntraUnitBonds = IntAdjacencyGraph<StructureElement.UnitIndex, {
|
||||
readonly order: ArrayLike<number>,
|
||||
readonly flags: ArrayLike<BondType.Flag>
|
||||
}, {
|
||||
/** can remap even with dynamicBonds on, e.g., for water molecules */
|
||||
readonly canRemap?: boolean
|
||||
}>
|
||||
|
||||
namespace IntraUnitBonds {
|
||||
export const Empty: IntraUnitBonds = IntAdjacencyGraph.create([], [], [], 0, { flags: [], order: [] });
|
||||
|
||||
@@ -141,7 +141,7 @@ function findBonds(unit: Unit.Atomic, props: BondComputationProps): IntraUnitBon
|
||||
const aI = atoms[_aI];
|
||||
|
||||
const elemA = type_symbol.value(aI);
|
||||
if (isWatery && (elemA !== 'H' || elemA !== 'O')) isWatery = false;
|
||||
if (isWatery && (elemA !== 'H' && elemA !== 'O')) isWatery = false;
|
||||
|
||||
const structConnEntries = props.forceCompute ? void 0 : structConn && structConn.byAtomIndex.get(aI);
|
||||
let hasStructConn = false;
|
||||
|
||||
83
src/mol-model/structure/structure/unit/resonance.ts
Normal file
83
src/mol-model/structure/structure/unit/resonance.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright (c) 2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
import { SortedArray } from '../../../../mol-data/int/sorted-array';
|
||||
import { sortedCantorPairing } from '../../../../mol-data/util';
|
||||
import { BondType } from '../../model/types';
|
||||
import { StructureElement } from '../element';
|
||||
import { Unit } from '../unit';
|
||||
|
||||
export type UnitResonance = {
|
||||
/**
|
||||
* Lookup for triplets of atoms in delocalized bonds.
|
||||
*
|
||||
* Does not include triplets that are part of aromatic rings.
|
||||
*/
|
||||
readonly delocalizedTriplets: {
|
||||
/** Return 3rd element in triplet or undefined if `a` and `b` are not part of a triplet */
|
||||
readonly getThirdElement: (a: StructureElement.UnitIndex, b: StructureElement.UnitIndex) => StructureElement.UnitIndex | undefined
|
||||
/** Return index into `triplets` or undefined if `a` is not part of any triplet */
|
||||
readonly getTripletIndices: (a: StructureElement.UnitIndex) => number[] | undefined
|
||||
readonly triplets: SortedArray<StructureElement.UnitIndex>[]
|
||||
}
|
||||
}
|
||||
|
||||
export function getResonance(unit: Unit.Atomic): UnitResonance {
|
||||
return {
|
||||
delocalizedTriplets: getDelocalizedTriplets(unit)
|
||||
};
|
||||
}
|
||||
|
||||
function getDelocalizedTriplets(unit: Unit.Atomic) {
|
||||
const bonds = unit.bonds;
|
||||
const { b, edgeProps, offset } = bonds;
|
||||
const { order: _order, flags: _flags } = edgeProps;
|
||||
const { elementAromaticRingIndices } = unit.rings;
|
||||
|
||||
const triplets: SortedArray<StructureElement.UnitIndex>[] = [];
|
||||
const thirdElementMap = new Map<number, StructureElement.UnitIndex>();
|
||||
const indicesMap = new Map<number, number[]>();
|
||||
|
||||
const add = (a: StructureElement.UnitIndex, b: StructureElement.UnitIndex, c: StructureElement.UnitIndex) => {
|
||||
const index = triplets.length;
|
||||
triplets.push(SortedArray.ofUnsortedArray([a, b, c]));
|
||||
thirdElementMap.set(sortedCantorPairing(a, b), c);
|
||||
if (indicesMap.has(a)) indicesMap.get(a)!.push(index);
|
||||
else indicesMap.set(a, [index]);
|
||||
};
|
||||
|
||||
for (let i = 0 as StructureElement.UnitIndex; i < unit.elements.length; i++) {
|
||||
if (elementAromaticRingIndices.has(i)) continue;
|
||||
|
||||
const count = offset[i + 1] - offset[i] + 1;
|
||||
if (count < 2) continue;
|
||||
|
||||
const deloBonds: StructureElement.UnitIndex[] = [];
|
||||
for (let t = offset[i], _t = offset[i + 1]; t < _t; t++) {
|
||||
const f = _flags[t];
|
||||
if (!BondType.is(f, BondType.Flag.Aromatic)) continue;
|
||||
|
||||
deloBonds.push(b[t]);
|
||||
}
|
||||
|
||||
if (deloBonds.length >= 2) {
|
||||
add(i, deloBonds[0], deloBonds[1]);
|
||||
for (let j = 1, jl = deloBonds.length; j < jl; j++) {
|
||||
add(i, deloBonds[j], deloBonds[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
getThirdElement: (a: StructureElement.UnitIndex, b: StructureElement.UnitIndex) => {
|
||||
return thirdElementMap.get(sortedCantorPairing(a, b));
|
||||
},
|
||||
getTripletIndices: (a: StructureElement.UnitIndex) => {
|
||||
return indicesMap.get(a);
|
||||
},
|
||||
triplets,
|
||||
};
|
||||
}
|
||||
@@ -28,17 +28,19 @@ export function computeRings(unit: Unit.Atomic) {
|
||||
}
|
||||
|
||||
const enum Constants {
|
||||
MaxDepth = 4
|
||||
MaxDepth = 5
|
||||
}
|
||||
|
||||
interface State {
|
||||
startVertex: number,
|
||||
endVertex: number,
|
||||
count: number,
|
||||
visited: Int32Array,
|
||||
isRingAtom: Int32Array,
|
||||
marked: Int32Array,
|
||||
queue: Int32Array,
|
||||
color: Int32Array,
|
||||
pred: Int32Array,
|
||||
depth: Int32Array,
|
||||
|
||||
left: Int32Array,
|
||||
right: Int32Array,
|
||||
@@ -59,9 +61,11 @@ function State(unit: Unit.Atomic, capacity: number): State {
|
||||
startVertex: 0,
|
||||
endVertex: 0,
|
||||
count: 0,
|
||||
visited: new Int32Array(capacity),
|
||||
isRingAtom: new Int32Array(capacity),
|
||||
marked: new Int32Array(capacity),
|
||||
queue: new Int32Array(capacity),
|
||||
pred: new Int32Array(capacity),
|
||||
depth: new Int32Array(capacity),
|
||||
left: new Int32Array(Constants.MaxDepth),
|
||||
right: new Int32Array(Constants.MaxDepth),
|
||||
color: new Int32Array(capacity),
|
||||
@@ -78,17 +82,26 @@ function State(unit: Unit.Atomic, capacity: number): State {
|
||||
|
||||
function resetState(state: State) {
|
||||
state.count = state.endVertex - state.startVertex;
|
||||
const { visited, pred, color } = state;
|
||||
const { isRingAtom, pred, color, depth, marked } = state;
|
||||
for (let i = 0; i < state.count; i++) {
|
||||
visited[i] = -1;
|
||||
isRingAtom[i] = 0;
|
||||
pred[i] = -1;
|
||||
marked[i] = -1;
|
||||
color[i] = 0;
|
||||
depth[i] = 0;
|
||||
}
|
||||
state.currentColor = 0;
|
||||
state.currentAltLoc = '';
|
||||
state.hasAltLoc = false;
|
||||
}
|
||||
|
||||
function resetDepth(state: State) {
|
||||
const { depth } = state;
|
||||
for (let i = 0; i < state.count; i++) {
|
||||
depth[i] = state.count + 1;
|
||||
}
|
||||
}
|
||||
|
||||
function largestResidue(unit: Unit.Atomic) {
|
||||
const residuesIt = Segmentation.transientSegments(unit.model.atomicHierarchy.residueAtomSegments, unit.elements);
|
||||
let size = 0;
|
||||
@@ -99,8 +112,16 @@ function largestResidue(unit: Unit.Atomic) {
|
||||
return size;
|
||||
}
|
||||
|
||||
function isStartIndex(state: State, i: number) {
|
||||
const bondOffset = state.bonds.offset;
|
||||
const a = state.startVertex + i;
|
||||
const bStart = bondOffset[a], bEnd = bondOffset[a + 1];
|
||||
const bondCount = bEnd - bStart;
|
||||
if (bondCount <= 1 || (state.isRingAtom[i] && bondCount === 2)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function processResidue(state: State, start: number, end: number) {
|
||||
const { visited } = state;
|
||||
state.startVertex = start;
|
||||
state.endVertex = end;
|
||||
|
||||
@@ -117,11 +138,13 @@ function processResidue(state: State, start: number, end: number) {
|
||||
}
|
||||
arraySetRemove(altLocs, '');
|
||||
|
||||
let mark = 1;
|
||||
if (altLocs.length === 0) {
|
||||
resetState(state);
|
||||
for (let i = 0; i < state.count; i++) {
|
||||
if (visited[i] >= 0) continue;
|
||||
findRings(state, i);
|
||||
if (!isStartIndex(state, i)) continue;
|
||||
resetDepth(state);
|
||||
mark = findRings(state, i, mark);
|
||||
}
|
||||
} else {
|
||||
for (let aI = 0; aI < altLocs.length; aI++) {
|
||||
@@ -129,12 +152,13 @@ function processResidue(state: State, start: number, end: number) {
|
||||
state.hasAltLoc = true;
|
||||
state.currentAltLoc = altLocs[aI];
|
||||
for (let i = 0; i < state.count; i++) {
|
||||
if (visited[i] >= 0) continue;
|
||||
if (!isStartIndex(state, i)) continue;
|
||||
const altLoc = state.altLoc.value(elements[state.startVertex + i]);
|
||||
if (altLoc && altLoc !== state.currentAltLoc) {
|
||||
continue;
|
||||
}
|
||||
findRings(state, i);
|
||||
resetDepth(state);
|
||||
mark = findRings(state, i, mark);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,10 +168,10 @@ function processResidue(state: State, start: number, end: number) {
|
||||
}
|
||||
}
|
||||
|
||||
function addRing(state: State, a: number, b: number) {
|
||||
function addRing(state: State, a: number, b: number, isRingAtom: Int32Array) {
|
||||
// only "monotonous" rings
|
||||
if (b < a) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
const { pred, color, left, right } = state;
|
||||
@@ -176,7 +200,7 @@ function addRing(state: State, a: number, b: number) {
|
||||
if (current < 0) break;
|
||||
}
|
||||
if (!found) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
current = a;
|
||||
@@ -190,50 +214,50 @@ function addRing(state: State, a: number, b: number) {
|
||||
const len = leftOffset + rightOffset;
|
||||
// rings must have at least three elements
|
||||
if (len < 3) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
const ring = new Int32Array(len);
|
||||
let ringOffset = 0;
|
||||
for (let t = 0; t < leftOffset; t++) ring[ringOffset++] = state.startVertex + left[t];
|
||||
for (let t = rightOffset - 1; t >= 0; t--) ring[ringOffset++] = state.startVertex + right[t];
|
||||
for (let t = 0; t < leftOffset; t++) {
|
||||
ring[ringOffset++] = state.startVertex + left[t];
|
||||
isRingAtom[left[t]] = 1;
|
||||
}
|
||||
for (let t = rightOffset - 1; t >= 0; t--) {
|
||||
ring[ringOffset++] = state.startVertex + right[t];
|
||||
isRingAtom[right[t]] = 1;
|
||||
}
|
||||
|
||||
sortArray(ring);
|
||||
|
||||
if (state.hasAltLoc) {
|
||||
// we need to check if the ring was already added because alt locs are present.
|
||||
// Check if the ring is unique and another one is not it's subset
|
||||
for (let rI = 0, _rI = state.currentRings.length; rI < _rI; rI++) {
|
||||
const r = state.currentRings[rI];
|
||||
|
||||
for (let rI = 0, _rI = state.currentRings.length; rI < _rI; rI++) {
|
||||
const r = state.currentRings[rI];
|
||||
if (ring[0] !== r[0]) continue;
|
||||
if (ring.length !== r.length) continue;
|
||||
|
||||
let areSame = true;
|
||||
for (let aI = 0, _aI = ring.length; aI < _aI; aI++) {
|
||||
if (ring[aI] !== r[aI]) {
|
||||
areSame = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (areSame) {
|
||||
return;
|
||||
}
|
||||
if (ring.length === r.length) {
|
||||
if (SortedArray.areEqual(ring as any, r)) return false;
|
||||
} else if (ring.length > r.length) {
|
||||
if (SortedArray.isSubset(ring as any, r)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
state.currentRings.push(SortedArray.ofSortedArray(ring));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function findRings(state: State, from: number) {
|
||||
const { bonds, startVertex, endVertex, visited, queue, pred } = state;
|
||||
function findRings(state: State, from: number, mark: number) {
|
||||
const { bonds, startVertex, endVertex, isRingAtom, marked, queue, pred, depth } = state;
|
||||
const { elements } = state.unit;
|
||||
const { b: neighbor, edgeProps: { flags: bondFlags }, offset } = bonds;
|
||||
visited[from] = 1;
|
||||
marked[from] = mark;
|
||||
depth[from] = 0;
|
||||
queue[0] = from;
|
||||
let head = 0, size = 1;
|
||||
|
||||
while (head < size) {
|
||||
const top = queue[head++];
|
||||
const d = depth[top];
|
||||
const a = startVertex + top;
|
||||
const start = offset[a], end = offset[a + 1];
|
||||
|
||||
@@ -250,18 +274,25 @@ function findRings(state: State, from: number) {
|
||||
|
||||
const other = b - startVertex;
|
||||
|
||||
if (visited[other] > 0) {
|
||||
if (marked[other] === mark) {
|
||||
if (pred[other] !== top && pred[top] !== other) {
|
||||
addRing(state, top, other);
|
||||
if (addRing(state, top, other, isRingAtom)) {
|
||||
return mark + 1;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
visited[other] = 1;
|
||||
const newDepth = Math.min(depth[other], d + 1);
|
||||
if (newDepth > Constants.MaxDepth) continue;
|
||||
|
||||
depth[other] = newDepth;
|
||||
marked[other] = mark;
|
||||
queue[size++] = other;
|
||||
pred[other] = top;
|
||||
}
|
||||
}
|
||||
return mark + 1;
|
||||
}
|
||||
|
||||
export function getFingerprint(elements: string[]) {
|
||||
|
||||
@@ -1,28 +1,34 @@
|
||||
/**
|
||||
* 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 David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
|
||||
*/
|
||||
|
||||
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 { SIFTSMapping } from '../../../../mol-model-props/sequence/sifts-mapping';
|
||||
import { ElementIndex } from '../../model/indexing';
|
||||
import { Structure } from '../structure';
|
||||
import { Unit } from '../unit';
|
||||
|
||||
export interface AlignmentResult {
|
||||
export interface AlignmentResultEntry {
|
||||
transform: MinimizeRmsd.Result,
|
||||
pivot: number,
|
||||
other: number
|
||||
}
|
||||
|
||||
export function alignAndSuperposeWithBestDatabaseMapping(structures: Structure[]): AlignmentResult[] {
|
||||
export interface AlignmentResult {
|
||||
entries: AlignmentResultEntry[],
|
||||
zeroOverlapPairs: [number, number][],
|
||||
failedPairs: [number, number][]
|
||||
}
|
||||
|
||||
export function alignAndSuperposeWithSIFTSMapping(structures: Structure[], options?: { traceOnly?: boolean }): AlignmentResult {
|
||||
const indexMap = new Map<string, IndexEntry>();
|
||||
|
||||
for (let i = 0; i < structures.length; i++) {
|
||||
buildIndex(structures[i], indexMap, i);
|
||||
buildIndex(structures[i], indexMap, i, options?.traceOnly ?? true);
|
||||
}
|
||||
|
||||
const index = Array.from(indexMap.values());
|
||||
@@ -30,15 +36,26 @@ export function alignAndSuperposeWithBestDatabaseMapping(structures: Structure[]
|
||||
// TODO: support non-first structure pivots
|
||||
const pairs = findPairs(structures.length, index);
|
||||
|
||||
const ret: AlignmentResult[] = [];
|
||||
const zeroOverlapPairs: AlignmentResult['zeroOverlapPairs'] = [];
|
||||
const failedPairs: AlignmentResult['failedPairs'] = [];
|
||||
|
||||
|
||||
const entries: AlignmentResultEntry[] = [];
|
||||
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 });
|
||||
if (p.count === 0) {
|
||||
zeroOverlapPairs.push([p.i, p.j]);
|
||||
} else {
|
||||
const [a, b] = getPositionTables(index, p.i, p.j, p.count);
|
||||
const transform = MinimizeRmsd.compute({ a, b });
|
||||
if (Number.isNaN(transform.rmsd)) {
|
||||
failedPairs.push([p.i, p.j]);
|
||||
} else {
|
||||
entries.push({ transform, pivot: p.i, other: p.j });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return { entries, zeroOverlapPairs, failedPairs };
|
||||
}
|
||||
|
||||
function getPositionTables(index: IndexEntry[], pivot: number, other: number, N: number) {
|
||||
@@ -53,7 +70,6 @@ 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;
|
||||
@@ -121,19 +137,20 @@ interface IndexEntry {
|
||||
pivots: { [i: number]: [unit: Unit.Atomic, start: ElementIndex, end: ElementIndex] | undefined }
|
||||
}
|
||||
|
||||
function buildIndex(structure: Structure, index: Map<string, IndexEntry>, sI: number) {
|
||||
function buildIndex(structure: Structure, index: Map<string, IndexEntry>, sI: number, traceOnly: boolean) {
|
||||
for (const unit of structure.units) {
|
||||
if (unit.kind !== Unit.Kind.Atomic) continue;
|
||||
|
||||
const { elements, model } = unit;
|
||||
|
||||
const map = BestDatabaseSequenceMapping.Provider.get(model).value;
|
||||
const map = SIFTSMapping.Provider.get(model).value;
|
||||
if (!map) return;
|
||||
|
||||
const { dbName, accession, num } = map;
|
||||
|
||||
const chainsIt = Segmentation.transientSegments(unit.model.atomicHierarchy.chainAtomSegments, elements);
|
||||
const residuesIt = Segmentation.transientSegments(unit.model.atomicHierarchy.residueAtomSegments, elements);
|
||||
const traceElementIndex = unit.model.atomicHierarchy.derived.residue.traceElementIndex;
|
||||
|
||||
while (chainsIt.hasNext) {
|
||||
const chainSegment = chainsIt.move();
|
||||
@@ -144,8 +161,15 @@ function buildIndex(structure: Structure, index: Map<string, IndexEntry>, sI: nu
|
||||
|
||||
if (!dbName[rI]) continue;
|
||||
|
||||
const start = elements[residueSegment.start];
|
||||
const end = elements[residueSegment.end - 1] + 1 as ElementIndex;
|
||||
let start, end;
|
||||
if (traceOnly) {
|
||||
start = traceElementIndex[rI];
|
||||
if (start === -1) continue;
|
||||
end = start + 1 as ElementIndex;
|
||||
} else {
|
||||
start = elements[residueSegment.start];
|
||||
end = elements[residueSegment.end - 1] + 1 as ElementIndex;
|
||||
}
|
||||
|
||||
const key = `${dbName[rI]}-${accession[rI]}-${num[rI]}`;
|
||||
|
||||
@@ -161,6 +185,4 @@ function buildIndex(structure: Structure, index: Map<string, IndexEntry>, sI: nu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(index);
|
||||
}
|
||||
@@ -24,8 +24,6 @@ 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; }
|
||||
@@ -39,6 +37,7 @@ export namespace StructureRepresentationPresetProvider {
|
||||
|
||||
export const CommonParams = {
|
||||
ignoreHydrogens: PD.Optional(PD.Boolean(false)),
|
||||
ignoreLight: PD.Optional(PD.Boolean(false)),
|
||||
quality: PD.Optional(PD.Select<VisualQuality>('auto', VisualQualityOptions)),
|
||||
theme: PD.Optional(PD.Group({
|
||||
globalName: PD.Optional(PD.Text<ColorTheme.BuiltIn>('')),
|
||||
@@ -70,9 +69,11 @@ export namespace StructureRepresentationPresetProvider {
|
||||
const typeParams = {
|
||||
quality: plugin.managers.structure.component.state.options.visualQuality,
|
||||
ignoreHydrogens: !plugin.managers.structure.component.state.options.showHydrogens,
|
||||
ignoreLight: plugin.managers.structure.component.state.options.ignoreLight,
|
||||
};
|
||||
if (params.quality && params.quality !== 'auto') typeParams.quality = params.quality;
|
||||
if (params.ignoreHydrogens !== void 0) typeParams.ignoreHydrogens = !!params.ignoreHydrogens;
|
||||
if (params.ignoreLight !== void 0) typeParams.ignoreLight = !!params.ignoreLight;
|
||||
const color: ColorTheme.BuiltIn | undefined = params.theme?.globalName ? params.theme?.globalName : void 0;
|
||||
const ballAndStickColor: ColorTheme.BuiltInParams<'element-symbol'> = params.theme?.carbonColor !== undefined
|
||||
? { carbonColor: getCarbonColorParams(params.theme?.carbonColor) }
|
||||
@@ -100,15 +101,6 @@ 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: {
|
||||
@@ -148,7 +140,6 @@ const empty = StructureRepresentationPresetProvider({
|
||||
id: 'preset-structure-representation-empty',
|
||||
display: { name: 'Empty', description: 'Removes all existing representations.' },
|
||||
async apply(ref, params, plugin) {
|
||||
resetPostprocessingProps(plugin);
|
||||
return { };
|
||||
}
|
||||
});
|
||||
@@ -194,17 +185,15 @@ const polymerAndLigand = StructureRepresentationPresetProvider({
|
||||
nonStandard: builder.buildRepresentation(update, components.nonStandard, { type: 'ball-and-stick', typeParams, color, colorParams: ballAndStickColor }, { tag: 'non-standard' }),
|
||||
branchedBallAndStick: builder.buildRepresentation(update, components.branched, { type: 'ball-and-stick', typeParams: { ...typeParams, alpha: 0.3 }, color, colorParams: ballAndStickColor }, { tag: 'branched-ball-and-stick' }),
|
||||
branchedSnfg3d: builder.buildRepresentation(update, components.branched, { type: 'carbohydrate', typeParams, color }, { tag: 'branched-snfg-3d' }),
|
||||
water: builder.buildRepresentation(update, components.water, { type: waterType, typeParams: { ...typeParams, alpha: 0.6 }, color, colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'water' }),
|
||||
water: builder.buildRepresentation(update, components.water, { type: waterType, typeParams: { ...typeParams, alpha: 0.6, visuals: waterType === 'line' ? ['intra-bond', 'element-point'] : undefined }, color, colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'water' }),
|
||||
ion: builder.buildRepresentation(update, components.ion, { type: 'ball-and-stick', typeParams, color, colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ion' }),
|
||||
lipid: builder.buildRepresentation(update, components.lipid, { type: lipidType, typeParams: { ...typeParams, alpha: 0.6 }, color, colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'lipid' }),
|
||||
lipid: builder.buildRepresentation(update, components.lipid, { type: lipidType, typeParams: { ...typeParams, alpha: 0.6, visuals: lipidType === 'line' ? ['intra-bond'] : undefined }, color, colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'lipid' }),
|
||||
coarse: builder.buildRepresentation(update, components.coarse, { type: 'spacefill', typeParams, color: color || 'chain-id' }, { tag: 'coarse' })
|
||||
};
|
||||
|
||||
await update.commit({ revertOnError: false });
|
||||
await updateFocusRepr(plugin, structure, params.theme?.focus?.name, params.theme?.focus?.params);
|
||||
|
||||
resetPostprocessingProps(plugin);
|
||||
|
||||
return { components, representations };
|
||||
}
|
||||
});
|
||||
@@ -244,8 +233,6 @@ 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 };
|
||||
}
|
||||
});
|
||||
@@ -298,8 +285,6 @@ 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 };
|
||||
}
|
||||
});
|
||||
@@ -333,8 +318,6 @@ 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 };
|
||||
}
|
||||
});
|
||||
@@ -401,8 +384,6 @@ 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 };
|
||||
}
|
||||
});
|
||||
@@ -436,21 +417,6 @@ const illustrative = StructureRepresentationPresetProvider({
|
||||
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 };
|
||||
}
|
||||
});
|
||||
@@ -471,6 +437,6 @@ export const PresetStructureRepresentations = {
|
||||
'polymer-and-ligand': polymerAndLigand,
|
||||
'protein-and-nucleic': proteinAndNucleic,
|
||||
'coarse-surface': coarseSurface,
|
||||
'illustrative': illustrative,
|
||||
illustrative,
|
||||
};
|
||||
export type PresetStructureRepresentations = typeof PresetStructureRepresentations;
|
||||
@@ -29,7 +29,7 @@ export class StructureRepresentationBuilder {
|
||||
|
||||
readonly defaultProvider = PresetStructureRepresentations.auto;
|
||||
|
||||
private resolveProvider(ref: StructureRepresentationPresetProviderRef) {
|
||||
resolveProvider(ref: StructureRepresentationPresetProviderRef) {
|
||||
return typeof ref === 'string'
|
||||
? PresetStructureRepresentations[ref as keyof PresetStructureRepresentations] ?? arrayFind(this._providers, p => p.id === ref)
|
||||
: ref;
|
||||
|
||||
@@ -76,9 +76,11 @@ namespace InteractivityManager {
|
||||
|
||||
/**
|
||||
* The `noRender` argument indicates that the action should only update the internal
|
||||
* data structure but not render anything user visible. For example 1) no drawing of
|
||||
* the canvas3d scene or 2) no ui update of loci labels. This is useful because some
|
||||
* actions require clearing any markings before they can be applied.
|
||||
* data structure but not render anything user visible. For example, no ui update of
|
||||
* loci labels.
|
||||
*
|
||||
* This is useful because some actions require clearing any markings before
|
||||
* they can be applied.
|
||||
*/
|
||||
export type LociMarkProvider = (loci: Representation.Loci, action: MarkerAction, /* test */ noRender?: boolean) => void
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -71,6 +71,7 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone
|
||||
await update.commit();
|
||||
await this.plugin.state.updateBehavior(StructureFocusRepresentation, p => {
|
||||
p.ignoreHydrogens = !options.showHydrogens;
|
||||
p.ignoreLight = options.ignoreLight;
|
||||
p.material = options.materialStyle;
|
||||
p.clip = options.clipObjects;
|
||||
});
|
||||
@@ -79,16 +80,17 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone
|
||||
}
|
||||
|
||||
private updateReprParams(update: StateBuilder.Root, component: StructureComponentRef) {
|
||||
const { showHydrogens, visualQuality: quality, materialStyle: material, clipObjects: clip } = this.state.options;
|
||||
const { showHydrogens, visualQuality: quality, ignoreLight, materialStyle: material, clipObjects: clip } = this.state.options;
|
||||
const ignoreHydrogens = !showHydrogens;
|
||||
for (const r of component.representations) {
|
||||
if (r.cell.transform.transformer !== StructureRepresentation3D) continue;
|
||||
|
||||
const params = r.cell.transform.params as StateTransformer.Params<StructureRepresentation3D>;
|
||||
if (!!params.type.params.ignoreHydrogens !== ignoreHydrogens || params.type.params.quality !== quality || !shallowEqual(params.type.params.material, material) || !PD.areEqual(Clip.Params, params.type.params.clip, clip)) {
|
||||
if (!!params.type.params.ignoreHydrogens !== ignoreHydrogens || params.type.params.quality !== quality || params.type.params.ignoreLight !== ignoreLight || !shallowEqual(params.type.params.material, material) || !PD.areEqual(Clip.Params, params.type.params.clip, clip)) {
|
||||
update.to(r.cell).update(old => {
|
||||
old.type.params.ignoreHydrogens = ignoreHydrogens;
|
||||
old.type.params.quality = quality;
|
||||
old.type.params.ignoreLight = ignoreLight;
|
||||
old.type.params.material = material;
|
||||
old.type.params.clip = clip;
|
||||
});
|
||||
@@ -309,9 +311,9 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone
|
||||
addRepresentation(components: ReadonlyArray<StructureComponentRef>, type: string) {
|
||||
if (components.length === 0) return;
|
||||
|
||||
const { showHydrogens, visualQuality: quality, materialStyle: material, clipObjects: clip } = this.state.options;
|
||||
const { showHydrogens, visualQuality: quality, ignoreLight, materialStyle: material, clipObjects: clip } = this.state.options;
|
||||
const ignoreHydrogens = !showHydrogens;
|
||||
const typeParams = { ignoreHydrogens, quality, material, clip };
|
||||
const typeParams = { ignoreHydrogens, quality, ignoreLight, material, clip };
|
||||
|
||||
return this.plugin.dataTransaction(async () => {
|
||||
for (const component of components) {
|
||||
@@ -346,9 +348,9 @@ class StructureComponentManager extends StatefulPluginComponent<StructureCompone
|
||||
const xs = structures || this.currentStructures;
|
||||
if (xs.length === 0) return;
|
||||
|
||||
const { showHydrogens, visualQuality: quality, materialStyle: material, clipObjects: clip } = this.state.options;
|
||||
const { showHydrogens, visualQuality: quality, ignoreLight, materialStyle: material, clipObjects: clip } = this.state.options;
|
||||
const ignoreHydrogens = !showHydrogens;
|
||||
const typeParams = { ignoreHydrogens, quality, material, clip };
|
||||
const typeParams = { ignoreHydrogens, quality, ignoreLight, material, clip };
|
||||
|
||||
const componentKey = UUID.create22();
|
||||
for (const s of xs) {
|
||||
@@ -458,6 +460,7 @@ namespace StructureComponentManager {
|
||||
export const OptionsParams = {
|
||||
showHydrogens: PD.Boolean(true, { description: 'Toggle display of hydrogen atoms in representations' }),
|
||||
visualQuality: PD.Select('auto', VisualQualityOptions, { description: 'Control the visual/rendering quality of representations' }),
|
||||
ignoreLight: PD.Boolean(false, { description: 'Ignore light for stylized rendering of representtions' }),
|
||||
materialStyle: Material.getParam(),
|
||||
clipObjects: PD.Group(Clip.Params),
|
||||
interactions: PD.Group(InteractionsProvider.defaultParams, { label: 'Non-covalent Interactions' }),
|
||||
|
||||
@@ -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>
|
||||
@@ -24,6 +24,7 @@ import { StructureSourceControls } from './structure/source';
|
||||
import { VolumeStreamingControls, VolumeSourceControls } from './structure/volume';
|
||||
import { PluginConfig } from '../mol-plugin/config';
|
||||
import { StructureSuperpositionControls } from './structure/superposition';
|
||||
import { StructureQuickStylesControls } from './structure/quick-styles';
|
||||
|
||||
export class TrajectoryViewportControls extends PluginUIComponent<{}, { show: boolean, label: string }> {
|
||||
state = { show: false, label: '' };
|
||||
@@ -292,6 +293,7 @@ export class DefaultStructureTools extends PluginUIComponent {
|
||||
<StructureSourceControls />
|
||||
<StructureMeasurementsControls />
|
||||
<StructureSuperpositionControls />
|
||||
<StructureQuickStylesControls />
|
||||
<StructureComponentControls />
|
||||
{this.plugin.config.get(PluginConfig.VolumeStreaming.Enabled) && <VolumeStreamingControls />}
|
||||
<VolumeSourceControls />
|
||||
|
||||
@@ -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>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
@@ -38,10 +38,10 @@ export function MoleculeSvg() { return _Molecule; }
|
||||
// The following icons are adapted from https://materialdesignicons.com/ and
|
||||
// licensed with https://github.com/Templarian/MaterialDesign/blob/master/LICENSE
|
||||
|
||||
const _CubeOutline = <svg width='24px' height='24px' viewBox='0 0 24 24' strokeWidth='0.1px'><path d="M21,16.5C21,16.88 20.79,17.21 20.47,17.38L12.57,21.82C12.41,21.94 12.21,22 12,22C11.79,22 11.59,21.94 11.43,21.82L3.53,17.38C3.21,17.21 3,16.88 3,16.5V7.5C3,7.12 3.21,6.79 3.53,6.62L11.43,2.18C11.59,2.06 11.79,2 12,2C12.21,2 12.41,2.06 12.57,2.18L20.47,6.62C20.79,6.79 21,7.12 21,7.5V16.5M12,4.15L6.04,7.5L12,10.85L17.96,7.5L12,4.15M5,15.91L11,19.29V12.58L5,9.21V15.91M19,15.91V9.21L13,12.58V19.29L19,15.91Z" /></svg>;
|
||||
const _CubeOutline = <svg width='24px' height='24px' viewBox='0 0 24 24' strokeWidth='0.1px'><path d='M21,16.5C21,16.88 20.79,17.21 20.47,17.38L12.57,21.82C12.41,21.94 12.21,22 12,22C11.79,22 11.59,21.94 11.43,21.82L3.53,17.38C3.21,17.21 3,16.88 3,16.5V7.5C3,7.12 3.21,6.79 3.53,6.62L11.43,2.18C11.59,2.06 11.79,2 12,2C12.21,2 12.41,2.06 12.57,2.18L20.47,6.62C20.79,6.79 21,7.12 21,7.5V16.5M12,4.15L6.04,7.5L12,10.85L17.96,7.5L12,4.15M5,15.91L11,19.29V12.58L5,9.21V15.91M19,15.91V9.21L13,12.58V19.29L19,15.91Z' /></svg>;
|
||||
export function CubeOutlineSvg() { return _CubeOutline; }
|
||||
|
||||
const _CubeScan = <svg width='24px' height='24px' viewBox='0 0 24 24' strokeWidth='0.1px'><path d="M17,22V20H20V17H22V20.5C22,20.89 21.84,21.24 21.54,21.54C21.24,21.84 20.89,22 20.5,22H17M7,22H3.5C3.11,22 2.76,21.84 2.46,21.54C2.16,21.24 2,20.89 2,20.5V17H4V20H7V22M17,2H20.5C20.89,2 21.24,2.16 21.54,2.46C21.84,2.76 22,3.11 22,3.5V7H20V4H17V2M7,2V4H4V7H2V3.5C2,3.11 2.16,2.76 2.46,2.46C2.76,2.16 3.11,2 3.5,2H7M13,17.25L17,14.95V10.36L13,12.66V17.25M12,10.92L16,8.63L12,6.28L8,8.63L12,10.92M7,14.95L11,17.25V12.66L7,10.36V14.95M18.23,7.59C18.73,7.91 19,8.34 19,8.91V15.23C19,15.8 18.73,16.23 18.23,16.55L12.75,19.73C12.25,20.05 11.75,20.05 11.25,19.73L5.77,16.55C5.27,16.23 5,15.8 5,15.23V8.91C5,8.34 5.27,7.91 5.77,7.59L11.25,4.41C11.5,4.28 11.75,4.22 12,4.22C12.25,4.22 12.5,4.28 12.75,4.41L18.23,7.59Z" /></svg>;
|
||||
const _CubeScan = <svg width='24px' height='24px' viewBox='0 0 24 24' strokeWidth='0.1px'><path d='M17,22V20H20V17H22V20.5C22,20.89 21.84,21.24 21.54,21.54C21.24,21.84 20.89,22 20.5,22H17M7,22H3.5C3.11,22 2.76,21.84 2.46,21.54C2.16,21.24 2,20.89 2,20.5V17H4V20H7V22M17,2H20.5C20.89,2 21.24,2.16 21.54,2.46C21.84,2.76 22,3.11 22,3.5V7H20V4H17V2M7,2V4H4V7H2V3.5C2,3.11 2.16,2.76 2.46,2.46C2.76,2.16 3.11,2 3.5,2H7M13,17.25L17,14.95V10.36L13,12.66V17.25M12,10.92L16,8.63L12,6.28L8,8.63L12,10.92M7,14.95L11,17.25V12.66L7,10.36V14.95M18.23,7.59C18.73,7.91 19,8.34 19,8.91V15.23C19,15.8 18.73,16.23 18.23,16.55L12.75,19.73C12.25,20.05 11.75,20.05 11.25,19.73L5.77,16.55C5.27,16.23 5,15.8 5,15.23V8.91C5,8.34 5.27,7.91 5.77,7.59L11.25,4.41C11.5,4.28 11.75,4.22 12,4.22C12.25,4.22 12.5,4.28 12.75,4.41L18.23,7.59Z' /></svg>;
|
||||
export function CubeScanSvg() { return _CubeScan; }
|
||||
|
||||
const _CubeSend = <svg width='24px' height='24px' viewBox='0 0 24 24' strokeWidth='0.1px'><path d="M16,4L9,8.04V15.96L16,20L23,15.96V8.04M16,6.31L19.8,8.5L16,10.69L12.21,8.5M0,7V9H7V7M11,10.11L15,12.42V17.11L11,14.81M21,10.11V14.81L17,17.11V12.42M2,11V13H7V11M4,15V17H7V15" /></svg>;
|
||||
@@ -53,9 +53,12 @@ export function CursorDefaultOutlineSvg() { return _CursorDefaultOutline; }
|
||||
const _FileOutline = <svg width='24px' height='24px' viewBox='0 0 24 24' strokeWidth='0.1px'><path fill='currentColor' d='M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z' /></svg>;
|
||||
export function FileOutlineSvg() { return _FileOutline; }
|
||||
|
||||
const _PencilRuler = <svg width='24px' height='24px' viewBox='0 0 24 24' strokeWidth='0.1px'><path d="M3 17.25V21H6.75L17.81 9.93L14.06 6.18L3 17.25M22.61 18.36L18.36 22.61L13.16 17.41L14.93 15.64L15.93 16.64L18.4 14.16L19.82 15.58L18.36 17L19.42 18L20.84 16.6L22.61 18.36M6.61 10.83L1.39 5.64L5.64 1.39L7.4 3.16L4.93 5.64L6 6.7L8.46 4.22L9.88 5.64L8.46 7.05L9.46 8.05L6.61 10.83M20.71 7C21.1 6.61 21.1 6 20.71 5.59L18.37 3.29C18 2.9 17.35 2.9 16.96 3.29L15.12 5.12L18.87 8.87L20.71 7Z" /></svg>;
|
||||
const _PencilRuler = <svg width='24px' height='24px' viewBox='0 0 24 24' strokeWidth='0.1px'><path d='M3 17.25V21H6.75L17.81 9.93L14.06 6.18L3 17.25M22.61 18.36L18.36 22.61L13.16 17.41L14.93 15.64L15.93 16.64L18.4 14.16L19.82 15.58L18.36 17L19.42 18L20.84 16.6L22.61 18.36M6.61 10.83L1.39 5.64L5.64 1.39L7.4 3.16L4.93 5.64L6 6.7L8.46 4.22L9.88 5.64L8.46 7.05L9.46 8.05L6.61 10.83M20.71 7C21.1 6.61 21.1 6 20.71 5.59L18.37 3.29C18 2.9 17.35 2.9 16.96 3.29L15.12 5.12L18.87 8.87L20.71 7Z' /></svg>;
|
||||
export function PencilRulerSvg() { return _PencilRuler; }
|
||||
|
||||
const _MagicWand = <svg width='24px' height='24px' viewBox='0 0 24 24'><path fill='currentColor' d='M7.5,5.6L5,7L6.4,4.5L5,2L7.5,3.4L10,2L8.6,4.5L10,7L7.5,5.6M19.5,15.4L22,14L20.6,16.5L22,19L19.5,17.6L17,19L18.4,16.5L17,14L19.5,15.4M22,2L20.6,4.5L22,7L19.5,5.6L17,7L18.4,4.5L17,2L19.5,3.4L22,2M13.34,12.78L15.78,10.34L13.66,8.22L11.22,10.66L13.34,12.78M14.37,7.29L16.71,9.63C17.1,10 17.1,10.65 16.71,11.04L5.04,22.71C4.65,23.1 4,23.1 3.63,22.71L1.29,20.37C0.9,20 0.9,19.35 1.29,18.96L12.96,7.29C13.35,6.9 14,6.9 14.37,7.29Z' /></svg>;
|
||||
export function MagicWandSvg() { return _MagicWand; }
|
||||
|
||||
// The following icons are adapted from https://material-ui.com/components/material-icons/ and
|
||||
// licensed with https://github.com/mui-org/material-ui/blob/master/LICENSE
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
*/
|
||||
|
||||
import * as React from 'react';
|
||||
import { PluginUIComponent } from '../base';
|
||||
import { MarkerAction } from '../../mol-util/marker-action';
|
||||
import { ButtonsType, ModifiersKeys, getButtons, getModifiers, getButton } from '../../mol-util/input/input-observer';
|
||||
import { SequenceWrapper } from './wrapper';
|
||||
import { StructureElement, StructureProperties, Unit } from '../../mol-model/structure';
|
||||
import { Subject } from 'rxjs';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
import { throttleTime } from 'rxjs/operators';
|
||||
import { OrderedSet } from '../../mol-data/int';
|
||||
import { StructureElement, StructureProperties, Unit } from '../../mol-model/structure';
|
||||
import { Representation } from '../../mol-repr/representation';
|
||||
import { ButtonsType, getButton, getButtons, getModifiers, ModifiersKeys } from '../../mol-util/input/input-observer';
|
||||
import { MarkerAction } from '../../mol-util/marker-action';
|
||||
import { PluginUIComponent } from '../base';
|
||||
import { SequenceWrapper } from './wrapper';
|
||||
|
||||
type SequenceProps = {
|
||||
sequenceWrapper: SequenceWrapper.Any,
|
||||
@@ -55,12 +55,10 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> {
|
||||
this.plugin.managers.interactivity.lociHighlights.addProvider(this.lociHighlightProvider);
|
||||
this.plugin.managers.interactivity.lociSelects.addProvider(this.lociSelectionProvider);
|
||||
|
||||
this.subscribe(debounceTime<{ seqIdx: number, buttons: number, button: number, modifiers: ModifiersKeys }>(15)(this.highlightQueue), (e) => {
|
||||
this.subscribe(this.highlightQueue.pipe(throttleTime(3 * 16.666, void 0, { leading: true, trailing: true })), (e) => {
|
||||
const loci = this.getLoci(e.seqIdx < 0 ? void 0 : e.seqIdx);
|
||||
this.hover(loci, e.buttons, e.button, e.modifiers);
|
||||
});
|
||||
|
||||
// this.updateMarker()
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -490,7 +490,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.msp-action-menu-options {
|
||||
.msp-action-menu-options {
|
||||
&-no-header, .msp-control-group-children {
|
||||
max-height: 300px;
|
||||
overflow: hidden;
|
||||
@@ -602,10 +602,10 @@
|
||||
}
|
||||
|
||||
.msp-slider {
|
||||
> div:first-child() {
|
||||
> div:first-child {
|
||||
right: 42px;
|
||||
}
|
||||
> div:last-child() {
|
||||
> div:last-child {
|
||||
width: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
-webkit-touch-callout: none;
|
||||
touch-action: manipulation;
|
||||
@@ -71,7 +72,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.msp-semi-transparent-background {
|
||||
.msp-semi-transparent-background {
|
||||
background: $default-background;
|
||||
opacity: 0.5;
|
||||
position: absolute;
|
||||
@@ -94,7 +95,7 @@
|
||||
|
||||
.msp-viewport-controls-panel-controls {
|
||||
overflow-y: auto;
|
||||
max-height: 400px;
|
||||
max-height: 400px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
107
src/mol-plugin-ui/structure/quick-styles.tsx
Normal file
107
src/mol-plugin-ui/structure/quick-styles.tsx
Normal file
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* Copyright (c) 2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
import { PresetStructureRepresentations } from '../../mol-plugin-state/builder/structure/representation-preset';
|
||||
import { Color } from '../../mol-util/color';
|
||||
import { CollapsableControls, PurePluginUIComponent } from '../base';
|
||||
import { Button } from '../controls/common';
|
||||
import { MagicWandSvg } from '../controls/icons';
|
||||
import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { PostprocessingParams } from '../../mol-canvas3d/passes/postprocessing';
|
||||
import { PluginConfig } from '../../mol-plugin/config';
|
||||
import { StructureComponentManager } from '../../mol-plugin-state/manager/structure/component';
|
||||
|
||||
export class StructureQuickStylesControls extends CollapsableControls {
|
||||
defaultState() {
|
||||
return {
|
||||
isCollapsed: false,
|
||||
header: 'Quick Styles',
|
||||
brand: { accent: 'gray' as const, svg: MagicWandSvg }
|
||||
};
|
||||
}
|
||||
|
||||
renderControls() {
|
||||
return <>
|
||||
<QuickStyles />
|
||||
</>;
|
||||
}
|
||||
}
|
||||
|
||||
export class QuickStyles extends PurePluginUIComponent {
|
||||
async default() {
|
||||
const { structures } = this.plugin.managers.structure.hierarchy.selection;
|
||||
const preset = this.plugin.config.get(PluginConfig.Structure.DefaultRepresentationPreset) || PresetStructureRepresentations.auto.id;
|
||||
const provider = this.plugin.builders.structure.representation.resolveProvider(preset);
|
||||
await this.plugin.managers.structure.component.applyPreset(structures, provider);
|
||||
|
||||
this.plugin.managers.structure.component.setOptions(PD.getDefaultValues(StructureComponentManager.OptionsParams));
|
||||
|
||||
if (this.plugin.canvas3d) {
|
||||
const p = PD.getDefaultValues(PostprocessingParams);
|
||||
this.plugin.canvas3d.setProps({
|
||||
postprocessing: { outline: p.outline, occlusion: p.occlusion }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async illustrative() {
|
||||
const { structures } = this.plugin.managers.structure.hierarchy.selection;
|
||||
await this.plugin.managers.structure.component.applyPreset(structures, PresetStructureRepresentations.illustrative);
|
||||
|
||||
if (this.plugin.canvas3d) {
|
||||
this.plugin.canvas3d.setProps({
|
||||
postprocessing: {
|
||||
outline: {
|
||||
name: 'on',
|
||||
params: { scale: 1, color: Color(0x000000), threshold: 0.25 }
|
||||
},
|
||||
occlusion: {
|
||||
name: 'on',
|
||||
params: { bias: 0.8, blurKernelSize: 15, radius: 5, samples: 32, resolutionScale: 1 }
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async stylized() {
|
||||
this.plugin.managers.structure.component.setOptions({ ...this.plugin.managers.structure.component.state.options, ignoreLight: true });
|
||||
|
||||
if (this.plugin.canvas3d) {
|
||||
const pp = this.plugin.canvas3d.props.postprocessing;
|
||||
this.plugin.canvas3d.setProps({
|
||||
postprocessing: {
|
||||
outline: {
|
||||
name: 'on',
|
||||
params: pp.outline.name === 'on'
|
||||
? pp.outline.params
|
||||
: { scale: 1, color: Color(0x000000), threshold: 0.33 }
|
||||
},
|
||||
occlusion: {
|
||||
name: 'on',
|
||||
params: pp.occlusion.name === 'on'
|
||||
? pp.occlusion.params
|
||||
: { bias: 0.8, blurKernelSize: 15, radius: 5, samples: 32, resolutionScale: 1 }
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div className='msp-flex-row'>
|
||||
<Button noOverflow title='Applies default representation preset. Set outline and occlusion effects to defaults.' onClick={() => this.default()} style={{ width: 'auto' }}>
|
||||
Default
|
||||
</Button>
|
||||
<Button noOverflow title='Applies no representation preset. Enables outline and occlusion effects. Enables ignore-light representation parameter.' onClick={() => this.stylized()} style={{ width: 'auto' }}>
|
||||
Stylized
|
||||
</Button>
|
||||
<Button noOverflow title='Applies illustrative representation preset. Enables outline and occlusion effects. Enables ignore-light parameter.' onClick={() => this.illustrative()} style={{ width: 'auto' }}>
|
||||
Illustrative
|
||||
</Button>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
@@ -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 Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
* @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
|
||||
*/
|
||||
|
||||
import { CollapsableControls, PurePluginUIComponent } from '../base';
|
||||
@@ -20,9 +21,9 @@ import { ParameterControls } from '../controls/parameters';
|
||||
import { stripTags } from '../../mol-util/string';
|
||||
import { StructureSelectionHistoryEntry } from '../../mol-plugin-state/manager/structure/selection';
|
||||
import { ToggleSelectionModeButton } from './selection';
|
||||
import { alignAndSuperposeWithBestDatabaseMapping } from '../../mol-model/structure/structure/util/superposition-db-mapping';
|
||||
import { alignAndSuperposeWithSIFTSMapping } from '../../mol-model/structure/structure/util/superposition-sifts-mapping';
|
||||
import { PluginCommands } from '../../mol-plugin/commands';
|
||||
import { BestDatabaseSequenceMapping } from '../../mol-model-props/sequence/best-database-mapping';
|
||||
import { SIFTSMapping } from '../../mol-model-props/sequence/sifts-mapping';
|
||||
|
||||
export class StructureSuperpositionControls extends CollapsableControls {
|
||||
defaultState() {
|
||||
@@ -48,7 +49,8 @@ export class StructureSuperpositionControls extends CollapsableControls {
|
||||
}
|
||||
|
||||
export const StructureSuperpositionParams = {
|
||||
alignSequences: PD.Boolean(true, { isEssential: true, description: 'Perform a sequence alignment and use the aligned residue pairs to guide the 3D superposition.' }),
|
||||
alignSequences: PD.Boolean(true, { isEssential: true, description: 'For Chain-based 3D superposition, perform a sequence alignment and use the aligned residue pairs to guide the 3D superposition.' }),
|
||||
traceOnly: PD.Boolean(true, { description: 'For Chain- and Uniprot-based 3D superposition, base superposition only on CA (and equivalent) atoms.' })
|
||||
};
|
||||
const DefaultStructureSuperpositionOptions = PD.getDefaultValues(StructureSuperpositionParams);
|
||||
export type StructureSuperpositionOptions = PD.ValuesFor<typeof StructureSuperpositionParams>
|
||||
@@ -94,7 +96,7 @@ export class SuperpositionControls extends PurePluginUIComponent<{ }, Superposit
|
||||
});
|
||||
|
||||
this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, sel => {
|
||||
this.setState({ canUseDb: sel.structures.every(s => !!s.cell.obj?.data && s.cell.obj.data.models.some(m => BestDatabaseSequenceMapping.Provider.isApplicable(m))) });
|
||||
this.setState({ canUseDb: sel.structures.every(s => !!s.cell.obj?.data && s.cell.obj.data.models.some(m => SIFTSMapping.Provider.isApplicable(m))) });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -123,10 +125,10 @@ export class SuperpositionControls extends PurePluginUIComponent<{ }, Superposit
|
||||
}
|
||||
|
||||
superposeChains = async () => {
|
||||
const { query } = StructureSelectionQueries.trace;
|
||||
const { query } = this.state.options.traceOnly ? StructureSelectionQueries.trace : StructureSelectionQueries.polymer;
|
||||
const entries = this.chainEntries;
|
||||
|
||||
const traceLocis = entries.map((e, i) => {
|
||||
const locis = entries.map((e, i) => {
|
||||
const s = StructureElement.Loci.toStructure(e.loci);
|
||||
const loci = StructureSelection.toLociWithSourceUnits(query(new QueryContext(s)));
|
||||
return StructureElement.Loci.remap(loci, i === 0
|
||||
@@ -136,11 +138,11 @@ export class SuperpositionControls extends PurePluginUIComponent<{ }, Superposit
|
||||
});
|
||||
|
||||
const transforms = this.state.options.alignSequences
|
||||
? alignAndSuperpose(traceLocis)
|
||||
: superpose(traceLocis);
|
||||
? alignAndSuperpose(locis)
|
||||
: superpose(locis);
|
||||
|
||||
const eA = entries[0];
|
||||
for (let i = 1, il = traceLocis.length; i < il; ++i) {
|
||||
for (let i = 1, il = locis.length; i < il; ++i) {
|
||||
const eB = entries[i];
|
||||
const { bTransform, rmsd } = transforms[i - 1];
|
||||
await this.transform(eB.cell, bTransform);
|
||||
@@ -148,6 +150,7 @@ export class SuperpositionControls extends PurePluginUIComponent<{ }, Superposit
|
||||
const labelB = stripTags(eB.label);
|
||||
this.plugin.log.info(`Superposed [${labelA}] and [${labelB}] with RMSD ${rmsd.toFixed(2)}.`);
|
||||
}
|
||||
await this.cameraReset();
|
||||
};
|
||||
|
||||
superposeAtoms = async () => {
|
||||
@@ -171,26 +174,47 @@ export class SuperpositionControls extends PurePluginUIComponent<{ }, Superposit
|
||||
const count = entries[i].atoms.length;
|
||||
this.plugin.log.info(`Superposed ${count} ${count === 1 ? 'atom' : 'atoms'} of [${labelA}] and [${labelB}] with RMSD ${rmsd.toFixed(2)}.`);
|
||||
}
|
||||
await this.cameraReset();
|
||||
};
|
||||
|
||||
superposeDb = async () => {
|
||||
const input = this.plugin.managers.structure.hierarchy.behaviors.selection.value.structures;
|
||||
const traceOnly = this.state.options.traceOnly;
|
||||
|
||||
const transforms = alignAndSuperposeWithBestDatabaseMapping(input.map(s => s.cell.obj?.data!));
|
||||
const structures = input.map(s => s.cell.obj?.data!);
|
||||
const { entries, failedPairs, zeroOverlapPairs } = alignAndSuperposeWithSIFTSMapping(structures, { traceOnly });
|
||||
|
||||
let rmsd = 0;
|
||||
|
||||
for (const xform of transforms) {
|
||||
for (const xform of entries) {
|
||||
await this.transform(input[xform.other].cell, xform.transform.bTransform);
|
||||
rmsd += xform.transform.rmsd;
|
||||
}
|
||||
|
||||
rmsd /= Math.max(transforms.length - 1, 1);
|
||||
rmsd /= Math.max(entries.length - 1, 1);
|
||||
|
||||
this.plugin.log.info(`Superposed ${input.length} structures with avg. RMSD ${rmsd.toFixed(2)} Å.`);
|
||||
const formatPairs = (pairs: [number, number][]) => {
|
||||
return `[${pairs.map(([i, j]) => `(${structures[i].models[0].entryId}, ${structures[j].models[0].entryId})`).join(', ')}]`;
|
||||
};
|
||||
|
||||
if (zeroOverlapPairs.length) {
|
||||
this.plugin.log.warn(`Superposition: No UNIPROT mapping overlap between structures ${formatPairs(zeroOverlapPairs)}.`);
|
||||
}
|
||||
|
||||
if (failedPairs.length) {
|
||||
this.plugin.log.error(`Superposition: Failed to superpose structures ${formatPairs(failedPairs)}.`);
|
||||
}
|
||||
|
||||
if (entries.length) {
|
||||
this.plugin.log.info(`Superposed ${entries.length + 1} structures with avg. RMSD ${rmsd.toFixed(2)} Å.`);
|
||||
await this.cameraReset();
|
||||
}
|
||||
};
|
||||
|
||||
async cameraReset() {
|
||||
await new Promise(res => requestAnimationFrame(res));
|
||||
PluginCommands.Camera.Reset(this.plugin);
|
||||
};
|
||||
}
|
||||
|
||||
toggleByChains = () => this.setState({ action: this.state.action === 'byChains' ? void 0 : 'byChains' });
|
||||
toggleByAtoms = () => this.setState({ action: this.state.action === 'byAtoms' ? void 0 : 'byAtoms' });
|
||||
@@ -323,8 +347,8 @@ export class SuperpositionControls extends PurePluginUIComponent<{ }, Superposit
|
||||
|
||||
superposeByDbMapping() {
|
||||
return <>
|
||||
<Button icon={SuperposeChainsSvg} title='Superpose structures using database mapping.' className='msp-btn msp-btn-block' onClick={this.superposeDb} style={{ marginTop: '1px' }} disabled={this.state.isBusy}>
|
||||
DB
|
||||
<Button icon={SuperposeChainsSvg} title='Superpose structures using intersection of residues from SIFTS UNIPROT mapping.' className='msp-btn msp-btn-block' onClick={this.superposeDb} style={{ marginTop: '1px' }} disabled={this.state.isBusy}>
|
||||
Uniprot
|
||||
</Button>
|
||||
</>;
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ export class VolumeStreamingControls extends CollapsableControls<{}, VolumeStrea
|
||||
const rootCell = root && pivot.cell.parent.cells.get(root);
|
||||
|
||||
const simpleApply = rootCell && rootCell.status === 'error'
|
||||
? { header: 'Error enabling', icon: ErrorSvg, title: rootCell.errorText }
|
||||
? { header: !!rootCell.errorText && rootCell.errorText?.includes('404') ? 'No Density Data Available' : 'Error Enabling', icon: ErrorSvg, title: rootCell.errorText }
|
||||
: rootCell && rootCell.obj?.data.entries.length === 0
|
||||
? { header: 'Error enabling', icon: ErrorSvg, title: 'No entry for streaming found' }
|
||||
? { header: 'Error Enabling', icon: ErrorSvg, title: 'No Entry for Streaming Found' }
|
||||
: { header: 'Enable', icon: CheckSvg, title: 'Enable' };
|
||||
|
||||
return <ApplyActionControl state={pivot.cell.parent} action={InitVolumeStreaming} initiallyCollapsed={true} nodeRef={pivot.cell.transform.ref} simpleApply={simpleApply} />;
|
||||
|
||||
@@ -11,6 +11,6 @@ export { AccessibleSurfaceArea } from './custom-props/computed/accessible-surfac
|
||||
export { Interactions } from './custom-props/computed/interactions';
|
||||
export { SecondaryStructure } from './custom-props/computed/secondary-structure';
|
||||
export { ValenceModel } from './custom-props/computed/valence-model';
|
||||
export { BestDatabaseSequenceMapping } from './custom-props/sequence/best-database-mapping';
|
||||
export { SIFTSMapping as BestDatabaseSequenceMapping } from './custom-props/sequence/sifts-mapping';
|
||||
|
||||
export { CrossLinkRestraint } from './custom-props/integrative/cross-link-restraint';
|
||||
@@ -5,17 +5,17 @@
|
||||
*/
|
||||
|
||||
import { OrderedSet } from '../../../../../mol-data/int';
|
||||
import { BestDatabaseSequenceMapping as BestDatabaseSequenceMappingProp } from '../../../../../mol-model-props/sequence/best-database-mapping';
|
||||
import { BestDatabaseSequenceMappingColorThemeProvider } from '../../../../../mol-model-props/sequence/themes/best-database-mapping';
|
||||
import { SIFTSMapping as BestDatabaseSequenceMappingProp } from '../../../../../mol-model-props/sequence/sifts-mapping';
|
||||
import { SIFTSMappingColorThemeProvider } from '../../../../../mol-model-props/sequence/themes/sifts-mapping';
|
||||
import { Loci } from '../../../../../mol-model/loci';
|
||||
import { StructureElement } from '../../../../../mol-model/structure';
|
||||
import { ParamDefinition as PD } from '../../../../../mol-util/param-definition';
|
||||
import { PluginBehavior } from '../../../behavior';
|
||||
|
||||
export const BestDatabaseSequenceMapping = PluginBehavior.create<{ autoAttach: boolean, showTooltip: boolean }>({
|
||||
name: 'best-sequence-database-mapping-prop',
|
||||
export const SIFTSMapping = PluginBehavior.create<{ autoAttach: boolean, showTooltip: boolean }>({
|
||||
name: 'sifts-mapping-prop',
|
||||
category: 'custom-props',
|
||||
display: { name: 'Best Database Sequence Mapping' },
|
||||
display: { name: 'SIFTS Mapping' },
|
||||
ctor: class extends PluginBehavior.Handler<{ autoAttach: boolean, showTooltip: boolean }> {
|
||||
private provider = BestDatabaseSequenceMappingProp.Provider;
|
||||
|
||||
@@ -39,13 +39,13 @@ export const BestDatabaseSequenceMapping = PluginBehavior.create<{ autoAttach: b
|
||||
|
||||
register(): void {
|
||||
this.ctx.customModelProperties.register(this.provider, this.params.autoAttach);
|
||||
this.ctx.representation.structure.themes.colorThemeRegistry.add(BestDatabaseSequenceMappingColorThemeProvider);
|
||||
this.ctx.representation.structure.themes.colorThemeRegistry.add(SIFTSMappingColorThemeProvider);
|
||||
this.ctx.managers.lociLabels.addProvider(this.labelProvider);
|
||||
}
|
||||
|
||||
unregister() {
|
||||
this.ctx.customModelProperties.unregister(this.provider.descriptor.name);
|
||||
this.ctx.representation.structure.themes.colorThemeRegistry.remove(BestDatabaseSequenceMappingColorThemeProvider);
|
||||
this.ctx.representation.structure.themes.colorThemeRegistry.remove(SIFTSMappingColorThemeProvider);
|
||||
this.ctx.managers.lociLabels.removeProvider(this.labelProvider);
|
||||
}
|
||||
},
|
||||
@@ -43,9 +43,9 @@ export const HighlightLoci = PluginBehavior.create({
|
||||
name: 'representation-highlight-loci',
|
||||
category: 'interaction',
|
||||
ctor: class extends PluginBehavior.Handler<HighlightLociProps> {
|
||||
private lociMarkProvider = (interactionLoci: Representation.Loci, action: MarkerAction, noRender?: boolean) => {
|
||||
private lociMarkProvider = (interactionLoci: Representation.Loci, action: MarkerAction) => {
|
||||
if (!this.ctx.canvas3d || !this.params.mark) return;
|
||||
this.ctx.canvas3d.mark(interactionLoci, action, noRender);
|
||||
this.ctx.canvas3d.mark(interactionLoci, action);
|
||||
};
|
||||
private getLoci(loci: Loci) {
|
||||
return this.params.preferAtoms && Bond.isLoci(loci) && loci.bonds.length === 2
|
||||
@@ -113,9 +113,9 @@ export const SelectLoci = PluginBehavior.create({
|
||||
category: 'interaction',
|
||||
ctor: class extends PluginBehavior.Handler<SelectLociProps> {
|
||||
private spine: StateTreeSpine.Impl;
|
||||
private lociMarkProvider = (reprLoci: Representation.Loci, action: MarkerAction, noRender?: boolean) => {
|
||||
private lociMarkProvider = (reprLoci: Representation.Loci, action: MarkerAction) => {
|
||||
if (!this.ctx.canvas3d || !this.params.mark) return;
|
||||
this.ctx.canvas3d.mark({ loci: reprLoci.loci }, action, noRender);
|
||||
this.ctx.canvas3d.mark({ loci: reprLoci.loci }, action);
|
||||
};
|
||||
private getLoci(loci: Loci) {
|
||||
return this.params.preferAtoms && Bond.isLoci(loci) && loci.bonds.length === 2
|
||||
|
||||
@@ -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>
|
||||
@@ -27,11 +27,19 @@ const StructureFocusRepresentationParams = (plugin: PluginContext) => {
|
||||
expandRadius: PD.Numeric(5, { min: 1, max: 10, step: 1 }),
|
||||
targetParams: PD.Group(reprParams, {
|
||||
label: 'Target',
|
||||
customDefault: createStructureRepresentationParams(plugin, void 0, { type: 'ball-and-stick', size: 'physical', typeParams: { sizeFactor: 0.26, alpha: 0.51, adjustCylinderLength: true } })
|
||||
customDefault: createStructureRepresentationParams(plugin, void 0, {
|
||||
type: 'ball-and-stick',
|
||||
size: 'physical',
|
||||
typeParams: { sizeFactor: 0.22, sizeAspectRatio: 0.73, adjustCylinderLength: true, xrayShaded: true, aromaticBonds: false, multipleBonds: 'off', excludeTypes: ['hydrogen-bond', 'metal-coordination'] },
|
||||
})
|
||||
}),
|
||||
surroundingsParams: PD.Group(reprParams, {
|
||||
label: 'Surroundings',
|
||||
customDefault: createStructureRepresentationParams(plugin, void 0, { type: 'ball-and-stick', size: 'physical', typeParams: { sizeFactor: 0.16 } })
|
||||
customDefault: createStructureRepresentationParams(plugin, void 0, {
|
||||
type: 'ball-and-stick',
|
||||
size: 'physical',
|
||||
typeParams: { sizeFactor: 0.16, excludeTypes: ['hydrogen-bond', 'metal-coordination'] }
|
||||
})
|
||||
}),
|
||||
nciParams: PD.Group(reprParams, {
|
||||
label: 'Non-covalent Int.',
|
||||
@@ -44,6 +52,7 @@ const StructureFocusRepresentationParams = (plugin: PluginContext) => {
|
||||
components: PD.MultiSelect(FocusComponents, PD.arrayToOptions(FocusComponents)),
|
||||
excludeTargetFromSurroundings: PD.Boolean(false, { label: 'Exclude Target', description: 'Exclude the focus "target" from the surroudings component.' }),
|
||||
ignoreHydrogens: PD.Boolean(false),
|
||||
ignoreLight: PD.Boolean(false),
|
||||
material: Material.getParam(),
|
||||
clip: PD.Group(Clip.Params),
|
||||
};
|
||||
@@ -68,10 +77,10 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber
|
||||
|
||||
private getReprParams(reprParams: PD.Values<PD.Params>) {
|
||||
return {
|
||||
...this.params.targetParams,
|
||||
...reprParams,
|
||||
type: {
|
||||
name: reprParams.type.name,
|
||||
params: { ...reprParams.type.params, ignoreHydrogens: this.params.ignoreHydrogens, material: this.params.material, clip: this.params.clip }
|
||||
params: { ...reprParams.type.params, ignoreHydrogens: this.params.ignoreHydrogens, ignoreLight: this.params.ignoreLight, material: this.params.material, clip: this.params.clip }
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -114,7 +123,7 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber
|
||||
if (components.indexOf('interactions') >= 0 && !refs[StructureFocusRepresentationTags.SurrNciRepr] && cell.obj && InteractionsRepresentationProvider.isApplicable(cell.obj?.data)) {
|
||||
refs[StructureFocusRepresentationTags.SurrNciRepr] = builder
|
||||
.to(refs[StructureFocusRepresentationTags.SurrSel]!)
|
||||
.apply(StateTransforms.Representation.StructureRepresentation3D, this.params.nciParams, { tags: StructureFocusRepresentationTags.SurrNciRepr }).ref;
|
||||
.apply(StateTransforms.Representation.StructureRepresentation3D, this.getReprParams(this.params.nciParams), { tags: StructureFocusRepresentationTags.SurrNciRepr }).ref;
|
||||
}
|
||||
|
||||
return { state, builder, refs };
|
||||
@@ -216,7 +225,7 @@ class StructureFocusRepresentationBehavior extends PluginBehavior.WithSubscriber
|
||||
hasComponent = components.indexOf('interactions') >= 0;
|
||||
for (const repr of state.select(all.withTag(StructureFocusRepresentationTags.SurrNciRepr))) {
|
||||
if (!hasComponent) builder.delete(repr.transform.ref);
|
||||
else builder.to(repr).update(this.params.nciParams);
|
||||
else builder.to(repr).update(this.getReprParams(this.params.nciParams));
|
||||
}
|
||||
|
||||
await PluginCommands.State.Update(this.plugin, { state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } });
|
||||
|
||||
@@ -69,8 +69,16 @@ export async function getContourLevel(provider: 'emdb' | 'pdbe', plugin: PluginC
|
||||
export async function getContourLevelEmdb(plugin: PluginContext, taskCtx: RuntimeContext, emdbId: string) {
|
||||
const emdbHeaderServer = plugin.config.get(PluginConfig.VolumeStreaming.EmdbHeaderServer);
|
||||
const header = await plugin.fetch({ url: `${emdbHeaderServer}/${emdbId.toUpperCase()}/header/${emdbId.toLowerCase()}.xml`, type: 'xml' }).runInContext(taskCtx);
|
||||
const map = header.getElementsByTagName('map')[0];
|
||||
const contourLevel = parseFloat(map.getElementsByTagName('contourLevel')[0].textContent!);
|
||||
const contours = header.getElementsByTagName('contour');
|
||||
|
||||
let primaryContour = contours[0];
|
||||
for (let i = 1; i < contours.length; i++) {
|
||||
if (contours[i].getAttribute('primary') === 'true') {
|
||||
primaryContour = contours[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
const contourLevel = parseFloat(primaryContour.getElementsByTagName('level')[0].textContent!);
|
||||
|
||||
return contourLevel;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class ViewportScreenshotHelper extends PluginComponent {
|
||||
postprocessing: {
|
||||
...c.props.postprocessing,
|
||||
occlusion: aoProps.name === 'on'
|
||||
? { name: 'on', params: { ...aoProps.params, samples: 128 } }
|
||||
? { name: 'on', params: { ...aoProps.params, samples: 128, resolutionScale: 1 } }
|
||||
: aoProps
|
||||
},
|
||||
marking: { ...c.props.marking }
|
||||
@@ -143,7 +143,7 @@ class ViewportScreenshotHelper extends PluginComponent {
|
||||
postprocessing: {
|
||||
...c.props.postprocessing,
|
||||
occlusion: aoProps.name === 'on'
|
||||
? { name: 'on', params: { ...aoProps.params, samples: 128 } }
|
||||
? { name: 'on', params: { ...aoProps.params, samples: 128, resolutionScale: 1 } }
|
||||
: aoProps
|
||||
},
|
||||
marking: { ...c.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>
|
||||
*/
|
||||
@@ -35,7 +35,7 @@ export const CartoonParams = {
|
||||
...NucleotideRingParams,
|
||||
...PolymerDirectionParams,
|
||||
sizeFactor: PD.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
|
||||
visuals: PD.MultiSelect(['polymer-trace', 'polymer-gap', 'nucleotide-block'], PD.objectToOptions(CartoonVisuals)),
|
||||
visuals: PD.MultiSelect(['polymer-trace', 'polymer-gap', 'nucleotide-ring'], PD.objectToOptions(CartoonVisuals)),
|
||||
bumpFrequency: PD.Numeric(2, { min: 0, max: 10, step: 0.1 }, BaseGeometry.ShadingCategory),
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ export function getCartoonParams(ctx: ThemeRegistryContext, structure: Structure
|
||||
if (!hasGaps && u.gapElements.length) hasGaps = true;
|
||||
});
|
||||
params.visuals.defaultValue = ['polymer-trace'];
|
||||
if (hasNucleotides) params.visuals.defaultValue.push('nucleotide-block');
|
||||
if (hasNucleotides) params.visuals.defaultValue.push('nucleotide-ring');
|
||||
if (hasGaps) params.visuals.defaultValue.push('polymer-gap');
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* 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 Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -31,7 +31,7 @@ export const LineParams = {
|
||||
...ElementCrossParams,
|
||||
multipleBonds: PD.Select('offset', PD.arrayToOptions(['off', 'symmetric', 'offset'] as const)),
|
||||
includeParent: PD.Boolean(false),
|
||||
sizeFactor: PD.Numeric(3, { min: 0.01, max: 10, step: 0.01 }),
|
||||
sizeFactor: PD.Numeric(2, { min: 0.01, max: 10, step: 0.01 }),
|
||||
unitKinds: getUnitKindsParam(['atomic']),
|
||||
visuals: PD.MultiSelect(['intra-bond', 'inter-bond', 'element-point', 'element-cross'], PD.objectToOptions(LineVisuals))
|
||||
};
|
||||
|
||||
@@ -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>
|
||||
@@ -79,12 +79,16 @@ function getIntraUnitBondCylinderBuilderProps(unit: Unit.Atomic, structure: Stru
|
||||
};
|
||||
|
||||
const { elementRingIndices, elementAromaticRingIndices } = unit.rings;
|
||||
const deloTriplets = aromaticBonds ? unit.resonance.delocalizedTriplets : undefined;
|
||||
|
||||
return {
|
||||
linkCount: edgeCount * 2,
|
||||
referencePosition: (edgeIndex: number) => {
|
||||
let aI = a[edgeIndex], bI = b[edgeIndex];
|
||||
|
||||
const rI = deloTriplets?.getThirdElement(aI, bI);
|
||||
if (rI !== undefined) return pos(elements[rI], vRef);
|
||||
|
||||
if (aI > bI) [aI, bI] = [bI, aI];
|
||||
if (offset[aI + 1] - offset[aI] === 1) [aI, bI] = [bI, aI];
|
||||
|
||||
@@ -145,8 +149,10 @@ function getIntraUnitBondCylinderBuilderProps(unit: Unit.Atomic, structure: Stru
|
||||
if (isBondType(f, BondType.Flag.Aromatic) || (arCount && !ignoreComputedAromatic)) {
|
||||
if (arCount === 2) {
|
||||
return LinkStyle.MirroredAromatic;
|
||||
} else {
|
||||
} else if (arCount === 1 || deloTriplets?.getThirdElement(aI, bI)) {
|
||||
return LinkStyle.Aromatic;
|
||||
} else {
|
||||
// case for bonds between two aromatic rings
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* 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 Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
@@ -52,12 +52,16 @@ function createIntraUnitBondLines(ctx: VisualContext, unit: Unit, structure: Str
|
||||
const pos = unit.conformation.invariantPosition;
|
||||
|
||||
const { elementRingIndices, elementAromaticRingIndices } = unit.rings;
|
||||
const deloTriplets = aromaticBonds ? unit.resonance.delocalizedTriplets : undefined;
|
||||
|
||||
const builderProps: LinkBuilderProps = {
|
||||
linkCount: edgeCount * 2,
|
||||
referencePosition: (edgeIndex: number) => {
|
||||
let aI = a[edgeIndex], bI = b[edgeIndex];
|
||||
|
||||
const rI = deloTriplets?.getThirdElement(aI, bI);
|
||||
if (rI !== undefined) return pos(elements[rI], vRef);
|
||||
|
||||
if (aI > bI) [aI, bI] = [bI, aI];
|
||||
if (offset[aI + 1] - offset[aI] === 1) [aI, bI] = [bI, aI];
|
||||
|
||||
@@ -106,8 +110,10 @@ function createIntraUnitBondLines(ctx: VisualContext, unit: Unit, structure: Str
|
||||
if (isBondType(f, BondType.Flag.Aromatic) || (arCount && !ignoreComputedAromatic)) {
|
||||
if (arCount === 2) {
|
||||
return LinkStyle.MirroredAromatic;
|
||||
} else {
|
||||
} else if (arCount === 1 || deloTriplets?.getThirdElement(aI, bI)) {
|
||||
return LinkStyle.Aromatic;
|
||||
} else {
|
||||
// case for bonds between two aromatic rings
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,4 +264,4 @@ 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>
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
@@ -22,9 +22,6 @@ import { SpheresBuilder } from '../../../../mol-geo/geometry/spheres/spheres-bui
|
||||
import { isTrace, isH, StructureGroup } from './common';
|
||||
import { Sphere3D } from '../../../../mol-math/geometry';
|
||||
|
||||
// avoiding namespace lookup improved performance in Chrome (Aug 2020)
|
||||
const v3add = Vec3.add;
|
||||
|
||||
type ElementProps = {
|
||||
ignoreHydrogens: boolean,
|
||||
traceOnly: boolean,
|
||||
@@ -73,17 +70,13 @@ export function createElementSphereMesh(ctx: VisualContext, unit: Unit, structur
|
||||
const ignore = makeElementIgnoreTest(structure, unit, props);
|
||||
const l = StructureElement.Location.create(structure, unit);
|
||||
const themeSize = theme.size.size;
|
||||
const center = Vec3();
|
||||
let maxSize = 0;
|
||||
let count = 0;
|
||||
|
||||
for (let i = 0; i < elementCount; i++) {
|
||||
if (ignore && ignore(elements[i])) continue;
|
||||
|
||||
l.element = elements[i];
|
||||
pos(elements[i], v);
|
||||
v3add(center, center, v);
|
||||
count += 1;
|
||||
|
||||
builderState.currentGroup = i;
|
||||
const size = themeSize(l);
|
||||
@@ -92,17 +85,8 @@ export function createElementSphereMesh(ctx: VisualContext, unit: Unit, structur
|
||||
addSphere(builderState, v, size * sizeFactor, detail);
|
||||
}
|
||||
|
||||
// re-use boundingSphere if it has not changed much
|
||||
let boundingSphere: Sphere3D;
|
||||
Vec3.scale(center, center, 1 / count);
|
||||
if (mesh && Vec3.distance(center, mesh.boundingSphere.center) / mesh.boundingSphere.radius < 1.0) {
|
||||
boundingSphere = Sphere3D.clone(mesh.boundingSphere);
|
||||
} else {
|
||||
boundingSphere = Sphere3D.expand(Sphere3D(), (childUnit ?? unit).boundary.sphere, maxSize * sizeFactor + 0.05);
|
||||
}
|
||||
|
||||
const m = MeshBuilder.getMesh(builderState);
|
||||
m.setBoundingSphere(boundingSphere);
|
||||
m.setBoundingSphere(Sphere3D.expand(Sphere3D(), (childUnit ?? unit).boundary.sphere, maxSize * sizeFactor + 0.05));
|
||||
|
||||
return m;
|
||||
}
|
||||
@@ -126,34 +110,21 @@ export function createElementSphereImpostor(ctx: VisualContext, unit: Unit, stru
|
||||
|
||||
const l = StructureElement.Location.create(structure, unit);
|
||||
const themeSize = theme.size.size;
|
||||
const center = Vec3();
|
||||
let maxSize = 0;
|
||||
let count = 0;
|
||||
|
||||
for (let i = 0; i < elementCount; i++) {
|
||||
if (ignore?.(elements[i])) continue;
|
||||
|
||||
pos(elements[i], v);
|
||||
builder.add(v[0], v[1], v[2], i);
|
||||
v3add(center, center, v);
|
||||
count += 1;
|
||||
|
||||
l.element = elements[i];
|
||||
const size = themeSize(l);
|
||||
if (size > maxSize) maxSize = size;
|
||||
}
|
||||
|
||||
// re-use boundingSphere if it has not changed much
|
||||
let boundingSphere: Sphere3D;
|
||||
Vec3.scale(center, center, 1 / count);
|
||||
if (spheres && Vec3.distance(center, spheres.boundingSphere.center) / spheres.boundingSphere.radius < 1.0) {
|
||||
boundingSphere = Sphere3D.clone(spheres.boundingSphere);
|
||||
} else {
|
||||
boundingSphere = Sphere3D.expand(Sphere3D(), (childUnit ?? unit).boundary.sphere, maxSize * props.sizeFactor + 0.05);
|
||||
}
|
||||
|
||||
const s = builder.getSpheres();
|
||||
s.setBoundingSphere(boundingSphere);
|
||||
s.setBoundingSphere(Sphere3D.expand(Sphere3D(), (childUnit ?? unit).boundary.sphere, maxSize * props.sizeFactor + 0.05));
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"alwaysStrict": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"sourceMap": true,
|
||||
"sourceMap": false,
|
||||
"noUnusedLocals": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"alwaysStrict": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"sourceMap": true,
|
||||
"sourceMap": false,
|
||||
"noUnusedLocals": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
|
||||
Reference in New Issue
Block a user