diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index ccfd8b2..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: ci -on: - push: - branches: - - master - - main -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.x - - run: pip install mkdocs-material - - run: git submodule update --init --recursive - - run: mkdocs gh-deploy --force diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 58ec61a..0000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -site/ -.idea -.DS_Store diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 1be205b..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "mkdocs-material"] - path = mkdocs-material - url = https://github.com/squidfunk/mkdocs-material \ No newline at end of file diff --git a/README.md b/README.md index 22e95f1..d46746b 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,3 @@ -# Mol* Documentation - -Contributions to the documentations are highly welcome! Please make a pull request with your changes. - -Requires Python 3.x to build. - -``` -pip install mkdocs-material -git clone --recursive https://github.com/molstar/docs.git -cd docs -``` - -For local preview, run - -``` -mkdocs serve -``` +# Mol* Developer Documentation +This is a helper repository for publishing developer documentation from the [main repo](https://github.com/molstar/molstar/tree/master/docs) to https://molstar.org/docs/. \ No newline at end of file diff --git a/docs/data-access-tools/convert-to-bcif.md b/docs/data-access-tools/convert-to-bcif.md deleted file mode 100644 index 294b66b..0000000 --- a/docs/data-access-tools/convert-to-bcif.md +++ /dev/null @@ -1,41 +0,0 @@ -# Convert CIF to BinaryCIF -BinaryCIF is an efficient, binary flavor of the CIF format. See [specification](https://github.com/molstar/BinaryCIF) and [publication](https://doi.org/10.1371/journal.pcbi.1008247) for further details. - -This script reads data in CIF format and converts it lossless to a BinaryCIF file that can be read by Mol* or other -applications. - -## Example -```sh -node lib/commonjs/cli/cif2bcif/index.js file.cif file.bcif -``` - -## Usage -| Argument | Description | -| --- | --- | -| `src` | Source CIF to convert (can be gzipped) | -| `out` | Generated BinaryCIF output path | -| `-c` | Path to optional config file | -| `-f` | Path to optional filter file | - -```sh -index.js [-h] [-c CONFIG] [-f FILTER] src out -``` - -### Config file -Controls how certain columns will be encoded. This is a JSON array of instructions: -```ts -interface EncodingStrategyHint { - categoryName: string, - columnName: string, - encoding: 'pack' | 'rle' | 'delta' | 'delta-rle', - precision?: number -} -``` -Identify a particular CIF columns by its name and override the encoding by Integer Packing, Run-Length Encoding, Delta -Encoding, or Delta & Run-Length Encoding. You can optionally control the precision if dealing with float values. - -### Filter file -Specifies which categories and columns will be written. This is a plain text file, each line represents one entry. -You can specify explicitly which categories or columns to include by adding `category_name` or -`category_name.field_name`. You can also choose to ignore some categories or columns by adding `!category_name` or -`!category_name.field_name`. \ No newline at end of file diff --git a/docs/data-access-tools/create-ccd-table.md b/docs/data-access-tools/create-ccd-table.md deleted file mode 100644 index e55575f..0000000 --- a/docs/data-access-tools/create-ccd-table.md +++ /dev/null @@ -1,25 +0,0 @@ -# Create Table from CCD -The [Chemical Component Dictionary (CCD)](https://www.wwpdb.org/data/ccd) is as an external reference file describing -all residue and small molecule components found in PDB entries. The -[Protonation Variants Companion Dictionary (PVCD)](https://www.wwpdb.org/data/ccd) enumerates protonation variants of -canonical amino acids. - -This script bundles all `chem_comp_bond` information from the CCD and the PVCD into a single file for later use. -Optionally, it can also generate a second output file that contains all `chem_comp_atom` information. - -## Example -```sh -node --max-old-space-size=4096 lib/commonjs/cli/chem-comp-dict/create-table.js build/data/ccb.bcif -b -``` - -## Usage -| Argument | Description | -| --- | --- | -| `out` | Generated file output path | -| `--forceDownload`, `-f` | Force download of CCD and PVCD | -| `--binary`, `-b` | Output as BinaryCIF | -| `--ccaOut`, `-a` | File output path of optionally generated chem_comp_atom | - -```sh -create-table.js [-h] [--forceDownload] [--binary] [--ccaOut CCAOUT] out -``` \ No newline at end of file diff --git a/docs/data-access-tools/extract-ccd-ions.md b/docs/data-access-tools/extract-ccd-ions.md deleted file mode 100644 index 044ae66..0000000 --- a/docs/data-access-tools/extract-ccd-ions.md +++ /dev/null @@ -1,20 +0,0 @@ -# Extract Ions from CCD -The [Chemical Component Dictionary (CCD)](https://www.wwpdb.org/data/ccd) is as an external reference file describing -all residue and small molecule components found in PDB entries. - -This script extracts all ions from the CCD and provides their names as TypeScript set. - -## Example -```sh -node --max-old-space-size=4096 lib/commonjs/cli/chem-comp-dict/create-ions.js src/mol-model/structure/model/types/ions.ts -``` - -## Usage -| Argument | Description | -| --- | --- | -| `out` | Generated file output path | -| `--forceDownload`, `-f` | Force download of CCD | - -```sh -create-ions.js [-h] [--forceDownload] out -``` \ No newline at end of file diff --git a/docs/data-access-tools/model-server.md b/docs/data-access-tools/model-server.md deleted file mode 100644 index 7e9ec8a..0000000 --- a/docs/data-access-tools/model-server.md +++ /dev/null @@ -1,105 +0,0 @@ -# Model Server - -Provides access to molecular 1D, 2D, and 3D (sub-)structure models of molecules. Substructures are described by the -mol-script (MolQL) language. It has the ability to include additional data to mmCIF “on the fly”, e.g. integrate -primary PDB archival data from [Chemical Component Dictionary (CCD)](https://www.wwpdb.org/data/ccd), -[Protonation Variants Companion Dictionary (PVCD)](https://www.wwpdb.org/data/ccd) and -[Biologically Interesting moleculeReference Dictionary (BIRD)](https://www.wwpdb.org/data/bird). - -## Example -```sh -node lib/commonjs/servers/model/server --sourceMap pdb-bcif '/opt/data/bcif/${id}.bcif' -``` - -## Usage -| Argument | Description | -| --- | --- | -| `--version`, `-v` | Show program's version number and exit. | -| `--cfg` | JSON config file path. If a property is not specified, cmd line param/OS variable/default value are used. | -| `--printCfg` | Print current config for validation and exit. | -| `--cfgTemplate` | Prints default JSON config template to be modified and exit. | -| `--apiPrefix` | Specify the prefix of the API, i.e. <host>/<apiPrefix>/<API queries> | -| `--defaultPort` | Specify the port the server is running on | -| `--cacheMaxSizeInBytes` | Read structures are cached, this specifies the cache size, 0 for off. | -| `--cacheEntryTimeoutMs` | Specify in ms how long to keep entries in cache. | -| `--requestTimeoutMs` | The maximum number of ms the server spends on a request. | -| `--queryTimeoutMs` | The maximum time the server dedicates to executing a query in ms. Does not include the time it takes to read and export the data. | -| `--shutdownTimeoutMinutes` | Server will shut down after this amount of minutes, 0 for off. | -| `--shutdownTimeoutVarianceMinutes` | Modifies the shutdown timer by +/- `timeoutVarianceMinutes` (to avoid multiple instances shutting at the same time) | -| `--maxQueryManyQueries` | Maximum number of queries allowed by the query-many at a time | -| `--defaultSource` | modifies which 'sourceMap' source to use by default | -| `--sourceMap` | Map `id`s for a `source` to a file path. Example: `pdb-bcif '../../data/bcif/${id}.bcif'` - JS expressions can be used inside `${}`, e.g. `${id.substr(1, 2)}/${id}.mdb` Can be specified multiple times. The `SOURCE` variable (e.g. `pdb-bcif`) is arbitrary and depends on how you plan to use the server. Supported formats: cif, bcif, cif.gz, bcif.gz | -| `--sourceMapUrl` | Same as `--sourceMap` but for URL. `--sourceMapUrl src url format` Example: `pdb-cif "https://www.ebi.ac.uk/pdbe/entry-files/download/${id}_updated.cif" cif` Supported formats: cif, bcif, cif.gz, bcif.gz | - -```sh -node lib/commonjs/servers/model/server [-h] [-v] - [--cfg CFG] - [--printCfg] - [--cfgTemplate] - [--apiPrefix PREFIX] - [--defaultPort PORT] - [--cacheMaxSizeInBytes CACHE_SIZE] - [--cacheEntryTimeoutMs CACHE_TIMEOUT] - [--requestTimeoutMs REQUEST_TIMEOUT] - [--queryTimeoutMs QUERY_TIMEOUT] - [--shutdownTimeoutMinutes TIME] - [--shutdownTimeoutVarianceMinutes VARIANCE] - [--maxQueryManyQueries QUERY_MANY_LIMIT] - [--defaultSource DEFAULT_SOURCE] - [--sourceMap SOURCE PATH] - [--sourceMapUrl SOURCE PATH SOURCE_MAP_FORMAT] -``` - -### Production Use -In production, it is required to use a service that will keep the server running, such as [forever.js](https://github.com/foreverjs/forever). - -### Memory Issues -Sometimes nodejs might run into problems with memory. This is usually resolved by adding the ``--max-old-space-size=8192`` parameter. - -### Preprocessor Example -The preprocessor application allows addiing custom data to CIF files and/or -[convert CIF to BinaryCIF](./convert-to-bcif.md). -```sh -node lib/commonjs/servers/model/preprocess -``` - -### Preprocessor Usage -| Argument | Description | -| --- | --- | -| `--input`, `-i` | Input filename | -| `--outCIF`, `-oc` | Output CIF filename | -| `--outBCIF`, `-ob` | Output BinaryCIF filename | -| `--cfg`, `-c` | Config file path | -| `--folderIn`, `-fin` | Convert folder | -| `--folderOutCIF`, `-foc` | Convert folder text output | -| `--folderOutBCIF`, `-fob` | Convert folder binary output | -| `--folderNumProcesses`, `-fp` | Convert folder number processes | - -Example cfg.json: -```ts -{ - "numProcesses": 1, - "customProperties": { - "sources": [ "wwpdb" ], - "params": { - "wwPDB": { - "chemCompBondTablePath": "./build/data/ccb.bcif" - } - } - } -} -``` - -### Local Mode -The server can be run in local/file based mode using -```sh -node lib/commonjs/servers/model/query -``` - -### Custom Properties -This feature is still in development. - -It is possible to provide property descriptors that transform data to internal representation and define how it should -be exported into one or mode CIF categories. Examples of this are located in the ``mol-model-props`` module and are -linked to the server in the config and ``servers/model/properties``. - diff --git a/docs/data-access-tools/plugin-state-server.md b/docs/data-access-tools/plugin-state-server.md deleted file mode 100644 index 43859b3..0000000 --- a/docs/data-access-tools/plugin-state-server.md +++ /dev/null @@ -1,22 +0,0 @@ -# Plugin State Server - -Provides a simple backend for online storing and sharing of Mol* sessions used by -[``mol-plugin``](https://github.com/molstar/molstar/tree/master/src/mol-plugin) and -[``mol-state``](https://github.com/molstar/molstar/tree/master/src/mol-state) modules. - -## Example -```sh -node lib/commonjs/servers/plugin-state --workding-folder ~ -``` - -## Usage -| Argument | Description | -| --- | --- | -| `--working-folder` | Working folder path | -| `--port` | Server port. Alternatively, use ENV variable PORT. | -| `--api-prefix` | Server API prefix | -| `--max-states` | Maximum number of states to save | - -```sh -node lib/commonjs/servers/plugin-state [-h] --working-folder WORKING_FOLDER [--port PORT] [--api-prefix API_PREFIX] [--max-states MAX_STATES] -``` \ No newline at end of file diff --git a/docs/data-access-tools/volume-server.md b/docs/data-access-tools/volume-server.md deleted file mode 100644 index a36a8b1..0000000 --- a/docs/data-access-tools/volume-server.md +++ /dev/null @@ -1,40 +0,0 @@ -# Volume Server - -Provides near-instantaneous access to volumetric data including density maps (for instance, from X-ray crystallography -or cryo-electron microscopy experiments), spatial distribution data, output from electrostatic calculations. It works by -utilizing adaptive downsampling (similar to how Google Earth works). - -## Example -```sh -node lib/commonjs/servers/volume/server --idMap x-ray '/opt/data/xray/${id}.mdb' -``` - -## Usage -| Argument= | Description | -| --- | --- | -| `--cfg` | JSON config file path. If a property is not specified, cmd line param/OS variable/default value are used. | -| `--printCfg` | Print current config for validation and exit. | -| `--cfgTemplate` | Prints default JSON config template to be modified and exit. | -| `--apiPrefix` | Specify the prefix of the API, i.e. <host>/<apiPrefix>/<API queries> | -| `--defaultPort` | Specify the port the server is running on | -| `--shutdownTimeoutMinutes` | Server will shut down after this amount of minutes, 0 for off. | -| `--shutdownTimeoutVarianceMinutes` | Modifies the shutdown timer by +/- `timeoutVarianceMinutes` (to avoid multiple instances shutting at the same time) | -| `--idMap` | Map `id`s for a `type` to a file path. Example: `x-ray '../../data/mdb/xray/${id}-ccp4.mdb'` - JS expressions can be used inside `${}`, e.g. `${id.substr(1, 2)}/${id}.mdb` - Can be specified multiple times. - The `TYPE` variable (e.g. `x-ray`) is arbitrary and depends on how you plan to use the server. By default, Mol* Viewer uses `x-ray` and `em`, but any particular use case may vary. | -| `--maxRequestBlockCount` | Maximum number of blocks that could be read in 1 query. This is somewhat tied to the ``maxOutputSizeInVoxelCountByPrecisionLevel`` in that the `<maximum number of voxel> = maxRequestBlockCount * <block size>^3`. The default block size is 96 which corresponds to 28,311,552 voxels with 32 max blocks. | -| `--maxFractionalBoxVolume` | The maximum fractional volume of the query box (to prevent queries that are too big). | -| `--maxOutputSizeInVoxelCountByPrecisionLevel` | What is the (approximate) maximum desired size in voxel count by precision level - Rule of thumb: `<response gzipped size>` in `[<voxel count> / 8, <voxel count> / 4]`. The maximum number of voxels is tied to maxRequestBlockCount. | - -```sh -node lib/commonjs/servers/volume/server [-h] [-v] - [--cfg CFG] - [--printCfg] - [--cfgTemplate] - [--apiPrefix PREFIX] - [--defaultPort PORT] - [--shutdownTimeoutMinutes TIME] - [--shutdownTimeoutVarianceMinutes VARIANCE] - [--idMap TYPE PATH] - [--maxRequestBlockCount COUNT] - [--maxFractionalBoxVolume VOLUME] - [--maxOutputSizeInVoxelCountByPrecisionLevel LEVEL [LEVEL ...]] -``` \ No newline at end of file diff --git a/docs/data-state.md b/docs/data-state.md deleted file mode 100644 index d53ea7b..0000000 --- a/docs/data-state.md +++ /dev/null @@ -1,11 +0,0 @@ -# Data State Management - -## Managers - -## State Tree, Selectors, Transforms - -## State Snapshots - -## Structure, Trajectory, Cell - -## Ref, Representation \ No newline at end of file diff --git a/docs/examples.md b/docs/examples.md deleted file mode 100644 index 5f7ff7b..0000000 --- a/docs/examples.md +++ /dev/null @@ -1,3 +0,0 @@ -# Examples - -Refer to Mol* [Apps](https://github.com/molstar/molstar/tree/master/src/apps) and [Examples](https://github.com/molstar/molstar/tree/master/src/examples). \ No newline at end of file diff --git a/docs/extensions/mvs/index.md b/docs/extensions/mvs/index.md deleted file mode 100644 index c3456d8..0000000 --- a/docs/extensions/mvs/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# MolViewSpec - -Please see the [standalone MolViewSpec documentation](https://molstar.org/mol-view-spec-docs/). diff --git a/docs/extensions/struct-conn.md b/docs/extensions/struct-conn.md deleted file mode 100644 index 47d0846..0000000 --- a/docs/extensions/struct-conn.md +++ /dev/null @@ -1,6 +0,0 @@ -# wwPDB StructConn extension - -**wwPDB StructConn extension** provides functionality to retrieve and visualize the connections from the STRUCT_CONN category in mmCIF files (such as hydrogen bonds, salt bridges, disulfide bridges). - - -Refer to [Documentation for Mol* wwPDB StructConn extension](https://github.com/molstar/molstar/blob/master/docs/extensions/struct-conn.md) diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index ae93313..0000000 --- a/docs/index.md +++ /dev/null @@ -1,43 +0,0 @@ -# Installation - -## NPM Package - -``` -yarn add molstar -``` - -or - -``` -npm install molstar -``` - -Mol* code can then be imported from the ``molstar/lib/...`` namespace, e.g. - -```ts -import { PluginContext } from 'molstar/lib/mol-plugin/context'; -``` - -## Clone from GitHub - - -``` -git clone https://github.com/molstar/molstar.git -cd molstar -npm install -npm build -``` - --------------------- - -For a watch task to automatically rebuild the source code on changes, run - -``` -npm run watch -``` - -or if working just with the Viewer app for better performance - -``` -npm run watch-viewer -``` diff --git a/docs/plugin.md b/docs/plugin.md deleted file mode 100644 index 8f962e6..0000000 --- a/docs/plugin.md +++ /dev/null @@ -1,274 +0,0 @@ -# Creating Plugin Instance - - -## Intro - -What is a plugin? A plugin is a collection of modules that provide functionality to the `Mol*` UI. The plugin is responsible for managing the state of the viewer, internal and user interactions. It has been a previous point of confusion for new users of `Mol*` to associate the __viewer__ part of the library with what is further referred to as the __plugin__. These two are closely connected in the `molstar-plugin-ui` module, which is the user-facing part of the library and ultimately provides the viewer, but they are ultimately distinct. - - -It is recommended that you inspect the general class structure of [`PluginInitWrapper`](https://github.com/molstar/molstar/blob/6edbae80db340134341631f669eec86543a0f1a8/src/mol-plugin-ui/plugin.tsx#L41), [`PluginUIContext`](https://github.com/molstar/molstar/blob/6edbae80db340134341631f669eec86543a0f1a8/src/mol-plugin/context.ts#L71) and [`PluginUIComponent`](https://github.com/molstar/molstar/blob/6edbae80db340134341631f669eec86543a0f1a8/src/mol-plugin-ui/base.tsx#L16) to better understand the flow of data and events in the plugin. -A passing analogy is that a [ `PluginContext` ](https://github.com/molstar/molstar/blob/6edbae80db340134341631f669eec86543a0f1a8/src/mol-plugin/context.ts#L71) is the engine that powers computation, rendering, events and subscriptions inside the molstar UI. All UI components depend on `PluginContext`. - - - -There are 4 basic ways of instantiating the Mol* plugin. - -## ``Viewer`` wrapper - -- The most basic usage is to use the ``Viewer`` wrapper. This is best suited for use cases that do not require much custom behavior and are mostly about just displaying a structure. -- See ``Viewer`` class is defined in [src/apps/viewer/app.ts](https://github.com/molstar/molstar/blob/master/src/apps/viewer/app.ts) for available methods and options. - -Example usage without using WebPack: - -```HTML - - - - - -
- - -``` - -When using WebPack (or possibly other build tool) with the Mol* NPM package installed, the viewer class can be imported using - -```ts -import { Viewer } from 'molstar/build/viewer/molstar' - -function initViewer(target: string | HTMLElement) { - return new Viewer(target, { /* options */}) -} -``` - -## ``PluginContext`` with built-in React UI - -- For more customization options it is possible to use the [``PluginContext``](https://github.com/molstar/molstar/blob/master/src/mol-plugin/context.ts) directly. -- When creating the plugin instance it is possible to customize the [``PluginSpec``](https://github.com/molstar/molstar/blob/master/src/mol-plugin/spec.ts). -- The default [``PluginSpec``](https://github.com/molstar/molstar/blob/master/src/mol-plugin/spec.ts) is available [here](https://github.com/molstar/molstar/blob/master/src/mol-plugin/spec.ts). -- [``PluginConfig``](https://github.com/molstar/molstar/blob/master/src/mol-plugin/config.ts) object provides additional customization options. -- See the [Viewer State Management](viewer-state.md) section for more information on customizing things like background. -- See the [Data State Management](data-state.md) section for more information on build the state. - -```ts -import { DefaultPluginUISpec, PluginUISpec } from 'molstar/lib/mol-plugin-ui/spec'; -import { createPluginUI } from 'molstar/lib/mol-plugin-ui'; -import { renderReact18 } from 'molstar/lib/mol-plugin-ui/react18'; -import { PluginConfig } from 'molstar/lib/mol-plugin/config'; - -const MySpec: PluginUISpec = { - ...DefaultPluginUISpec(), - config: [ - [PluginConfig.VolumeStreaming.Enabled, false] - ] -} - -async function createPlugin(parent: HTMLElement) { - const plugin = await createPluginUI({ - target: parent, - spec: MySpec, - render: renderReact18 - }); - - const data = await plugin.builders.data.download({ url: '...' }, { state: { isGhost: true } }); - const trajectory = await plugin.builders.structure.parseTrajectory(data, format); - await this.plugin.builders.structure.hierarchy.applyPreset(trajectory, 'default'); - - return plugin; -} - -createPlugin(document.getElementById('app')!); // app is a
element with position: relative -``` - -To use the plugin (with the React UI) inside another React app: - -A single-plugin setup is shown the example below. In order to initialize multiple -plugins, each with its own context and viewport, some extra steps are required (docs section to be added). - -```ts -import { useEffect, createRef } from "react"; -import { createPluginUI } from "molstar/lib/mol-plugin-ui"; -import { renderReact18 } from "molstar/lib/mol-plugin-ui/react18"; -import { PluginUIContext } from "molstar/lib/mol-plugin-ui/context"; -/* Might require extra configuration, -see https://webpack.js.org/loaders/sass-loader/ for example. -create-react-app should support this natively. */ -import "molstar/lib/mol-plugin-ui/skin/light.scss"; - -declare global { - interface Window { - molstar?: PluginUIContext; - } -} - - -export function MolStarWrapper() { - const parent = createRef(); - - // In debug mode of react's strict mode, this code will - // be called twice in a row, which might result in unexpected behavior. - useEffect(() => { - async function init() { - window.molstar = await createPluginUI({ - target: parent.current as HTMLDivElement, - render: renderReact18 - }); - - const data = await window.molstar.builders.data.download( - { url: "https://files.rcsb.org/download/3PTB.pdb" }, /* replace with your URL */ - { state: { isGhost: true } } - ); - const trajectory = - await window.molstar.builders.structure.parseTrajectory(data, "pdb"); - await window.molstar.builders.structure.hierarchy.applyPreset( - trajectory, - "default" - ); - } - init(); - return () => { - window.molstar?.dispose(); - window.molstar = undefined; - }; - }, []); - - return
; -} - -``` - - -Furthermore, if it is desirable in your project to use the `molstar`'s React UI components, but you wish to alter or rearrange the layout, you should take a look at the signatures of [ `PluginUIComponent` ](https://github.com/molstar/molstar/blob/6edbae80db340134341631f669eec86543a0f1a8/src/mol-plugin-ui/base.tsx#L16) which every "control" subclasses. - - -[ `SequenceView` ](https://github.com/molstar/molstar/blob/6edbae80db340134341631f669eec86543a0f1a8/src/mol-plugin-ui/sequence.tsx#L221C4-L221C4), for example, can be used separately from the `PluginUI`. Yet you would need to pass the `PluginUIContext` to it in order for it to observe the changes in the state of the plugin. This can be done via a `PluginContextContainer`: -```typescript -// your_app.plugin: PluginUIContext -... -
- - - -
-``` - -## Directly using Mol* React UI - -```ts -class MolStarWrapper { - private resolveInit: () => void; - initialized = new Promise(res => { this.resolveInit = () => res(true); }); - - private initCalled = false; - plugin: PluginUIContext; - async init() { - if (this.initCalled) return; - this.initCalled = true; - this.plugin = ...; - await this.plugin.init(); - this.resolveInit(); - } -} - -function MolStar({ model }: { model: MolStarWrapper }) { - const [initialized, setInitialized] = useState(false); - useEffect(() => { - async function init() { - await model.init(); - setInitialized(true); - } - init(); - }, [model]); - - if (!initialized) return <>Loading; - return
- -
; -} -``` - -## ``PluginContext`` without built-in React UI - -- The [``PluginContext``](https://github.com/molstar/molstar/blob/master/src/mol-plugin/context.ts) can be instantiated without using the default React UI. - -```HTML -
- -
-``` - -```ts -import { DefaultPluginSpec, PluginSpec } from 'molstar/lib/mol-plugin/spec'; -import { PluginContext } from 'molstar/lib/mol-plugin/context'; -import { PluginConfig } from 'molstar/lib/mol-plugin/config'; - -const MySpec: PluginSpec = { - ...DefaultPluginSpec(), - config: [ - [PluginConfig.VolumeStreaming.Enabled, false] - ] -} - -async function init() { - const plugin = new PluginContext(MySpec); - await plugin.init(); - - const canvas = document.getElementById('molstar-canvas'); - const parent = document.getElementById('molstar-parent'); - - if (!plugin.initViewer(canvas, parent)) { - console.error('Failed to init Mol*'); - return; - } - - // Example url:"https://files.rcsb.org/download/3j7z.pdb" - // Example url:"https://files.rcsb.org/download/5AFI.cif" - const data = await plugin.builders.data.download({ url: '...' }, { state: { isGhost: true } }); - const trajectory = await plugin.builders.structure.parseTrajectory(data, format); //format is 'mmcif' or 'pdb' etc. - await plugin.builders.structure.hierarchy.applyPreset(trajectory, 'default'); -} - -``` - -## ``Canvas3D`` without built-in state management - -- The ``PluginContext`` object from the above examples can be completely omitted. -- See [Browser Tests](https://github.com/molstar/molstar/tree/master/src/tests/browser) for example usage. - -```ts -const canvas = document.getElementById('canvas'); // parent element -const canvas3d = Canvas3D.create(Canvas3DContext.fromCanvas(canvas)); -canvas3d.animate(); -// use the canvas3d object here -``` diff --git a/docs/selections.md b/docs/selections.md deleted file mode 100644 index cb67e52..0000000 --- a/docs/selections.md +++ /dev/null @@ -1,110 +0,0 @@ -# Selections - - -Assuming you have a model already loaded into the plugin (see [initiation](./plugin.md)), these are some of the following method you can select structural data. - -### Selecting directly from the `hierarchy` manager - -One can select a subcomponent's data directly from the plugin manager. - -```typescript -import { Structure } from '../mol-model/structure'; - -const ligandData = plugin.managers.structure.hierarchy.selection.structures[0]?.components[0]?.cell.obj?.data; -const ligandLoci = Structure.toStructureElementLoci(ligandData as any); - -plugin.managers.camera.focusLoci(ligandLoci); -plugin.managers.interactivity.lociSelects.select({ loci: ligandLoci }); -``` - -## Selection callbacks -If you want to subscribe to selection events (e.g. to change external state in your application based on a user selection), you can use: `plugin.behaviors.interaction.click.subscribe` - -Here's an example of passing in a React "set" function to update selected residue positions. -```typescript -import { - Structure, - StructureProperties, -} from "molstar/lib/mol-model/structure" -// setSelected is assumed to be a "set" function returned by useState -// (selected: any[]) => void -plugin.behaviors.interaction.click.subscribe( - (event: InteractivityManager.ClickEvent) => { - const selections = Array.from( - plugin.managers.structure.selection.entries.values() - ); - // This bit can be customized to record any piece information you want - const localSelected: any[] = []; - for (const { structure } of selections) { - if (!structure) continue; - Structure.eachAtomicHierarchyElement(structure, { - residue: (loc) => { - const position = StructureProperties.residue.label_seq_id(loc); - localSelected.push({ position }); - }, - }); - } - setSelected(localSelected); - } -) -``` - -### `Molscript` language - -Molscript is a language for addressing crystallographic structures and is a part of the Mol* library found at `https://github.com/molstar/molstar/tree/master/src/mol-script`. It can be used against the Molstar plugin as a query language and traspiled against multiple external molecular visualization libraries(see [here](https://github.com/molstar/molstar/tree/master/src/mol-script/transpilers)). - -### Querying a structure for a specific chain and residue range (select residues with 12 Q.struct.generator.atomGroups({ - 'chain-test' : Q.core.rel.eq([Q.struct.atomProperty.macromolecular.auth_asym_id(), A]), - "residue-test": Q.core.rel.eq([Q.struct.atomProperty.macromolecular.label_seq_id(), 124]), - }), objdata) - -let loci = StructureSelection.toLociWithSourceUnits(sel); -``` diff --git a/docs/transforms/custom-trajectory.md b/docs/transforms/custom-trajectory.md deleted file mode 100644 index aa192e6..0000000 --- a/docs/transforms/custom-trajectory.md +++ /dev/null @@ -1,72 +0,0 @@ -# Load Trajectory from a Custom Format - -This section shows a high level example for loading trajectory from custom data in specialized plugin instances. A more complete solution is available for example in form of the [G3D format extension](https://github.com/molstar/molstar/tree/master/src/extensions/g3d). - -## Defining and Using a Custom Transformer - -```ts -import { StateTransformer } from 'molstar/lib/mol-state'; - -const CreateTransformer = StateTransformer.builderFactory('custom-namespace'); - -export interface CustomTrajectoryData { - // ... -} - -export const TrajectoryFromCustomData = CreateTransformer({ - name: 'trajectory-from-custom-data', - display: 'Trajectory', - from: PluginStateObject.Root, - to: PluginStateObject.Molecule.Trajectory, - params: { - data: PD.Value(void 0 as any, { isHidden: true }), - }, -})({ - apply({ params }) { - return Task.create('Trajectory', async (ctx) => { - const models = await customParse(params.data, ctx); - return new PluginStateObject.Molecule.Trajectory(models, { - label: 'Trajectory', - }); - }); - }, -}); -``` - -The ``customParse`` function can usually be implemented -by modifying/extending an [existing parser already available in Mol*](https://github.com/molstar/molstar/tree/master/src/mol-model-formats/structure). - -To use the transformer: - -```ts -const data: CustomTrajectoryData = await (await fetch(url)).json(); -const trajectory = await plugin.build().toRoot().apply(TrajectoryFromCustomData, { data }).commit(); -// Create the representation -await plugin.builders.structure.hierarchy.applyPreset(trajectory, 'default'); -``` - -## Using Mol* to Download the Data - -```ts -export const TrajectoryFromCustomData = CreateTransformer({ - name: 'trajectory-from-custom-data', - display: 'Trajectory', - from: PluginStateObject.Data.String, // or PluginStateObject.Data.Binary - to: PluginStateObject.Molecule.Trajectory, -})({ - apply({ a }) { - return Task.create('Trajectory', async (ctx) => { - const models = await customParse(a.data, ctx); - return new PluginStateObject.Molecule.Trajectory(models, { - label: 'Trajectory', - }); - }); - }, -}); - -////////////// - -const data = await plugin.builders.data.download({ url, isBinary }); -const trajectory = await plugin.build().to(data).apply(TrajectoryFromCustomData, { data }).commit(); -await plugin.builders.structure.hierarchy.applyPreset(trajectory, 'default'); -``` \ No newline at end of file diff --git a/docs/viewer-state.md b/docs/viewer-state.md deleted file mode 100644 index 4bea390..0000000 --- a/docs/viewer-state.md +++ /dev/null @@ -1,132 +0,0 @@ -# Viewer State Management - -## ``Canvas3D`` Properties -Properties of the [``Canvas3D``](https://github.com/molstar/molstar/blob/master/src/mol-canvas3d/canvas3d.ts) can be -changed using [``PluginCommands``](https://github.com/molstar/molstar/blob/master/src/mol-plugin/commands.ts). - - -### Change background, highlight, or select color -```ts -import { ColorNames } from 'molstar/lib/mol-util/color/names'; -import { PluginCommands } from 'molstar/lib/mol-plugin/commands'; - -const renderer = plugin.canvas3d!.props.renderer; -PluginCommands.Canvas3D.SetSettings(plugin, { settings: { renderer: { ...renderer, backgroundColor: ColorNames.red /* or: 0xff0000 as Color */ } } }); -``` -Similarly, `highlightColor` and `selectColor` can be updated. - - -## Interactivity - -Interactivity in Mol* is based on the concept of ``Loci``. A ``Loci`` usually references a collection of objects and can be created by a [``Selection``](selections.md). For example, the -``Loci`` captures all atoms in the chain with label_asym_id B of a protein: -```ts -import { Script } from 'molstar/lib/mol-script/script'; -import { StructureSelection } from 'molstar/lib/mol-model/structure/query'; - -const data = plugin.managers.structure.hierarchy.current.structures[0]?.cell.obj?.data; -if (!data) return; - -const selection = Script.getStructureSelection(Q => Q.struct.generator.atomGroups({ - 'chain-test': Q.core.rel.eq(['B', Q.ammp('label_asym_id')]) -}), data); -const loci = StructureSelection.toLociWithSourceUnits(selection); -``` -A ``Loci`` can be used to trigger custom [``Behaviors``](#behaviors). - - -### Log message to Mol* console -The built-in console in the bottom center of the plugin shows log entries. -```ts -plugin.log.message('This message will appear in the Mol* console'); -``` -Other log levels are: `info`, `warn`, and `error`. - - -### Show toast message -Toast messages will appear in the bottom right of the plugin and will linger for a limited time before disappearing. -```ts -import { PluginCommands } from 'molstar/lib/mol-plugin/commands'; - -PluginCommands.Toast.Show(plugin, { - title: 'Custom Message', - message: 'A custom toast message that will disappear after 2 seconds.', - key: 'toast-custom', - timeoutMs: 2000 -}); -``` - -## Behaviors - -The state of the Mol* plugin is usually governed by dynamic behaviors which can be set up in initial plugin specification or updated during the plugin runtime. This allows for high modularity and customizability of individual plugin instances. - - -### Highlight ``Loci`` -Highlighting adds a transient overpaint to a representation that will linger until the mouse enters hovers over another -object. Highlights can be applied to a previously defined ``Loci`` by: -```ts -plugin.managers.interactivity.lociHighlights.highlightOnly({ loci }); // loci: Loci -``` -Reset all highlights by: -```ts -plugin.managers.interactivity.clearHighlights(); -``` - - -### Select ``Loci`` - -Selected elements will appear with distinct visuals and, if applicable, the corresponding sequence positions will be -shown in the Sequence Viewer panel. Selections persist until removed, for example by clicking the background. A ``Loci`` -is selected by: -```ts -plugin.managers.interactivity.lociSelects.select({ loci }); // loci: Loci -``` - -Deselect a specific ``Loci`` by: -```ts -plugin.managers.interactivity.lociSelects.deselect({ loci }); // loci: Loci -``` -To deselect everything: -```ts -plugin.managers.interactivity.lociSelects.deselectAll(); -``` - - -### Focus ``Loci`` -The focus representation shows a ``Loci`` in ball-and-stick representation and, additionally, visualizes non-covalent -interactions between atoms of the ``Loci`` as well as interactions with surrounding residues (default: 5 Å). -```ts -plugin.managers.structure.focus.setFromLoci(loci); -``` -Extend an existing focus representation by: -```ts -plugin.managers.structure.focus.addFromLoci(loci); // loci: Loci -``` -Reset by: -```ts -plugin.managers.structure.focus.clear(); -``` - - -### Zoom ``Loci`` -A ``Loci`` can also be used to manipulate the camera. Zoom in by: -```ts -plugin.managers.camera.focusLoci(loci); // loci: Loci -``` - -Restore the default camera position by: -```ts -plugin.managers.camera.reset(); -``` - -### Turn off view resetting on new representations -A new representation via something like -```ts -.apply(StateTransforms.Representation.VolumeRepresentation3D, ...) -``` -can reset the view to make the whole representation visible. -When one wants to keep the view the same instead of having the rep reset the view, -keep the view constant by: -```ts -plugin.canvas3d?.setProps({ camera: { manualReset: true } }); -``` diff --git a/mkdocs-material b/mkdocs-material deleted file mode 160000 index 1e812c6..0000000 --- a/mkdocs-material +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1e812c61461189f563d841b921a2f054e641610d diff --git a/mkdocs.yml b/mkdocs.yml deleted file mode 100644 index 91e2748..0000000 --- a/mkdocs.yml +++ /dev/null @@ -1,50 +0,0 @@ -site_name: Mol* Documentation -theme: - name: null - custom_dir: mkdocs-material/material - - # 404 page - static_templates: - - 404.html - - # Necessary for search to work properly - include_search_page: false - search_index_only: true - - # Default values, taken from mkdocs_theme.yml - language: en - font: - text: Roboto - code: Roboto Mono - favicon: assets/favicon.png - icon: - logo: logo -markdown_extensions: - - pymdownx.highlight - - pymdownx.superfences - - pymdownx.arithmatex: - generic: true -# Scripts for rendering Latex equations (in addition to pymdownx.arithmatex): -extra_javascript: - - https://polyfill.io/v3/polyfill.min.js?features=es6 - - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js -nav: - - 'index.md' - - 'examples.md' - - 'plugin.md' - - 'data-state.md' - - 'viewer-state.md' - - 'selections.md' - - Transforms: - - 'transforms/custom-trajectory.md' - - Data Access Tools: - - 'data-access-tools/model-server.md' - - 'data-access-tools/volume-server.md' - - 'data-access-tools/plugin-state-server.md' - - 'data-access-tools/convert-to-bcif.md' - - 'data-access-tools/create-ccd-table.md' - - 'data-access-tools/extract-ccd-ions.md' - - Extensions: - - MolViewSpec: 'extensions/mvs/index.md' - - wwPDB StructConn: 'extensions/struct-conn.md' -repo_url: https://github.com/molstar/docs \ No newline at end of file