Skip to content

How to check if 2 SMILES are a pair of enantiomers? #7169

Answered by ptosco
LiuCMU asked this question in FAQ
Discussion options

You must be logged in to vote

@LiuCMU Converting both SMILES to their canonical form and then checking that both molecules are chiral and that all their parities are opposite should work.

from rdkit import Chem

def are_enantiomers(smi1, smi2):
    mol1 = Chem.MolFromSmiles(smi1)
    assert mol1
    mol2 = Chem.MolFromSmiles(smi2)
    assert mol2
    can_smi1 = Chem.MolToSmiles(mol1)
    can_smi2 = Chem.MolToSmiles(mol2)
    return ("@" in can_smi1 and "@" in can_smi2
        and can_smi1.replace(
            "@@", "__DOUBLE_AT__"
        ).replace("@", "@@").replace(
            "__DOUBLE_AT__", "@"
        ) == can_smi2)

mol4_1 = "C[C@@H](/C=C\C[C@H](Br)C)C(O)=O"
mol4_2 = "C[C@@H](C(O)=O)/C=C\C[C@H](C)Br"

are_enan…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@LiuCMU
Comment options

Answer selected by LiuCMU
Comment options

You must be logged in to vote
1 reply
@LiuCMU
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
FAQ
Labels
None yet
3 participants