How can I select certain model to use its .positions and elemenets!

The functionality of OpenMM will (eventually) include everything that one would need to run modern molecular simulation.
POST REPLY
User avatar
Elsaid Mohamed
Posts: 26
Joined: Tue Jan 04, 2022 2:35 am

How can I select certain model to use its .positions and elemenets!

Post by Elsaid Mohamed » Tue Feb 28, 2023 8:49 am

Hi,
I got an output file from simulation of pdb file.
The output.pdb contains 20 models.
I want to be able to loop over positions and elements for every model. How can select certain model?

User avatar
Peter Eastman
Posts: 2593
Joined: Thu Aug 09, 2007 1:25 pm

Re: How can I select certain model to use its .positions and elemenets!

Post by Peter Eastman » Tue Feb 28, 2023 9:49 am

Use getPositions() to get the coordinates for a particular model. There's only a single Topology, because the PDB spec requires all models to have the same atoms.

User avatar
Elsaid Mohamed
Posts: 26
Joined: Tue Jan 04, 2022 2:35 am

Re: How can I select certain model to use its .positions and elemenets!

Post by Elsaid Mohamed » Tue Feb 28, 2023 3:12 pm

This means that I have to cut the output files to many files every file contains positions for every model?
By the way I have used pandas, and it counts number 10 and more or -10 and less as positive whatever their signs.

User avatar
Peter Eastman
Posts: 2593
Joined: Thu Aug 09, 2007 1:25 pm

Re: How can I select certain model to use its .positions and elemenets!

Post by Peter Eastman » Tue Feb 28, 2023 4:09 pm

This means that I have to cut the output files to many files every file contains positions for every model?
I don't understand what you mean. You don't need to repeat the same model in multiple files. But all the models in a single file have to have the same set of atoms. That's a requirement of the PDB format. The spec states, "each model should have the exact same atoms (hydrogen and heavy atoms), sequence and chemistry."
By the way I have used pandas, and it counts number 10 and more or -10 and less as positive whatever their signs.
I don't understand what you're talking about. What does pandas have to do with OpenMM?

User avatar
Elsaid Mohamed
Posts: 26
Joined: Tue Jan 04, 2022 2:35 am

Re: How can I select certain model to use its .positions and elemenets!

Post by Elsaid Mohamed » Tue Feb 28, 2023 5:44 pm

Highlighting of the positions of atoms in each model is a goal of my project.
Say I have 20 models(same atoms, but distributed differently). I think I have to cut my output.pdb into 20 modelxs.pdb then get every model then get its coordinate like:

Code: Select all

X = [float(coord[0]/nanometer) for coord in modelxpdb.positions]
I have used all output.pdb to produce one dataframe in one script by "Pandas" but I found mistakes in the results.

User avatar
Peter Eastman
Posts: 2593
Joined: Thu Aug 09, 2007 1:25 pm

Re: How can I select certain model to use its .positions and elemenets!

Post by Peter Eastman » Tue Feb 28, 2023 6:16 pm

As long as they all have identical atoms, it's fine for them to be a single file. To get the coordinates of the i'th model, call pdb.getPositions(frame=i).

User avatar
Elsaid Mohamed
Posts: 26
Joined: Tue Jan 04, 2022 2:35 am

Re: How can I select certain model to use its .positions and elemenets!

Post by Elsaid Mohamed » Wed Mar 01, 2023 2:32 pm

Thank you, I got the answer for my question.
I think it is possible to meet some output.pdb, its frames have different atoms or elements............?
How can we define them like position

Code: Select all

pdb.getPositions(frame=i-1)
!

User avatar
Peter Eastman
Posts: 2593
Joined: Thu Aug 09, 2007 1:25 pm

Re: How can I select certain model to use its .positions and elemenets!

Post by Peter Eastman » Wed Mar 01, 2023 2:40 pm

No, that can never happen. Any file with different atoms in different models would violate the spec. And there are a lot of records that only appear once per file, not once per model: CONECT, CRYST1, SEQRES, etc. It would be impossible to specify different sequences, bonds, etc. for the different models.

POST REPLY