marrink-lab / vermouth-martinize

Describe and apply transformation on molecular structures and topologies
Apache License 2.0
89 stars 40 forks source link

Funny stuff with ifdef/ifndef #385

Open fgrunewald opened 2 years ago

fgrunewald commented 2 years ago
[ link ]
resname "DT|DG|DC|DA"
[ bonds ]
BB3  >BB1 1  0.35300 10000 {"group": "link"}
[ angles ]
BB2 BB3  >BB1  2  102.00000   150 {"group": "link"}
BB3 >BB1 >BB2  2  106.00000    75 {"group": "link"}
[ exclusions ]
BB2 >BB1
BB3 >BB2
[ dihedrals ]
#meta {"group": "B-DNA chiral dihedrals", "ifdef": "CHIRAL"}
BB2 BB3 >BB1 >BB2     2  110.00000     100     {"group": "link", "version": "1"}
BB3 >BB1 >BB2 >BB3    2  110.00000     100     {"group": "link", "version": "1"}
BB3 >BB1 >BB2 >BB3    2  110.00000     100     {"group": "link", "version": "1"}
#meta {"group": "Normal non-chiral dihedrals", "ifndef": "CHIRAL"}
BB2 BB3 >BB1 >BB2     1  180.00000     2     3 {"group": "link", "version": "2"}
BB3 >BB1 >BB2 >BB3    9   85.00000     2     2 {"group": "link", "version": "2"}
BB3 >BB1 >BB2 >BB3    9  160.00000     2     2 {"group": "link", "version": "2"}

This actually results in the error:

ValueError: An interaction cannot have both an "ifdef" and an "ifndef" meta attribute.

@pckroon any idea on this one?

pckroon commented 2 years ago

It seems to me that #meta tags are additive (unless the group is equal maybe?) This kind of behaviour is one of the reasons the file format and parser needs to be redone.

Tsjerk commented 2 years ago

The problem seems to be that the #meta adds to interactions on the block level. I think splitting this into two dihedral blocks will solve the issue. It does make sense to have #metas apply on the block level in the force field definition, so I think this isn't a real problem, but it does require documentation. @fgrunewald please check and close this issue if this appears correct.

fgrunewald commented 2 years ago

This could be the issue. But as long as it is neither documented nor changed, I'd leave the issue open. It also has already the parser tag which should make it easy to pull up once the parser is being redone.