-
Notifications
You must be signed in to change notification settings - Fork 92
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
Enumerate input molecule with tautomers #1780
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -811,22 +811,24 @@ def _assign_aromaticity_and_stereo_from_3d(self, offmol): | |||||
return offmol_w_stereo_and_aro | ||||||
|
||||||
def enumerate_protomers( | ||||||
self, molecule: "Molecule", max_states: int = 10 | ||||||
) -> List["Molecule"]: | ||||||
self, | ||||||
molecule: "Molecule", | ||||||
max_states: int = 10, | ||||||
) -> list["Molecule"]: | ||||||
""" | ||||||
Enumerate the formal charges of a molecule to generate different protomoers. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
molecule: openff.toolkit.topology.Molecule | ||||||
molecule: openff.toolkit.Molecule | ||||||
The molecule whose state we should enumerate | ||||||
|
||||||
max_states: int optional, default=10, | ||||||
The maximum number of protomer states to be returned. | ||||||
|
||||||
Returns | ||||||
------- | ||||||
molecules: List[openff.toolkit.topology.Molecule], | ||||||
molecules: list[openff.toolkit.Molecule], | ||||||
A list of the protomers of the input molecules not including the input. | ||||||
""" | ||||||
|
||||||
|
@@ -912,8 +914,10 @@ def enumerate_stereoisomers( | |||||
return molecules[:max_isomers] | ||||||
|
||||||
def enumerate_tautomers( | ||||||
self, molecule: "Molecule", max_states: int = 20 | ||||||
) -> List["Molecule"]: | ||||||
self, | ||||||
molecule: "Molecule", | ||||||
max_states: int = 20, | ||||||
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 think we could go bigger than 20 if we wanted! |
||||||
) -> list["Molecule"]: | ||||||
""" | ||||||
Enumerate the possible tautomers of the current molecule | ||||||
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.
Suggested change
|
||||||
|
||||||
|
@@ -927,8 +931,8 @@ def enumerate_tautomers( | |||||
|
||||||
Returns | ||||||
------- | ||||||
molecules: List[openff.toolkit.topology.Molecule] | ||||||
A list of openff.toolkit.topology.Molecule instances excluding the input molecule. | ||||||
molecules: list[openff.toolkit.Molecule] | ||||||
A list of openff.toolkit.Molecule instances excluding the input molecule. | ||||||
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.
Suggested change
|
||||||
""" | ||||||
from openeye import oequacpac | ||||||
|
||||||
|
@@ -945,16 +949,13 @@ def enumerate_tautomers( | |||||
tautomer_options.SetCarbonHybridization(False) | ||||||
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. - tautomer_options.SetMaxTautomersGenerated(max_states + 1)
+ tautomer_options.SetMaxTautomersGenerated(max_states) No longer need to generate an extra state so we can drop the input. |
||||||
|
||||||
for tautomer in oequacpac.OEEnumerateTautomers(oemol, tautomer_options): | ||||||
# remove the input tautomer from the output | ||||||
taut = self.from_openeye( | ||||||
tautomer, allow_undefined_stereo=True, _cls=molecule.__class__ | ||||||
) | ||||||
if taut != molecule: | ||||||
tautomers.append( | ||||||
self.from_openeye( | ||||||
tautomer, allow_undefined_stereo=True, _cls=molecule.__class__ | ||||||
) | ||||||
tautomers.append( | ||||||
self.from_openeye( | ||||||
tautomer, | ||||||
allow_undefined_stereo=True, | ||||||
_cls=molecule.__class__, | ||||||
) | ||||||
) | ||||||
|
||||||
return tautomers | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1339,23 +1339,25 @@ def enumerate_stereoisomers( | |||||
return molecules | ||||||
|
||||||
def enumerate_tautomers( | ||||||
self, molecule: "Molecule", max_states: int = 20 | ||||||
) -> List["Molecule"]: | ||||||
self, | ||||||
molecule: "Molecule", | ||||||
max_states: int = 20, | ||||||
) -> list["Molecule"]: | ||||||
""" | ||||||
Enumerate the possible tautomers of the current molecule. | ||||||
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.
Suggested change
|
||||||
|
||||||
Parameters | ||||||
---------- | ||||||
molecule: openff.toolkit.topology.Molecule | ||||||
molecule: openff.toolkit.Molecule | ||||||
The molecule whose state we should enumerate | ||||||
|
||||||
max_states: int optional, default=20 | ||||||
The maximum amount of molecules that should be returned | ||||||
|
||||||
Returns | ||||||
------- | ||||||
molecules: List[openff.toolkit.topology.Molecule] | ||||||
A list of openff.toolkit.topology.Molecule instances not including the input molecule. | ||||||
molecules: list[openff.toolkit.Molecule] | ||||||
A list of openff.toolkit.Molecule instances including the input molecule. | ||||||
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.
Suggested change
|
||||||
""" | ||||||
|
||||||
from rdkit import Chem | ||||||
|
@@ -1371,11 +1373,12 @@ def enumerate_tautomers( | |||||
molecules = [] | ||||||
for taut in tautomers: | ||||||
taut_hs = Chem.AddHs(taut) | ||||||
mol = self.from_smiles( | ||||||
Chem.MolToSmiles(taut_hs), allow_undefined_stereo=True | ||||||
molecules.append( | ||||||
self.from_smiles( | ||||||
Chem.MolToSmiles(taut_hs), | ||||||
allow_undefined_stereo=True, | ||||||
) | ||||||
) | ||||||
if mol != molecule: | ||||||
molecules.append(mol) | ||||||
|
||||||
return molecules[:max_states] | ||||||
|
||||||
|
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.