Openff-toolkit: Implement ForceField.to_file and to_string

Created on 24 Apr 2019  路  7Comments  路  Source: openforcefield/openff-toolkit

We should add FF I/O methods, so that users don't have to deal with converting FF's to dicts (which we're removing from the public API).

I propose
ForceField.to_file(filename, format, return_cosmetic_attributes=False)
and
ForceField.to_string(format, return_cosmetic_attributes=False)

(Discussion migrated from #278 )

api extension medium high

Most helpful comment

Another option that maybe I'd like more could be discard_cosmetic_attributes (with inverted default values), but I'll be happy with any choice here.

All 7 comments

Comment from @jchodera
https://github.com/openforcefield/openforcefield/issues/278#issuecomment-486342940

We should definitely add this, but we should discuss this in a separate issue.

Also, do you mean retain_cosmetic_attributes instead of return_cosmetic_attributes?
And perhaps we would want to retain these by default unless instructed to strip them out?

Since we're looking at the output stage, I'd prefer return_cosmetic_attributes. The choice for whether to permit cosmetic attributes during input (FF initialization) is made here, with the keyword permit_cosmetic_attributes.

And actually, the permit_cosmetic_attributes keyword should be exposed to the top-level FF __init__ as well.

The problem with return is that .to_file() is a function that doesn't return anything.

Good point. How about output_cosmetic_attributes?

Another option that maybe I'd like more could be discard_cosmetic_attributes (with inverted default values), but I'll be happy with any choice here.

I like that idea, @andrrizzi. Attaching this to our 0.3.0 milestone.

Closed by #291

Was this page helpful?
0 / 5 - 0 ratings