本文整理汇总了C++中openbabel::OBMol::DeleteHydrogens方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::DeleteHydrogens方法的具体用法?C++ OBMol::DeleteHydrogens怎么用?C++ OBMol::DeleteHydrogens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openbabel::OBMol
的用法示例。
在下文中一共展示了OBMol::DeleteHydrogens方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
}
示例3: 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;
}
}
示例4: main
//.........这里部分代码省略.........
else
{
no_ignored++;
}
delete mol;
continue;
}
Log.level(20) << "Molecule <" << mol_name << "> is newly protonated because of missing hydrogens (non-hydrogen atoms keep their 3D coordinates)." << endl;
}
}
else
{
rebuild_mol = true;
Log.level(20) << "Molecule <" << mol_name << "> is rebuild because of either missing 3D coordinates, unusual charges or unusual bond lengths." << endl;
}
}
// Rebuild or re-protonate and minimze molecule using OpenBabel tools
// Note: Openbabel::OpGen3D::Do() is NOT used directly here, because it re-assigns hydrogens for a static ph of 7.4,
// i.e. the pH can not be specified. Furthermore, it does also not remove hydrogens before using OBBuilder, resulting in hydrogens sometimes having more than one bond!
obmol = MolecularSimilarity::createOBMol(*mol);
ob_error = false;
try
{
// Remove all hydrogens before using OBBuilder, otherwise hydrogens end up having more than one bond! (Sigh!)
obmol->DeleteHydrogens();
// Backup original atom coordinates
coord_backup.clear();
if (!rebuild_mol && keep3DcoordsProtonate)
{
for(OpenBabel::OBAtomIterator a_it=obmol->BeginAtoms(); a_it!=obmol->EndAtoms(); ++a_it)
{
coord_backup.insert(make_pair((*a_it)->GetIdx(), (*a_it)->GetVector()));
}
}
// Create 3D coordinates for individual fragments using template library
OpenBabel::OBBuilder builder;
builder.Build(*obmol);
obmol->SetDimension(3);
// Set up a constraints object for OpenBabel minimization
// It is used to set positional constraints on non-hydrogen atoms when only hydrogens should be minimized
OpenBabel::OBFFConstraints constraints;
// Reset original coordinates and set positional constraints on non-hydrogen atoms
if (!rebuild_mol && keep3DcoordsProtonate)
{
for(OpenBabel::OBAtomIterator a_it=obmol->BeginAtoms(); a_it!=obmol->EndAtoms(); ++a_it)
{
(*a_it)->SetVector(coord_backup[(*a_it)->GetIdx()]);
constraints.AddAtomConstraint((*a_it)->GetIdx());
}
示例5: 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;
}
}