Skip to content
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

Fixes #6050 #6071

Merged
merged 3 commits into from
Feb 16, 2023
Merged

Fixes #6050 #6071

merged 3 commits into from
Feb 16, 2023

Conversation

greglandrum
Copy link
Member

We need to keep track of the group IDs of the stereo groups as the molecule is being built.

std::vector<StereoGroup> mol_stereo_groups(mol.getStereoGroups());
mol_stereo_groups.emplace_back(group_type, std::move(atoms));
TEST_ASSERT(mol_stereo_groups.size() == sgTracker.size());
bool found = false;
Copy link
Contributor

@bp-kelley bp-kelley Feb 14, 2023

Choose a reason for hiding this comment

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

using std::find I think would make this code simpler.

   auto index = std::find(sgTracker.start(), sgTracker.end(), group_id);
   if( index != sgTracker.end()) {
         auto gAtoms = mol_stereo_groups[*index].getAtoms();
         gAtoms.insert(gAtoms.end(), atoms.begin(), atoms.end());
         mol_stereo_groups[*index] =
             StereoGroup(mol_stereo_groups[*index].getGroupType(), std::move(gAtoms));
   } else {
      // not seen this before, create a new stereogroup
       mol_stereo_groups.emplace_back(group_type, std::move(atoms));
       sgTracker.resize(mol_stereo_groups.size());
       sgTracker.back() = group_id;
      mol.setProp(cxsgTracker, sgTracker);
   }

// this particular StereoGroup (was Github #6050)
group_id = 10 * group_id + static_cast<unsigned int>(group_type);
std::vector<unsigned int> sgTracker;
mol.getPropIfPresent(cxsgTracker, sgTracker);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should sgTracker be part of the StereoGroup object? This would remove the need for the implicit copy here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think the IDs should be part of the stereogroups. They only important here when parsing and can then simply be added when writing the groups out (which may not be in the order in which they were read or stored).

@bp-kelley bp-kelley merged commit a49380e into rdkit:master Feb 16, 2023
greglandrum added a commit that referenced this pull request Feb 23, 2023
* translate the cxsmiles tests to use catch2

* Fixes #6050

* changes in response to review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants