Skip to content

Commit

Permalink
Calculate bondsets for all rings when pruning in SSSR
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikw committed Nov 21, 2023
1 parent e1e372e commit 785673b
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/ring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,22 +348,36 @@ namespace OpenBabel
if (_rlist.size() == (unsigned)frj)
return;

//make sure tmp is the same size as the rings
// create bondsets
std::vector<OBBitVec> _bslist;
std::vector<unsigned int> bonds;
OBBitVec bondset;
OBMol *mol = _rlist[0]->GetParent();
for (j = 0; j < (signed)_rlist.size(); ++j)
{
bondset.Clear();
bonds = atomRingToBondRing(mol, (_rlist[j])->_path);
for (unsigned int i = 0; i < bonds.size(); ++i)
bondset.SetBitOn(bonds[i]);
_bslist.push_back(bondset);
}

// make sure tmp is the same size as the rings
OBBitVec tmp;
for (j = 0;j < (signed)_rlist.size();++j)
tmp = (_rlist[j])->_pathset;
for (j = 0; j < (signed)_bslist.size(); ++j)
tmp = _bslist[j];

//remove larger rings that cover the same atoms as smaller rings
for (i = _rlist.size()-1;i >= 0;i--)
{
tmp.Clear();
for (j = 0;j < (signed)_rlist.size();++j)
if ((_rlist[j])->_path.size() <= (_rlist[i])->_path.size() && i != j)
tmp |= (_rlist[j])->_pathset;
tmp |= _bslist[j];

tmp = tmp & (_rlist[i])->_pathset;
tmp = tmp & _bslist[i];

if (tmp == (_rlist[i])->_pathset)
if (tmp == _bslist[i])
{
delete _rlist[i];
_rlist.erase(_rlist.begin()+i);
Expand Down

0 comments on commit 785673b

Please sign in to comment.