Comments (4)
Thanks for your contribution. I think it's fine to export things we need from the library given that NGL is quite monolithic and not amenable to tree shaking.
Regarding the parser, I've used in past projects the ParserRegistry
object that is exported from NGL to get some parsers in my code and even redefine some methods via their prototype.
const pdbParser = ParserRegistry.get('pdb')
pdbParser.prototype._beforeParse = // ... overriding code goes there
What is the use case for exporting the NetworkStreamer? Is it to override some of its methods?
from ngl.
Thanks for the answer, I didn't know about the possibility to use the ParserRegistry, but it should solve the problem,
Yes indeed, it is to overwrite a method (see example). The main reason for this is that the state and api queries are conveniently managed via React/Redux.
This makes it very easy to integrate the viewer into the normal flow and let the react/redux handel all the data/api calls updates caching etc...
// Use Structure data from the state
const compound3DStructure = useAppSelector(getStructure3D);
const createNetworkStreamer = (result: string) => {
const networkInputStream = new NetworkStreamer("custom", {
compressed: false,
binary: false,
json: false,
xml: false,
});
networkInputStream._read = () => {
return new Promise((resolve) => {
return resolve(result);
});
};
return networkInputStream;
};
// State result can be directly used here
const targetInputStream = createNetworkStreamer(compound3DStructure.structure);
from ngl.
If I understand this correctly, the NetworkSreamer is redefined to bypass the network transfer and directly use a known file content instead.
What can be done instead is to pass a Blob containing the file content as the first argument of the stage.loadFile
method.
Something like
const compound3DStructure = useAppSelector(getStructure3D);
const blob = new Blob([compound3DStructure.structure], {type: 'text/plain'});
stage.loadFile(blob, {ext: 'pdb'}).then((component: StructureComponent) => {
// rest of the code goes there
})
from ngl.
Thank you I think we can close this.
I just described a simple case to show why I would like to override certain methods, of course there are some ways to have a workaround but that is not directly what I had in mind.
I will do the customization locally, I think that is more effective. Thanks again for your time
from ngl.
Related Issues (20)
- dispose() method leaves part of the old representation when changing model HOT 2
- Incorrect behavior when changing opacity for a separate pocket HOT 3
- Should threejs be changed to a peer dependency? HOT 2
- change color of specific residue HOT 2
- getAtomSetWithinSelection and getAtomSetWithinGroup in several files HOT 4
- info in tooltip HOT 2
- Mass in .pdb files HOT 2
- Focus camera on selection
- Why is the effect after superposition not as good as before superposition HOT 1
- Export .pdb file HOT 2
- Question: How to save and restore transformation?
- Funnel like shape
- Multi-touch zoom with multiple NGL instances
- Show connections in two difference files HOT 4
- Hiding non-polar hydrogens HOT 1
- MeasureRepresentation between non-atoms HOT 2
- displaying hydrogens as ligands HOT 1
- Select the entire molecule by clicking on its atom HOT 1
- Regressions
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 ngl.