OpenChemistry / avogadrolibs

Avogadro libraries provide 3D rendering, visualization, analysis and data processing useful in computational chemistry, molecular modeling, bioinformatics, materials science, and related areas.
https://two.avogadro.cc/
BSD 3-Clause "New" or "Revised" License
450 stars 172 forks source link

Import trajectories from PDB files #1524

Open joerivan opened 10 months ago

joerivan commented 10 months ago

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.

welcome[bot] commented 10 months ago

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/

avo-bot commented 10 months ago

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

ghutchis commented 10 months ago

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

vaibhav-1508 commented 10 months ago

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?

ghutchis commented 10 months ago

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

Himanshuu23 commented 8 months ago

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!

ghutchis commented 8 months ago

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);
Himanshuu23 commented 7 months ago

Raised an PR for it.