MDAnalysis / solvation-analysis

A comprehensive tool for analyzing liquid solvation structure.
https://solvation-analysis.readthedocs.io/en/latest/
GNU General Public License v3.0
46 stars 13 forks source link

No dimensions while using GROMACS trr or xtc file #62

Closed sli259 closed 2 years ago

sli259 commented 2 years ago

Hi, I am trying to use the trajectory file from GROMACS to do the solvation analysis. The run process give me this error. AttributeError: 'TRRReader' object has no attribute 'dimensions'

I did set the dimensions as suggested by the message, however I still have the same error... Any suggestion to make it work for the GROMACS trajectory file?

Thanks!

Here is the code I used:

import MDAnalysis as mda

data = "../traj/npt2.gro"
traj = "../traj/npt2.xtc"
dim = [80, 80, 80, 90, 90, 90]

u = mda.Universe(data, traj)
mda.transformations.set_dimensions(dim)

li_atoms = u.select_atoms('name Li')
FSI = u.select_atoms("resname FSI")
DEE = u.select_atoms("resname DEE")

from solvation_analysis.solution import Solution

solution = Solution(li_atoms, {'FSI':FSI, 'DEE':DEE})
solution.run()
orionarcher commented 2 years ago

Hi @sli259, thanks for raising an issue!

mda.transformations.set_dimensions(dim) will create a transformation, but it won't add it to your trajectory, to do that, you'll need to call u.trajectory.add_transformations. This code snippet should work:

u = mda.Universe(data, traj)
workflow = [mda.transformations.set_dimensions(dim)]
u.trajectory.add_transformations(workflow)

For more details, check out the MDAnalysis documentation on this topic: https://docs.mdanalysis.org/1.0.0/documentation_pages/trajectory_transformations.html

orionarcher commented 2 years ago

Hi @sli259, I am going to close this but please let me know if you have any more questions!