Becksteinlab / GromacsWrapper

GromacsWrapper wraps system calls to GROMACS tools into thin Python classes (GROMACS 4.6.5 - 2024 supported).
https://gromacswrapper.readthedocs.org
GNU General Public License v3.0
169 stars 53 forks source link

angle parameters are not being read from topology file #261

Closed brgstfzj closed 10 months ago

brgstfzj commented 11 months ago

I have a problem when I want to read the topology file to work with the angle values.

when reading a topology file and trying to access the angle values k_theta and theta_0, I run into an issue.

import gromacs as gmx
topol = gmx.fileformats.top.TOP("topol.top")
topol.molecules[0].angles[0].gromacs

the parameters of the angles (ktheta and theta0) are not being read from the line. (it returns None for both) when changing the section name in the .top file from "angles" to "angletypes", it works.

this behaviour seems to be by design (see gromacs/fileformats/top.py line 474-526). for "angletypes" the parameters are read from the lines but for "angles" they are not...

(and sorry for being nit-picky, but the names of the parameters in your library for these two values are 'ktetha' and 'tetha0'. is this a typo? I think the name of the greek letter is "theta" in both cases.)

Thanks in advance!

orbeckst commented 11 months ago

That sounds like a bug. At a minimum, the typos could be fixed.

I haven't been using any of the TOP/ITP code in years and I think today there are other tools available (MDAnalysis has a ITP parser, ParmED can probably do it, possibly gromologist #218 ). If you have an idea how to fix the problem please submit a pull request. Ping me as @orbeckst so that I get a notification.

Please note that GromacsWrapper is an old package and maintenance is minimal — its core functionality is still good (running gromacs from Python scripts) but the "other stuff" like reading TOP files has not really kept up (and if anything I am considering removing it unless people contribute to maintenance).

orbeckst commented 11 months ago

@jandom you might have written the TOP/ITP code. Just in case you have any recollection of what you did there, I am pinging you ;-).

brgstfzj commented 10 months ago

thanks for the info!

unfortunately your tool is the only one, that does not alter the parameters in any way when reading the file. The other tools like parmed an the itp parser from MDAnalysis perform somewhat of a calculation with it, that I would have to reverse to get the parameters in the .top file. so, please don't remove it :D

jandom commented 10 months ago

hahah, interesting – I'd be happy to give this a look over the weeknd. @brgstfzj thank you for reporting – are you under some pressing timeline to have this fixed?

jandom commented 10 months ago

@brgstfzj do you have an example input file to reproduce the problem? The topol.top you mentioned in your initial ticket. And your original observation is correct, the parameters are not read-in for angles.

jandom commented 10 months ago

Okay, here is an initial PR to resolve this – doing some good old test-driven development (TDD) to get this under control

https://github.com/Becksteinlab/GromacsWrapper/pull/264

brgstfzj commented 10 months ago

example.txt here's a file :)

orbeckst commented 10 months ago

Fixed in PR #264

jandom commented 10 months ago

@brgstfzj thank you for reporting this error – as indicated above it should be now fixed. You should be able to install this repos 'develop' branch to consume the fixed code.

In terms of limitations: this only fixes the reader code, not the writer code, depending on your use case this may or may not be a problem.