-
Notifications
You must be signed in to change notification settings - Fork 35
Migrate validation to Protocol._validate in HybridTopologyProtocol #1740
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
base: main
Are you sure you want to change the base?
Conversation
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
No API break detected ✅ |
| if m.componentA not in alchemical_components["stateA"]: | ||
| raise ValueError( | ||
| f"Mapping componentA {m.componentA} not in alchemical components of stateA" | ||
| ) | ||
| if m.componentB not in alchemical_components["stateB"]: | ||
| raise ValueError( | ||
| f"Mapping componentB {m.componentB} not in alchemical components of stateB" | ||
| ) |
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.
Could maybe squash the repeated errors into a single loop?
| if m.componentA not in alchemical_components["stateA"]: | |
| raise ValueError( | |
| f"Mapping componentA {m.componentA} not in alchemical components of stateA" | |
| ) | |
| if m.componentB not in alchemical_components["stateB"]: | |
| raise ValueError( | |
| f"Mapping componentB {m.componentB} not in alchemical components of stateB" | |
| ) | |
| for label in ["A", "B"]: | |
| if getattr(m, f"component{label}") not in alchemical_components[f"state{label}"]: | |
| raise ValueError(f"Mapping component{label} {gatattr(m, f'component{label}') not in alchemical components of state{label}") | |
| * If an explicit charge correction is attempted and the | ||
| nonbonded method is not PME. | ||
| * If the absolute charge difference is greater than one | ||
| and an explicit charge correction is attempted. |
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.
| and an explicit charge correction is attempted. | |
| and an explicit charge correction is attempted. | |
| * If an explicit charge correction is attempted and there is no solvent present. |
| Raises | ||
| ------ | ||
| ValueError | ||
| * If the |
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.
Needs finishing
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.
Aaahh sorry I obviously gave up on the docs some point and never came back - thanks for pointing this out!
| * Mappings which involve element changes in core atoms | ||
| """ | ||
| # if a single mapping is provided, convert to list | ||
| if isinstance(mapping, ComponentMapping): |
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 is done for us in the default_validate method on the base class so we could skip it.
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.
Great to see this being used, left a couple of optional things you might consider changing otherwise LGTM!
hannahbaumann
left a comment
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.
Thanks @IAlibay , love the validate method! Just some small spelling things.
|
|
||
| if len(clashes) > 0: | ||
| errmsg = ( | ||
| "Found SmallMoleculeComponents are are isomorphic " |
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.
| "Found SmallMoleculeComponents are are isomorphic " | |
| "Found SmallMoleculeComponents that are isomorphic " |
| return | ||
|
|
||
| if solvent_component is None: | ||
| errmsg = "Cannot use eplicit charge correction without solvent" |
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.
| errmsg = "Cannot use eplicit charge correction without solvent" | |
| errmsg = "Cannot use explicit charge correction without solvent" |
| self._validate_endstates(stateA, stateB) | ||
|
|
||
| # Get alchemical components & validate them + mapping | ||
| # Valildate the mapping |
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.
| # Valildate the mapping | |
| # Validate the mapping |
|
|
||
| # Validate charge difference | ||
| # Note: validation depends on the mapping & solvent component checks | ||
| if stateA.contains(SolventComponent): |
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.
More a note to self, we'll have to see how to best do all these validations with the explicit solvent component.
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.
I think this is where we will need to make an explicit solvent component be a subclasses of both protein and solvent components
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.
I think this is where we will need to make an explicit solvent component be a subclasses of both protein and solvent components
Fixes #1739
Checklist
newsentry, or the changes are not user-facing.pre-commit.ci autofixbefore requesting review.Manual Tests: these are slow so don't need to be run every commit, only before merging and when relevant changes are made (generally at reviewer-discretion).
Developers certificate of origin