Page 1 of 1

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

Posted: Tue Feb 28, 2023 8:49 am
by elsaid
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?

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

Posted: Tue Feb 28, 2023 9:49 am
by peastman
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.

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

Posted: Tue Feb 28, 2023 3:12 pm
by elsaid
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.

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

Posted: Tue Feb 28, 2023 4:09 pm
by peastman
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?

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

Posted: Tue Feb 28, 2023 5:44 pm
by elsaid
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.

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

Posted: Tue Feb 28, 2023 6:16 pm
by peastman
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).

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

Posted: Wed Mar 01, 2023 2:32 pm
by elsaid
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)
!

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

Posted: Wed Mar 01, 2023 2:40 pm
by peastman
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.