avogadrolibs icon indicating copy to clipboard operation
avogadrolibs copied to clipboard

Import trajectories from PDB files

Open joerivan opened this issue 1 year ago • 8 comments

It could be a good add if Avogadro could import trajectories from PDB files. The old Avogadro had this feature, but it does not seem present/working in Avogadro 2.

Similar to loading a 'normal' PDB file, the feature should allow the user the drag and drop a PDB file into Avogadro, and Avogadro should read the PDB file, where each geometry that is separated by an ENDMDL[^1] should be imported as a separate frame.

Switching between the frames should then be possible (as normal) via the Animation Tool.

An alternative would be to import with a separate tool/menu. For example, adding an option to import trajectories inside of the Animation Tool (specific for PDB files). I believe that the first suggestion would be more user-friendly.

[^1]:In PDB files coordinates are read until either the file ends or the keyword ENDMDL is encountered. Using this, a PDB file can be used as a trajectory format. The different steps are then separated by an ENDMDL.

joerivan avatar Dec 12 '23 21:12 joerivan

Thanks for opening your first issue here! Please try to include example files and screenshots if possible. If you're looking for support, please post on our forum: https://discuss.avogadro.cc/

welcome[bot] avatar Dec 12 '23 21:12 welcome[bot]

This issue has been mentioned on Avogadro Discussion. There might be relevant details there:

https://discuss.avogadro.cc/t/import-trajectories-from-pdb-files/5113/1

avo-bot avatar Dec 12 '23 22:12 avo-bot

I'm going to mark this as "help wanted" and "good first issue" since I've got a few other things on my plate right now.

The code for this is in https://github.com/OpenChemistry/avogadrolibs/blob/bb080b5bfd45b8c197702d802888687450c6f5d5/avogadro/io/pdbformat.cpp#L59

An example of adding frames is in the XYZ code: https://github.com/OpenChemistry/avogadrolibs/blob/bb080b5bfd45b8c197702d802888687450c6f5d5/avogadro/io/xyzformat.cpp#L137

ghutchis avatar Dec 13 '23 01:12 ghutchis

Hey there @ghutchis , I was interested in working on this issue but had problem in figuring out how to set up the repository locally. Apart from forking and cloning, what next do I have to do?. Are there any docs which I can refer to?

vaibhav-1508 avatar Dec 19 '23 18:12 vaibhav-1508

The README points to https://two.avogadro.cc/install/build.html

ghutchis avatar Dec 19 '23 19:12 ghutchis

It could be a good add if Avogadro could import trajectories from PDB files. The old Avogadro had this feature, but it does not seem present/working in Avogadro 2.

Similar to loading a 'normal' PDB file, the feature should allow the user the drag and drop a PDB file into Avogadro, and Avogadro should read the PDB file, where each geometry that is separated by an ENDMDL1 should be imported as a separate frame.

Switching between the frames should then be possible (as normal) via the Animation Tool.

An alternative would be to import with a separate tool/menu. For example, adding an option to import trajectories inside of the Animation Tool (specific for PDB files). I believe that the first suggestion would be more user-friendly.

Footnotes

  1. In PDB files coordinates are read until either the file ends or the keyword ENDMDL is encountered. Using this, a PDB file can be used as a trajectory format. The different steps are then separated by an ENDMDL.

@joerivan Hi Sir, please assign me to work on this issue. I have already written the required code for this following issue, just need to find out the correct file in the repository and I'll raise a PR asap!

Himanshuu23 avatar Feb 11 '24 15:02 Himanshuu23

We generally don't "assign" issues except to mark that someone from the core development team is working on it.

If you want to find the correct files, you need to look at: https://github.com/OpenChemistry/avogadrolibs/blob/master/avogadro/io/pdbformat.cpp

An example of reading multiple coordinate sets can be found in xyzformat.cpp, e.g. https://github.com/OpenChemistry/avogadrolibs/blob/dfbd6f6bf9fefc4a13278a9c2fefd26f2dc1b98a/avogadro/io/xyzformat.cpp#L135

Basically, you push back each frame:

Array<Vector3> positions;
positions.reserve(numAtoms);
unsigned coordSet = 0;
mol.setCoordinate3d(positions, 0);

ghutchis avatar Feb 11 '24 18:02 ghutchis

Raised an PR for it.

Himanshuu23 avatar Mar 23 '24 13:03 Himanshuu23