Open ijpulidos opened 10 months ago
@ijpulidos yeah having ChemicalSystem.get_components_of_type(type: Component) -> list[Component]
would work fine. Since the ChemicalSystem is just a dict[str, Component
all this method would do is [c for c in cs.components.values() if isinstance(c, type)]
but I guess it's a handy.
Yes, I think it could be something that gufe
could provide, and the complexity shouldn't be that hard, there might be a need to make some logic to make sure we are not returning a component more than once. I think since these are GufeTokenizable
we should be able to use set operations for this, correct?
Possibly related to #144! Thanks @ijpulidos!
In the current implemented protocols that use
gufe
objects foralchemiscale
, we find that we need ways to extract components from theChemicalSystem
. For example as in https://github.com/OpenFreeEnergy/openfe/blob/2af8dcda2921ccfa131456bb291453ca3c487dbb/openfe/protocols/openmm_utils/system_validation.py#L139This raises the question of whether this utility function/method should be part of the
ChemicalSystem
object itself. It seems like a good candidate of a commonly used functionality thatgufe
could provide, and if the inner structure of how theChemicalSystem
object changes protocols don't have to keep track and adapt when this happens.I think it could be desirable to have something like
chemical_system.get_components(type=SomeComponentType)
. I'm raising this question here for further discussion.