Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to load LAMMPS data file with chemfiles.py #45

Open
Roy-Kid opened this issue Jan 8, 2023 · 1 comment
Open

How to load LAMMPS data file with chemfiles.py #45

Roy-Kid opened this issue Jan 8, 2023 · 1 comment

Comments

@Roy-Kid
Copy link

Roy-Kid commented Jan 8, 2023

I use python to load the chemfiles/tests-data, for example lammps-data/solvated.lmp. But it raises an error that ChemfilesError: can not find a format associated with the '.lmp' extension. In the supported formats page, the extension of lammps data is false. Could you please tell me how to load lammps data? I want to extract topology info.

@Luthaf
Copy link
Member

Luthaf commented Jan 9, 2023

Since there is no standard for extension for LAMMPS data files, you'll need to specify the format explicitly when opening the file:

from chemfiles import Trajectory

trajectory = Trajectory("lammps-data/solvated.lmp", "r", format="LAMMPS Data")
frame = trajectory.read()

# depending on what's inside the data file, you might want to guess the bonds using a distance-based algorithm
# frame.guess_bonds()

topology = frame.topology

(you can always specify a format, and it will override the guess based on file extension, for example Trajectory("solvated.mol", "r", format="XYZ") will try to read the file as an XYZ file)

@Luthaf Luthaf transferred this issue from chemfiles/chemfiles Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants