Skip to content

Add the option to wedge two bonds at chiral centers#6108

Merged
greglandrum merged 14 commits into
rdkit:masterfrom
greglandrum:feat/add_two_wedges
Mar 11, 2023
Merged

Add the option to wedge two bonds at chiral centers#6108
greglandrum merged 14 commits into
rdkit:masterfrom
greglandrum:feat/add_two_wedges

Conversation

@greglandrum
Copy link
Copy Markdown
Member

Some style guides suggest including wedges at chiral centers. This adds a modification to WedgeMolBonds() to allow two neighboring bonds to be wedged:
Here's an example of what this does:
image

There's also some refactoring of the bond wedging code, including pulling it out into a separate source file.

At the moment the functionality here is limited to tetrahedral stereo. The refactoring and cleanup is intended to make it easier to get this working with non-tetrahedral stereo.

@greglandrum greglandrum added this to the 2023_03_1 milestone Feb 18, 2023
@greglandrum greglandrum marked this pull request as draft February 18, 2023 20:16
Comment thread Code/GraphMol/WedgeBonds.cpp Outdated
auto [chiNbrs, nChiralNbrs] = detail::countChiralNbrs(mol, noNbrs);
if (chiNbrs) {
std::sort(indices.begin(), indices.end(), [&](auto i1, auto i2) {
return nChiralNbrs[i1] < nChiralNbrs[i2];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're going to love this one:

https://stackoverflow.com/questions/46114214/lambda-implicit-capture-fails-with-variable-declared-from-structured-binding

Basically clang is being anal with the specification that tuple unpacking never makes variables and lambdas must only implicitly bind variables.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can resolve this as follows:

std::sort(indices.begin(), indices.end(), [&, nChiralNbrs=nChiralNbrs](auto i1, auto i2) {
       return nChiralNbrs[i1] < nChiralNbrs[i2];
});

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out.

@bp-kelley
Copy link
Copy Markdown
Contributor

Hey, it worked!

@greglandrum greglandrum marked this pull request as ready for review February 20, 2023 10:15
@greglandrum
Copy link
Copy Markdown
Member Author

@bp-kelley: if you have a chance to look at this again, I think it's ready for review

Comment thread Code/GraphMol/WedgeBonds.cpp
Comment thread Code/GraphMol/WedgeBonds.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants