Dear Igor,

On Fri, Dec 26, 2008 at 6:56 PM, Igor Filippov [Contr]
<[email protected]> wrote:
> Dear Greg,
>
> I was wondering if you could give a hint as to how accomplish the
> following: I am trying to remove all the disconnected fragments from a
> molecule smaller than a certain threshold number of atoms. The following
> piece of code does not seem to work:
>
> std::vector<ROMOL_SPTR> frag;
>  frag = MolOps::getMolFrags(*mol1);
>  for (unsigned i=0;i< frag.size();i++)
>    if (frag[i]->getNumAtoms()<MIN_A_COUNT)
>      for(RWMol::AtomIterator atomIt=frag[i]->beginAtoms();atomIt!
> =frag[i]->endAtoms();atomIt++)
>        {
>          RWMol *mol2=(static_cast<RWMol *>(frag[i]));
>          mol2->removeAtom(atomIt);
>        }
>
> Any recommendations would be welcome!
>

The RWMol class has an insertMol() method that I would use. Something
like this (completely untested):

RWMol *newMol=new RWMol();
std::vector<ROMOL_SPTR> frag;
frag = MolOps::getMolFrags(*mol1);
for (unsigned i=0;i< frag.size();i++){
  if (frag[i]->getNumAtoms()<MIN_A_COUNT){
    newMol->insertMol(*frag[i]);
  }
}

> P.S. Merry holidays :)

Thanks! You too.
Note: I will be out of email contact for a week starting today.

-greg

Reply via email to