question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding frames to a trajectory from coordinates array

See original GitHub issue

Hello, 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: multi-model-struct 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:closed
  • Created 2 years ago
  • Comments:15 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
dsehnalcommented, Nov 5, 2021

Hi,

the way to approach this would be:

  • Create a transform that creates PluginStateObject.Molecule.Coordinates object from your trajectory data.
  • Look at AddTrajectory state action how to create a new trajectory from an existing model and additional “trajectory” (e.g. use the TrajectoryFromModelAndCoordinates transform).
  • Do whatever you want with the resulting trajectory (e.g. create a separate model for each frame).
  • Might also be worthwhile to delete the “default” representation of the original PDB model.
0reactions
ptourlascommented, Nov 12, 2021

Thanks a lot, will try to make something readable out of this issue and visit the docs repo with it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

6. Trajectory analysis — MDAnalysis Tutorial 3.0.0 ...
The standard way to assess each time step (or frame) in a trajectory is to iterate over the Universe.trajectory attribute (which is an...
Read more >
Trajectory analysis — Practical 15 - Beckstein Lab
Where the cursor points, there's you current coordinates, frame number, and time. Normally you will collect the data in a list or array,...
Read more >
mdtraj.Trajectory — MDTraj 1.6.2 documentation
Trajectory supports fancy indexing, so you can extract one or more frames from a Trajectory as a separate trajectory.
Read more >
Trajectory - ProDy - University of Pittsburgh
Add a file to the trajectory instance. Currently only DCD files are ... in the trajectory file. Shape of the coordinate set array...
Read more >
biotite.structure.io.xtc.XTCFile
Since trajectory files usually only contain atom coordinate information and no topology information, this method requires a template atom array or stack.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found