本文整理汇总了C++中openbabel::OBMol::BeginAtom方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::BeginAtom方法的具体用法?C++ OBMol::BeginAtom怎么用?C++ OBMol::BeginAtom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openbabel::OBMol
的用法示例。
在下文中一共展示了OBMol::BeginAtom方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rings
void
FilterCores::Calculate(OpenBabel::OBMol* mol)
{
// Any rings?
OpenBabel::OBAtom* atom;
std::vector<OpenBabel::OBAtom*>::iterator i;
bool rings(false);
for (atom = mol->BeginAtom(i); atom; atom = mol->NextAtom(i))
{
if (atom->IsInRing())
{
rings = true;
break;
}
}
if (rings)
{
// Make workcopy of original mol
OpenBabel::OBMol m = *mol; m.DeleteHydrogens();
// Iteratively remove all endstanding atoms until none are left
OpenBabel::OBAtom* atom;
std::vector<OpenBabel::OBAtom*>::iterator i;
bool endstanding(true);
while (endstanding && m.NumAtoms())
{
endstanding = false;
for (atom = m.BeginAtom(i); atom; atom = m.NextAtom(i))
{
if (atom->GetValence() < 2)
{
if (m.DeleteAtom(atom))
{
endstanding = true;
break;
}
}
}
}
if (m.NumAtoms()) _result = 1;
else _result = 0;
}
else
{
_result = 0;
}
if ((_minLimit && (_result < _min)) || (_maxLimit && (_result > _max)))
{
_passed = false;
}
else
{
_passed = true;
}
}
示例2: n
unsigned int
Schuffenhauer::CalculateHeteroAtoms(OpenBabel::OBMol& mol, OpenBabel::OBRing* ring, int a = 0)
{
unsigned int n(0);
OpenBabel::OBAtom* atom;
std::vector<OpenBabel::OBAtom*>::iterator avi;
for (atom = mol.BeginAtom(avi); atom; atom = mol.NextAtom(avi))
{
if (ring->IsMember(atom) && (atom->GetAtomicNum() == a))
{
++n;
}
if (!a && ring->IsMember(atom))
{
if ((atom->GetAtomicNum() == 7) ||
(atom->GetAtomicNum() == 8) ||
(atom->GetAtomicNum() == 16))
{
++n;
}
}
}
return n;
}
示例3: rings
void
FilterBridgeFraction::Calculate(OpenBabel::OBMol* mol)
{
// Are there rings?
OpenBabel::OBAtom* atom;
std::vector<OpenBabel::OBAtom*>::iterator i;
bool rings(false);
for (atom = mol->BeginAtom(i); atom; atom = mol->NextAtom(i))
{
if (atom->IsInRing())
{
rings = true;
break;
}
}
if (rings)
{
// Make workcopy of original mol
OpenBabel::OBMol m = *mol; m.DeleteHydrogens();
unsigned int natoms(m.NumAtoms());
if (!natoms)
{
_result = 0.0;
_passed = false;
return;
}
// Iteratively remove all endstanding atoms until none are left
OpenBabel::OBAtom* atom;
std::vector<OpenBabel::OBAtom*>::iterator i;
bool endstanding(true);
while (endstanding && m.NumAtoms())
{
endstanding = false;
for (atom = m.BeginAtom(i); atom; atom = m.NextAtom(i))
{
if (atom->GetValence() < 2)
{
if (m.DeleteAtom(atom))
{
endstanding = true;
break;
}
}
}
}
// Now remove all ring atoms
rings = true;
while (rings && m.NumAtoms())
{
rings = false;
for (atom = m.BeginAtom(i); atom; atom = m.NextAtom(i))
{
if (atom->IsInRing())
{
if (m.DeleteAtom(atom))
{
rings = true;
break;
}
}
}
}
_result = (double) m.NumAtoms() / (double) natoms;
}
else
{
_result = 0.0;
}
if ((_minLimit && (_result < _min)) || (_maxLimit && (_result > _max)))
{
_passed = false;
}
else
{
_passed = true;
}
}
示例4: rings
void
FilterAtomsInSmallestBridge::Calculate(OpenBabel::OBMol* mol)
{
// Are there rings?
OpenBabel::OBAtom* atom;
std::vector<OpenBabel::OBAtom*>::iterator i;
bool rings(false);
for (atom = mol->BeginAtom(i); atom; atom = mol->NextAtom(i))
{
if (atom->IsInRing())
{
rings = true;
break;
}
}
if (rings)
{
// Make workcopy of original mol
OpenBabel::OBMol m = *mol; m.DeleteHydrogens();
// Iteratively remove all endstanding atoms until none are left
OpenBabel::OBAtom* atom;
std::vector<OpenBabel::OBAtom*>::iterator i;
bool endstanding(true);
while (endstanding && m.NumAtoms())
{
endstanding = false;
for (atom = m.BeginAtom(i); atom; atom = m.NextAtom(i))
{
if (atom->GetValence() < 2)
{
if (m.DeleteAtom(atom))
{
endstanding = true;
break;
}
}
}
}
// Now remove all ring atoms
rings = true;
while (rings && m.NumAtoms())
{
rings = false;
for (atom = m.BeginAtom(i); atom; atom = m.NextAtom(i))
{
if (atom->IsInRing())
{
if (m.DeleteAtom(atom))
{
rings = true;
break;
}
}
}
}
// Separate into fragments
if (m.NumAtoms())
{
std::vector<std::vector<int> > bridges;
m.ContigFragList(bridges);
_result = bridges[0].size();
for (unsigned int i(1); i < bridges.size(); ++i)
{
if (bridges[i].size() < _result) _result = bridges[i].size();
}
}
if ((_minLimit && (_result < _min)) || (_maxLimit && (_result > _max)))
{
_passed = false;
}
else
{
_passed = true;
}
}
else
{
_result = 0;
_passed = true;
}
}
示例5: notaromatic
OpenBabel::OBMol
Schuffenhauer::Rule_11(OpenBabel::OBMol& oldMol)
{
// Return if the molecule contains an acyclic linker
std::vector<OpenBabel::OBAtom*>::iterator avi;
OpenBabel::OBAtom* atom;
for (atom = oldMol.BeginAtom(avi); atom; atom = oldMol.NextAtom(avi))
{
if (!atom->IsInRing() && atom->GetValence() >= 2)
{
return oldMol;
}
}
// Make sure we are dealing with a mixed aromatic/nonaromatic system
bool notaromatic(false);
bool aromatic(false);
for (atom = oldMol.BeginAtom(avi); atom; atom = oldMol.NextAtom(avi))
{
if (atom->IsAromatic())
{
aromatic = true;
}
else
{
notaromatic = true;
}
}
if (aromatic && notaromatic)
{
std::vector<OpenBabel::OBRing*> allrings(oldMol.GetSSSR());
if (allrings.size() <= _ringsToBeRetained)
{
return oldMol;
}
std::vector<OpenBabel::OBMol> mols;
std::vector<unsigned int> aromaticRings;
for (unsigned int i(0); i < allrings.size(); ++i)
{
if (allrings[i]->IsAromatic())
{
mols.push_back(oldMol);
aromaticRings.push_back(i);
}
}
std::vector<OpenBabel::OBMol> validMols;
for (unsigned int i(0); i < aromaticRings.size(); ++i)
{
mols[i] = RemoveRing(mols[i], allrings, aromaticRings[i]);
if (!mols[i].Empty())
{
validMols.push_back(mols[i]);
}
}
if (validMols.size() == 1)
{
return validMols[0];
}
}
return oldMol;
}
示例6: broken
OpenBabel::OBMol
Schuffenhauer::Rule_7(OpenBabel::OBMol& oldMol)
{
std::vector<OpenBabel::OBRing*> allrings(oldMol.GetSSSR());
if (allrings.size() <= _ringsToBeRetained)
{
return oldMol;
}
// Are all atoms and bonds aromatic?
std::vector<OpenBabel::OBAtom*>::iterator avi;
OpenBabel::OBAtom* atom;
for (atom = oldMol.BeginAtom(avi); atom; atom = oldMol.NextAtom(avi))
{
if (!atom->IsAromatic())
{
return oldMol;
}
}
std::vector<OpenBabel::OBBond*>::iterator bvi;
OpenBabel::OBBond* bond;
for (bond = oldMol.BeginBond(bvi); bond; bond = oldMol.NextBond(bvi))
{
if (!bond->IsAromatic())
{
return oldMol;
}
}
std::vector<OpenBabel::OBMol> mols;
for (unsigned int i(0); i < allrings.size(); ++i)
{
mols.push_back(oldMol);
}
std::vector<OpenBabel::OBMol> validMols;
for (unsigned int i(0); i < mols.size(); ++i)
{
mols[i] = RemoveRing(mols[i], allrings, i);
if (!mols[i].Empty())
{
// Has aromaticity been broken?
bool broken(false);
for (atom = mols[i].BeginAtom(avi); atom; atom = mols[i].NextAtom(avi))
{
if (atom->IsInRing() && !atom->IsAromatic())
{
broken = true;
break;
}
}
if (!broken)
{
validMols.push_back(mols[i]);
}
}
}
if (validMols.size() == 1)
{
return validMols[0];
}
return oldMol;
}
示例7: allrings
OpenBabel::OBMol
Schuffenhauer::Rule_6(OpenBabel::OBMol& oldMol)
{
std::vector<OpenBabel::OBRing*> allrings(oldMol.GetSSSR());
if (allrings.size() <= _ringsToBeRetained)
{
return oldMol;
}
std::vector<OpenBabel::OBMol> mols;
std::vector<int> rings;
int size;
for (unsigned int i(0); i < allrings.size(); ++i)
{
size = allrings[i]->Size();
if ((size == 3) || (size == 5) || (size == 6))
{
mols.push_back(oldMol);
rings.push_back(i);
}
}
if (mols.empty())
{
return oldMol;
}
// Only focus on ringsystems with more than one ring
std::vector<OpenBabel::OBAtom*>::iterator avi;
OpenBabel::OBAtom* atom;
std::vector<int> fusedRings;
for (unsigned int i(0); i < rings.size(); ++i)
{
for (atom = oldMol.BeginAtom(avi); atom; atom = oldMol.NextAtom(avi))
{
if (allrings[rings[i]]->IsMember(atom) && (atom->MemberOfRingCount() > 1))
{
fusedRings.push_back(rings[i]);
break;
}
}
}
if (fusedRings.empty())
{
return oldMol;
}
std::vector<OpenBabel::OBMol> validMols;
for (unsigned int i(0); i < fusedRings.size(); ++i)
{
mols[i] = RemoveRing(mols[i], allrings, fusedRings[i]);
if (!mols[i].Empty())
{
validMols.push_back(mols[i]);
}
}
if (validMols.size() == 1)
{
return validMols[0];
}
return oldMol;
}
示例8: rings
void
FilterRingsystems::Calculate(OpenBabel::OBMol* mol)
{
// Are there rings?
bool rings(false);
OpenBabel::OBAtom* atom;
std::vector<OpenBabel::OBAtom*>::iterator i;
for (atom = mol->BeginAtom(i); atom; atom = mol->NextAtom(i))
{
if (atom->IsInRing())
{
rings = true;
break;
}
}
if (rings)
{
// Make workcopy of original mol
OpenBabel::OBMol m = *mol; m.DeleteHydrogens();
// Remove all atoms that are not part of ring
std::vector<OpenBabel::OBAtom*> nonRingAtoms;
nonRingAtoms.clear();
for (atom = m.BeginAtom(i); atom; atom = m.NextAtom(i))
{
if (!atom->IsInRing()) nonRingAtoms.push_back(atom);
}
for (unsigned int i(0); i < nonRingAtoms.size(); ++i)
{
m.DeleteAtom(nonRingAtoms[i]);
}
// Remove all bonds that are not part of a ring
std::vector<OpenBabel::OBBond*> nonRingBonds;
nonRingBonds.clear();
OpenBabel::OBBond* bond;
std::vector<OpenBabel::OBBond*>::iterator j;
for (bond = m.BeginBond(j); bond; bond = m.NextBond(j))
{
if (!bond->IsInRing()) nonRingBonds.push_back(bond);
}
for (unsigned int i(0); i < nonRingBonds.size(); ++i)
{
m.DeleteBond(nonRingBonds[i]);
}
// Count ringsystems
std::vector<std::vector< int > > ringsystems;
m.ContigFragList(ringsystems);
_result = ringsystems.size();
}
else
{
_result = 0;
}
if ((_minLimit && (_result < _min)) || (_maxLimit && (_result > _max)))
{
_passed = false;
}
else
{
_passed = true;
}
}