-
Notifications
You must be signed in to change notification settings - Fork 9
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
[WIP] Fe setup structure remodelling #346
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This code is part of OpenFE and is licensed under the MIT license. | ||
# For details, see https://github.com/OpenFreeEnergy/openfe | ||
|
||
import abc | ||
from typing import Iterable | ||
from .. import AlchemicalNetwork | ||
|
||
|
||
class AlchemicalNetworkPlanner(abc.ABC): | ||
""" | ||
this abstract class defines the interface for the alchemical Network Planners. | ||
""" | ||
|
||
@abc.abstractmethod | ||
def __call__(self, *args, **kwargs) -> AlchemicalNetwork: | ||
raise NotImplementedError() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This code is part of OpenFE and is licensed under the MIT license. | ||
# For details, see https://github.com/OpenFreeEnergy/openfe | ||
import abc | ||
from enum import Enum | ||
|
||
from typing import Iterable | ||
from gufe import ChemicalSystem | ||
|
||
# Todo: connect to protocols - use this for labels? | ||
|
||
class RFEComponentLabels(str, Enum): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs more discusison, I don't remember this being in the plans for updating things, definitely using |
||
PROTEIN = "protein" | ||
LIGAND = "ligand" | ||
SOLVENT = "solvent" | ||
COFACTOR = "cofactor" | ||
|
||
|
||
class AbstractChemicalSystemGenerator(abc.ABC): | ||
""" | ||
this abstract class defines the interface for the chemical system generators. | ||
""" | ||
|
||
@abc.abstractmethod | ||
def __call__(self, *args, **kwargs) -> Iterable[ChemicalSystem]: | ||
raise NotImplementedError() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
from collections.abc import Iterator | ||
import gufe | ||
|
||
from ..tokenization import GufeTokenizable | ||
from gufe.tokenization import GufeTokenizable | ||
from .atom_mapping import AtomMapping | ||
|
||
|
||
|
@@ -27,4 +27,5 @@ def suggest_mappings(self, | |
Suggests zero or more :class:`.AtomMapping` objects, which are possible | ||
atom mappings between two :class:`.Component` objects. | ||
""" | ||
... | ||
raise NotImplementedError("This function was not implemented.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this (...) is a pattern we use quite widely for our abcs? |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
|
||
import gufe | ||
from .componentmapping import ComponentMapping | ||
from gufe.setup.network_planning.component_mapping import ComponentMapping | ||
|
||
|
||
class AtomMapping(ComponentMapping, abc.ABC): | ||
|
@@ -37,22 +37,23 @@ def componentA_to_componentB(self) -> Mapping[int, int]: | |
entity in the other component (e.g. the atom disappears), therefore | ||
resulting in a KeyError on query | ||
""" | ||
... | ||
raise NotImplementedError("This function was not implemented.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above |
||
|
||
@property | ||
@abc.abstractmethod | ||
def componentB_to_componentA(self) -> Mapping[int, int]: | ||
"""Similar to A to B, but reversed.""" | ||
... | ||
raise NotImplementedError("This function was not implemented.") | ||
|
||
@property | ||
@abc.abstractmethod | ||
def componentA_unique(self) -> Iterable[int]: | ||
"""Indices of atoms in component A that aren't mappable to B""" | ||
... | ||
raise NotImplementedError("This function was not implemented.") | ||
|
||
@property | ||
@abc.abstractmethod | ||
def componentB_unique(self) -> Iterable[int]: | ||
"""Indices of atoms in component B that aren't mappable to A""" | ||
... | ||
raise NotImplementedError("This function was not implemented.") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This code is part of kartograf and is licensed under the MIT license. | ||
# For details, see https://github.com/OpenFreeEnergy/gufe | ||
|
||
import abc | ||
from ....tokenization import GufeTokenizable | ||
|
||
from .atom_mapping import AtomMapping | ||
|
||
|
||
class AtomMappingScorer(GufeTokenizable): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is in line with what we discussed, so this feature I think it ok to include. |
||
"""A generic class for scoring Atom mappings. | ||
this class can be used for example to build graph algorithm based networks. | ||
|
||
Implementations of this class can require an arbitrary and non-standardised | ||
number of input arguments to create. | ||
|
||
Implementations of this class provide the :meth:`.get_score` method | ||
|
||
""" | ||
|
||
def __call__(self, mapping: AtomMapping) -> float: | ||
return self.get_score(mapping) | ||
|
||
@abc.abstractmethod | ||
def get_score(self, mapping: AtomMapping) -> float: | ||
""" calculate the score for an :class:`.AtomMapping` | ||
the scoring function returns a value between 0 and 1. | ||
a value close to 1.0 indicates a small change - good score, a score close to zero indicates a large cost/change - bad score. | ||
|
||
Parameters | ||
---------- | ||
mapping: AtomMapping | ||
the mapping to be scored | ||
args | ||
kwargs | ||
|
||
Returns | ||
------- | ||
float | ||
a value between [0,1] where zero is a very bad score and one a very good one. | ||
|
||
""" | ||
raise NotImplementedError("This function was not implemented.") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This code is part of gufe and is licensed under the MIT license. | ||
# For details, see https://github.com/OpenFreeEnergy/gufe | ||
import abc | ||
from collections.abc import Iterator | ||
import gufe | ||
|
||
from gufe.tokenization import GufeTokenizable | ||
from .component_mapping import ComponentMapping | ||
|
||
|
||
class ComponentMapper(GufeTokenizable): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also in line with what was discussed. |
||
"""A class for manufacturing mappings | ||
|
||
Implementations of this class can require an arbitrary and non-standardised | ||
number of input arguments to create. | ||
|
||
Implementations of this class provide the :meth:`.suggest_mappings` method | ||
""" | ||
|
||
@abc.abstractmethod | ||
def suggest_mappings(self, | ||
A: gufe.Component, | ||
B: gufe.Component | ||
) -> Iterator[ComponentMapping]: | ||
"""Suggests possible mappings between two Components | ||
|
||
Suggests zero or more :class:`.AtomMapping` objects, which are possible | ||
atom mappings between two :class:`.Component` objects. | ||
""" | ||
raise NotImplementedError("This function was not implemented.") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This code is part of kartograf and is licensed under the MIT license. | ||
# For details, see https://github.com/OpenFreeEnergy/gufe | ||
|
||
import abc | ||
from gufe.tokenization import GufeTokenizable | ||
|
||
from .component_mapping import ComponentMapping | ||
|
||
class ComponentMappingScorer(GufeTokenizable): | ||
"""A generic class for scoring Atom mappings. | ||
this class can be used for example to build graph algorithm based networks. | ||
Implementations of this class can require an arbitrary and non-standardised | ||
number of input arguments to create. | ||
Implementations of this class provide the :meth:`.get_score` method | ||
""" | ||
|
||
def __call__(self, mapping: ComponentMapping) -> float: | ||
return self.get_score(mapping) | ||
|
||
@abc.abstractmethod | ||
def get_score(self, mapping: ComponentMapping) -> float: | ||
""" calculate the score for an :class:`.AtomMapping` | ||
the scoring function returns a value between 0 and 1. | ||
a value close to 1.0 indicates a small change, a score close to zero indicates a large cost/change. | ||
Parameters | ||
---------- | ||
mapping: AtomMapping | ||
the mapping to be scored | ||
args | ||
kwargs | ||
Returns | ||
------- | ||
float | ||
a value between [0,1] where zero is a very bad score and one a very good one. | ||
""" | ||
raise NotImplementedError("This function was not implemented.") |
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.
We can't move all these imports, this will break the API