Chemfiles is a modern and high-quality library for reading and writing
trajectory files created by computational chemistry simulations programs. To help you access information (atomic positions, velocities, names, topology, etc.) about these files, Chemfiles provides an interface that is
- unified: the same code will work with all supported formats;
- simple: the interface is easy to use and extensively documented.
You can use Chemfiles to conduct post-processing analysis and extract physical
information about the systems you're simulating, to convert files from one
format to another, or to write trajectories with your own simulation software.
This repository contains the core of the Chemfiles library — a programmer
interface written in C++11, with a C99 interface. If you want a ready-to-use
programs for trajectory analysis, use cfiles.
You can also use Chemfiles from other languages: Python 2&3,
Fortran, Rust,
and Julia.
We created Chemfiles to be able to write analysis algorithms once and use them
with all the existing trajectory formats in
cfiles; and to provide input/output
capacities in two molecular simulation engines. You might want to use it too, if
any of these apply to your use case:
There are other libraries
doing the roughly the same job as Chemfiles, have a look at them if Chemfiles is
not for you. Here we also say why we could not use them instead of creating a
new library.
Chemfiles is free and open source. Your contributions are
always welcome!
If you have questions or suggestions, or need help, please open an [issue] or join us on our [Gitter] chat room.
If you are using Chemfiles in a published scientific study, please cite us using the following DOI: https://doi.org/10.5281/zenodo.800663.
Chemfiles can read and write files in the following formats:
- XYZ;
- PDB;
- Amber NetCDF
- LAMMPS data files;
- Tinker XYZ files (.arc files);
- BIOVIA SDF files;
Chemfiles can also read but not (yet) write files in the following formats:
- TNG;
- LAMMPS trajectory;
- GROMACS formats: .gro; .xtc; .trj; .trr;
- CHARMM DCD files;
- TRIPOS mol2 files;
- Molden files;
- MacroMolecular Transmission Format (MMTF) files;
See the issue list
for planned formats. If you need another format, open a new issue with a link to
the format definition, or — even better — write the code and
contribute it!
Here, we'll help you get started with the C++ and C interface. If you want to
use Chemfiles with another language, please refer to the corresponding
documentation.
We provide compiled packages of the latest Chemfiles release for Linux
distributions. You can use your package manager to download them
here.
We also provide conda packages in the conda-forge
community channel for Linux
and OS X. This package provides the C++, C and Python interfaces. Install the conda package by running:
conda install -c conda-forge chemfiles
Find more information about packages in the documentation.
You will need cmake and a C++11 compiler.
git clone https://github.com/chemfiles/chemfiles
cd chemfiles
mkdir build
cd build
cmake ..
make
make install
This is what the interface looks like in C++:
// C++ version
#include <iostream>
#include "chemfiles.hpp"
int main() {
chemfiles::Trajectory trajectory("filename.xyz");
auto frame = trajectory.read();
std::cout << "There are " << frame.natoms() << " atoms in the frame" << std::endl;
auto positions = frame.positions();
// Do awesome science with the positions here !
}
Guillaume Fraux created and maintains Chemfiles, which is distributed under the
3 clauses BSD license. By contributing to Chemfiles, you agree to
distribute your contributions under the same license.
The AUTHORS file lists all contributors to Chemfiles. Many thanks to
all of them!