Example #1
0
Coordinate
_hDonCalcNormal(OpenBabel::OBAtom* a)
{
   int nbrBonds(0);
   Coordinate normal;

   std::vector<OpenBabel::OBBond*>::iterator bi;
   for (OpenBabel::OBBond* b = a->BeginBond(bi); b; b = a->NextBond(bi))
   {
      OpenBabel::OBAtom* aa = b->GetNbrAtom(a);
      if (aa->GetAtomicNum() == 1)
      {
         continue;
      }
      ++nbrBonds;
      normal.x += (aa->x() - a->x());
      normal.y += (aa->y() - a->y());
      normal.z += (aa->z() - a->z());
   }
   double length(sqrt(normal.x*normal.x + normal.y*normal.y + normal.z*normal.z));
   normal.x /= length;
   normal.y /= length;
   normal.z /= length;
  
   normal.x = -normal.x;
   normal.y = -normal.y;
   normal.z = -normal.z;
  
   normal.x += a->x();
   normal.y += a->y();
   normal.z += a->z();
  
   return normal;
}
Example #2
0
void
Fingerprint::_getFragments(std::vector<int> levels, std::vector<int>curfrag, 
int level, OpenBabel::OBAtom* patom, OpenBabel::OBBond* pbond)
{
   const int MaxFragSize = 7;
   int bo(0);
   if (pbond) bo = pbond->IsAromatic() ? 5 : pbond->GetBondOrder();

   curfrag.push_back(bo);
   curfrag.push_back(patom->GetAtomicNum());
   levels[patom->GetIdx()] = level;

   std::vector<OpenBabel::OBBond*>::iterator i;
   OpenBabel::OBBond* pnewbond;
   for (pnewbond = patom->BeginBond(i); pnewbond; pnewbond = patom->NextBond(i))
   {
      if (pnewbond == pbond)
      {
         continue;
      }
      OpenBabel::OBAtom* pnxtat = pnewbond->GetNbrAtom(patom);
      int atlevel = levels[pnxtat->GetIdx()];
      if (atlevel)
      {
         if (atlevel == 1)
         {
            curfrag[0] = bo;
            _ringset.insert(curfrag);
         }
      }
      else
      {
         if (level < MaxFragSize)
         {
            _getFragments(levels, curfrag, level + 1, pnxtat, pnewbond);
         }
      }
   }
   
   if ((curfrag[0] == 0) &&
      ((level > 1) || (patom->GetAtomicNum() > 8) || (patom->GetAtomicNum() < 6)))
   {
      _fragset.insert(curfrag);
   }
}