marrink-lab / vermouth-martinize

Describe and apply transformation on molecular structures and topologies
Apache License 2.0
95 stars 43 forks source link

Add option to generate log entries from .ff files #474

Closed pckroon closed 1 year ago

pckroon commented 1 year ago

This PR adds the option to have martinize2 generate log statements based on .ff files. Blocks, Modifications and Links get debug, info, warning, and error sections, in which each line will become a log statement with the appropriate level. This is still WIP, since I kind of want to be able to do e.g.

[ info ]
Created a disulfide bridge between residues {SC1['resid']} and {>SC1['resid']}.

but I'm not quite sure yet how painful that's going to be (shouldn't be too bad though, format will do the heavy lifting). Does require some bookkeeping .

Question, should each line in a section result in a separate log message, or should these be aggregated to a single entry?

pckroon commented 1 year ago

With the last commit the following should be possible. I gave it a quick test, but I probably missed some edge cases...

;; Cystein bridge
[ link ]
resname "CYS"
[ constraints ]
SC1 >SC1 1 0.24 {"comment": "Disulfide bridge"}
[ features ]
disulfide
[ info ]
Added a disulfide bridge between {SC1[chain]}-{SC1[resname]}{SC1[resid]} and {>SC1[chain]}-{>SC1[resname]}{>SC1[resid]}.

Ditto for Blocks and Modifications. During the formatting SC1 and >SC1 in the example above are replaced by the corresponding dictionaries with node attributes.

pckroon commented 1 year ago

Overall looks good to me. Have a look at the two small comments I made. One question that came to my mind. Would it be good/needed to have force-field wide log statements and warnings. Like for example "You choose Martini2, are you sure cuz it sucks for protein interactions?"

I played around with this, but I'm running into limitations of the SectionLineParser. So good idea, but no.

fgrunewald commented 1 year ago

@pckroon what is the status of this one?

pckroon commented 1 year ago

Ready as far as I'm concerned. The log statements at FF level we can leave for later I think.

fgrunewald commented 1 year ago

How about the test coverage? Do you care to fix it?

pckroon commented 1 year ago

Honestly not really. If this feature turns out to not work perfectly it's not too big a deal.

fgrunewald commented 1 year ago

@pckroon is there a way to line-break a warning ? Just using two lines scrambles the print output

pckroon commented 1 year ago

No, there isn't. Multiline statements are something for the parser overhaul as far as I'm concerned. For now just make long lines.

fgrunewald commented 1 year ago

@pckroon I'm in principle fine with this PR. Seems to work. Except I wonder if it is a good idea to print the log statements in the end or actually where the processor is called?

pckroon commented 1 year ago

Printing them in the end makes deduplication possible/much easier. Also, at the end they're more likely to be noticed I guess.

fgrunewald commented 1 year ago

@pckroon I'm fine with merging this. I want to adopt it to polypyl asap as well