void Seed::fillNewBonds(const ROMol& qmol) { std::vector<bool> excludedBonds = ExcludedBonds; for (unsigned srcAtomIdx = LastAddedAtomsBeginIdx; srcAtomIdx < getNumAtoms(); srcAtomIdx++) { // all atoms added on previous growing only const Atom* atom = MoleculeFragment.Atoms[srcAtomIdx]; ROMol::OEDGE_ITER beg, end; for (boost::tie(beg, end) = qmol.getAtomBonds(atom); beg != end; beg++) { // all bonds from MoleculeFragment.Atoms[srcAtomIdx] const Bond* bond = &*(qmol[*beg]); if (!excludedBonds[bond->getIdx()]) { // already in the seed or NewBonds list from another atom in a RING excludedBonds[bond->getIdx()] = true; unsigned ai = (atom == bond->getBeginAtom()) ? bond->getEndAtomIdx() : bond->getBeginAtomIdx(); const Atom* end_atom = qmol.getAtomWithIdx(ai); unsigned end_atom_idx = NotSet; for (unsigned i = 0; i < getNumAtoms(); i++) if (end_atom == MoleculeFragment.Atoms[i]) { // already exists in this seed end_atom_idx = i; break; } NewBonds.push_back( NewBond(srcAtomIdx, bond->getIdx(), ai, end_atom_idx, NotSet == end_atom_idx ? end_atom : nullptr)); } } } }
void AtomContainer::addAtom(const double * pos, const std::vector<std::string>& atomProperties){ int iProperty; //after adding the atom was successful, continue with adding additional properties if(addAtom(pos)) { //save additional properties for (iProperty = 0; iProperty < atomProperties.size(); iProperty++){ if (!atomPropertyList.isPropertyInt(iProperty)) { //property has float type atomPropertyList.addFloatPropertyValue(iProperty, atof(atomProperties[iProperty].c_str())); } else { //property has integer type if (isFloat(atomProperties[iProperty])) { //but current value is of float type -> conversion atomPropertyList.convertPropertyToFloat(iProperty); atomPropertyList.addFloatPropertyValue(iProperty, atof(atomProperties[iProperty].c_str())); } else { //value has also integer type -> add value atomPropertyList.addIntPropertyValue(iProperty,atoi(atomProperties[iProperty].c_str())); } } } } else { std::cout << "WARNING: Adding atom " << getNumAtoms() <<" failed (placed outside container)" << std::endl; } }
void Seed::computeRemainingSize(const ROMol& qmol) { RemainingBonds = RemainingAtoms = 0; std::vector<unsigned> end_atom_stack; std::vector<bool> visitedBonds = ExcludedBonds; std::vector<bool> visitedAtoms(qmol.getNumAtoms()); for (auto&& visitedAtom : visitedAtoms) visitedAtom = false; for (std::vector<unsigned>::const_iterator it = MoleculeFragment.AtomsIdx.begin(); it != MoleculeFragment.AtomsIdx.end(); it++) visitedAtoms[*it] = true; // SDF all paths // 1. direct neighbours for (unsigned seedAtomIdx = LastAddedAtomsBeginIdx; seedAtomIdx < getNumAtoms(); seedAtomIdx++) { // just now added new border vertices (candidates for // future growing) const Atom* atom = MoleculeFragment.Atoms[seedAtomIdx]; ROMol::OEDGE_ITER beg, end; for (boost::tie(beg, end) = qmol.getAtomBonds(atom); beg != end; beg++) { // all bonds from MoleculeFragment.Atoms[srcAtomIdx] const Bond& bond = *(qmol[*beg]); if (!visitedBonds[bond.getIdx()]) { ++RemainingBonds; visitedBonds[bond.getIdx()] = true; unsigned end_atom_idx = (MoleculeFragment.AtomsIdx[seedAtomIdx] == bond.getBeginAtomIdx()) ? bond.getEndAtomIdx() : bond.getBeginAtomIdx(); if (!visitedAtoms[end_atom_idx]) { // check RING/CYCLE ++RemainingAtoms; visitedAtoms[end_atom_idx] = true; end_atom_stack.push_back(end_atom_idx); } } } } // 2. go deep while (!end_atom_stack.empty()) { unsigned ai = end_atom_stack.back(); end_atom_stack.pop_back(); const Atom* atom = qmol.getAtomWithIdx(ai); ROMol::OEDGE_ITER beg, end; for (boost::tie(beg, end) = qmol.getAtomBonds(atom); beg != end; beg++) { // all bonds from end_atom const Bond& bond = *(qmol[*beg]); if (!visitedBonds[bond.getIdx()]) { ++RemainingBonds; visitedBonds[bond.getIdx()] = true; unsigned end_atom_idx = (ai == bond.getBeginAtomIdx()) ? bond.getEndAtomIdx() : bond.getBeginAtomIdx(); if (!visitedAtoms[end_atom_idx]) { // check RING/CYCLE ++RemainingAtoms; visitedAtoms[end_atom_idx] = true; end_atom_stack.push_back(end_atom_idx); } } } } }