-
Notifications
You must be signed in to change notification settings - Fork 845
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
Fixes #6050 #6071
Conversation
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; |
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.
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); |
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.
Should sgTracker be part of the StereoGroup object? This would remove the need for the implicit copy here.
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.
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).
We need to keep track of the group IDs of the stereo groups as the molecule is being built.