r/comp_chem 1d ago

Metadynamics extension for the ASE Python package

Hello everyone!

I am a postdoctoral student in Hungary and did my PhD in bioinformatics/cheminformatics, namely (mostly) in molecular dynamics of proteins. Around this time I read some articles about metadynamics as a tool to explore the free energy surface of certain processes, including small ligand binding to proteins, conformational changes or peptide-peptide association, etc... This kind of approach also gave me insights in statistical thermodynamics, while also keeping the fun-factor high and staying intuitive. I did not start to apply it until recently however, which makes me a novice in setting the right parameters, collective variables, for the right processes. I try to read research papers in this topic, but to challenge myself, I also wanted to make something new.

I started using the ASE/RDKit/OpenFF combo recently for the extraction of offxml parametrizations to standard GROMACS top/itp files. While doing this, I noticed that (afaik) there are no metadynamics extensions for ASE besides PLUMED. Since I am also somewhat familiar with PyTorch (and not really familiar with PLUMED), I figured I should create a package that uses PyTorch's autodiff modality for the implementation of metadynamics in ASE. So I created MePTASE (Metadynamics with PyTorch in the Atomic Simulation Environment), a small, still under development Python package, available from PyPI using pip install meptase[tblite] or pip install meptase[mace] (depending on the "force field" you want to use). You can use it within Python or from the CLI using JSON config files. I would appreciate any feedback you guys can give me, either regarding code quality, ease of use, possible extensions or anything else. I am especially proud of the CLI/JSON run option, which allows users to run simulations without writing Python code. You can also run well tempered metadynamics, but I have to test this feature more thoroughly.

Here is my repo: https://github.com/fazekaszs/meptase/tree/master

I know that there is some hate for AI assisted coding in this community. I love coding, so about 90%-95% of the codebase is written only by me. For the remaining part, I used OpenCode, mainly for some very trivial code snippets, to discuss optimal architectural choices for my code or to write documentation. Thank you for your observations in forward!

12 Upvotes

4 comments sorted by

3

u/LItzaV 1d ago

404 error in the GitHub repo

1

u/fazekaszs 1d ago

Thank you for noticing! I forgot to set the visibility to public. Rookie mistake.

2

u/shuanghan6848 1d ago

How does your code differ from PySages which also supports ASE calculator?

1

u/fazekaszs 21h ago

Hey, thank you for the comment! I was a bit naive to think that this is a low hanging fruit. I haven't met with PySages before, but from a quick glance at it, it is indeed very similar, just JAX based. It seems nice, comprehensive, definitely more advanced than MePTASE and supports more platforms. Maybe the only thing I would mention as an advantage of MePTASE is the CLI/JSON interface. For quick and dirty runs you can just specify the SMILES of a molecule, CVs, metadynamics kernels, run and IO parameters in a JSON file, and then start the run from that using python -m meptase -in my_json_config.json.

Additionally, while classical metadynamics places Gaussian kernels along the trajectory, MePTASE can place other kernel types too, such as von Mises kernels for dihedral angles or beta kernels for three point angles. This is a curiosity rather than a really useful feature for the user side, but it was fun to implement from the development side.