Skip to content

Find zwitterions #4900

Answered by greglandrum
ldamore asked this question in Q&A
Jan 18, 2022 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Sure! If you want to match molecules which have at least one positively charged atom and at least one negatively charged atom, you can use the SMARTS [+].[-]:

In [2]: qry = Chem.MolFromSmarts('[+].[-]')

In [3]: Chem.MolFromSmiles('[NH3+]CC(=O)[O-]').GetSubstructMatch(qry)
Out[3]: (0, 4)

In [4]: Chem.MolFromSmiles('[NH3+]CC(=O)').GetSubstructMatch(qry)
Out[4]: ()

Note that this also matches the charge separated form of nitro groups which the RDKit uses:

In [5]: Chem.MolFromSmiles('CC[N+](=O)[O-]').GetSubstructMatch(qry)
Out[5]: (2, 4)

It only matches atoms which have a +1 or -1 charge... +2 and -2 are rarer, but you could also match higher charge states if you want by using a modfied f…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@dehaenw
Comment options

@ldamore
Comment options

@piermichele-kobauri
Comment options

Answer selected by ldamore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants