Comments (4)
Hi Ismail,
if you want to change the parameters, you have to build the representation yourself.
You can start with this example https://github.com/molstar/molstar/blob/master/src/examples/basic-wrapper/index.ts#L52
Essentially you want something along these lines:
const data = await this.plugin.builders.data.download({ url });
const trajectory = await this.plugin.builders.structure.parseTrajectory(data, format);
const model = await this.plugin.builders.structure.createModel(trajectory);
const structure = await this.plugin.builders.structure.createStructure(model);
const components = {
polymer: await this.plugin.builders.structure.tryCreateComponentStatic(structure, 'polymer'),
ligand: await this.plugin.builders.structure.tryCreateComponentStatic(structure, 'ligand'),
water: await this.plugin.builders.structure.tryCreateComponentStatic(structure, 'water'),
};
const builder = this.plugin.builders.structure.representation;
const update = this.plugin.build();
if (components.polymer) builder.buildRepresentation(update, components.polymer, { type: 'gaussian-surface', typeParams: { alpha: 0.51 } }, { tag: 'polymer' });
if (components.ligand) builder.buildRepresentation(update, components.ligand, { type: 'ball-and-stick' }, { tag: 'ligand' });
if (components.water) builder.buildRepresentation(update, components.water, { type: 'ball-and-stick', typeParams: { alpha: 0.6 } }, { tag: 'water' });
await update.commit();
You can have a look at https://github.com/molstar/molstar/blob/master/src/mol-plugin-state/builder/structure/representation-preset.ts#L129 for how the code for the default preset looks like (the code above is a modification of that code, for example it would be required to show carbohydrates separately).
David
from molstar.
Yeah, just add { type: ..., color: 'uniform', colorParams: Color(0xFFFFF00) }
.
If you want to use the custom theme, you need to provide it's string id (available in the definition of the theme; and possibly use as any
if in typescript).
David
from molstar.
Hi David,
Thanks for the swift reply.
This looks like exactly what I needed.
And thank you for the exemplar code - this will make implementing this a lot easier 😃
Ismail Moghul
from molstar.
Hi David,
Once again thank you for all your help last time.
I have another very quick question.
I am trying to change the surface colour of the PDB file I am importing (e.g. to bright yellow).
Is it possible to pass a colour hex id (0xFFFF00
) directly to buildRepresentation()
?
Looking at the basic-wrapper example, I have tried using the new theme object created and passing this to the buildRepresentation()
; however, this has not worked:
import { StripedResidues } from './coloring';
...
if (components.polymer) builder.buildRepresentation(update, components.polymer, { type: 'gaussian-surface', typeParams: { alpha: 0.51 }, StripedResidues }, { tag: 'polymer' });
However, the colour surface file of the polymer is still randomly assigned (to green) and does not use the colour id in the StripedResidue object.
Many Thanks,
Ismail Moghul
from molstar.
Related Issues (20)
- Interactions between SDF entries and PDB entry HOT 2
- How to correctly parse scss file with webpack? HOT 2
- Getting bond information from selected atom HOT 2
- Given a protein file is there a way to visualize it? HOT 1
- How to set the custom residues label in the bottom right corner of the panel when hovering over them HOT 3
- A question about how to hide/show some part of component? HOT 2
- Suggestion/Request: public concatStructures method like NGL HOT 2
- Moving gl and friends to optional peer dependencies HOT 2
- Consider using markdown everywhere where we currently use `dangerouslySetInnerHTML`
- Inconsistent prototype for BinaryCIF decoder/encoder for IntegerPacking HOT 1
- Cannot read properties of undefined (reading 'entry') when apply rawData HOT 1
- Export Models fails on BCIF from ModelServer HOT 5
- Inter-structure selection of residues, atoms and ligands within 5 Angstroms HOT 1
- Toggle selection radius in "Manipulate Selection" menu HOT 1
- failed yarn build with molstar 4.0.0 HOT 5
- Problem when reading saved state files HOT 4
- Adding a Volume and representation resets the view to show the whole rep HOT 2
- Idiomatic way to color specific residues? HOT 3
- Mostar.org front page interactive examples - several fail... HOT 2
- How to run examples? (2) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from molstar.