Adding frames to a trajectory from coordinates array
See original GitHub issueHello, Based on https://github.com/molstar/molstar/issues/90, I would like to add some extra info regarding @stefdoerr 's case. The frontend receives a PDB file from the backend which is loaded using:
async function createStructureFromRawData(filecontent, molname, filetype, structureKey) {
const raw_data = await viewer.plugin.builders.data.rawData({ data: filecontent, label: molname })
const trajectory = await viewer.plugin.builders.structure.parseTrajectory(raw_data, filetype);
// Apply default representations
await viewer.plugin.builders.structure.hierarchy.applyPreset(trajectory, 'default');
return trajectory
}
Once this is called, the frontend also receives an array of the form:
[frame1, frame2, ..., frameN]
with each entry being a list of the atomic coordinates in sequence, i.e.
[x1,y1,z1,x2,y2,z2,...,xK,yK,zK]
Ideally, we would like each one of the entries to be added as a new model for the given topology (if I’m using the term correctly here), like this:
I think that: https://github.com/molstar/molstar/blob/7f39cf0f37e66e35c8016620a8d753065d9b2978/src/mol-plugin-state/actions/structure.ts#L176 could be of use but I’m not experienced with how these functions can be accessed.
(In fact, how to apply state transformations to the viewer programmatically is another big question and I perhaps I could help with documenting this since I’m already trying to understand the whole “state tree” concept.)
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (14 by maintainers)
Hi,
the way to approach this would be:
PluginStateObject.Molecule.Coordinates
object from your trajectory data.AddTrajectory
state action how to create a new trajectory from an existing model and additional “trajectory” (e.g. use theTrajectoryFromModelAndCoordinates
transform).Thanks a lot, will try to make something readable out of this issue and visit the docs repo with it.