-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add version attribute to force fields #298
Add version attribute to force fields #298
Conversation
|
I should be able to rework it to handle multiple files but I also think this might be a feature we want to drop at some point. |
Codecov Report
@@ Coverage Diff @@
## master #298 +/- ##
=========================================
+ Coverage 86.57% 86.9% +0.32%
=========================================
Files 14 14
Lines 1222 1252 +30
=========================================
+ Hits 1058 1088 +30
Misses 164 164 |
I'm happy with where this is at now. If this approach is ok, I will duplicate this functionality to support a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a warning if there is no version? That way people can see that they should add a version if it is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from adding in a warning about the version or name, looks good to me!
root = tree.getroot() | ||
try: | ||
return root.attrib['version'] | ||
except KeyError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going off of Mike's comment about raising a warning, this seems like the place where that would go.
except KeyError: | |
except KeyError: | |
warn.Warn("version warning message here") | |
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
Another thing we could add is an attribute to the Forcefield
class which gives the path from which the forcefield was loaded. This wouldn't be saved in the forcefield xml, but is only an attribute. This might be a dumb idea, since we might have issues comparing two of the same forcefield loaded from different paths.
PR Summary:
Fixes #187, would be useful in #290
version
as an attribute of theForceField
element in the XML schemaversion
as an attribute to theForcefield
classversion
s are equalThis is not done elegantly right now; 99% of the XML loading is done by OpenMM, so I had to do this after the fact and only dealing with the case of passing a single XML, which is all I believe we do right now. I'm not sure what the target for this PR should be, but I think we should soon have a bigger discussion about how we want to handle multiple XML files. The OpenMM use case is basically
Forcefield('protein_model.xml', 'water_model.xml')
, i.e. there is a clean interface between constituents and not any expected overlap between the two. This doesn't cleanly map on to our use cases, I don't think. Related to #297 #262 #149If this seems reasonable I can do the same for names (#153), here or in another PR. Requesting a few specific reviewers since I have discussed this with many people over the past year or two (but only gotten to it now 🤕)
PR Checklist