本文整理汇总了C++中openbabel::OBAtom类的典型用法代码示例。如果您正苦于以下问题:C++ OBAtom类的具体用法?C++ OBAtom怎么用?C++ OBAtom使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OBAtom类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nbrBonds
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;
}
示例2: rings
void
FilterRings::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)
{
std::vector<OpenBabel::OBRing* > nrings = mol->GetSSSR();
_result = nrings.size();
}
else
{
_result = 0;
}
if ((_minLimit && (_result < _min)) || (_maxLimit && (_result > _max)))
{
_passed = false;
}
else
{
_passed = true;
}
}
示例3: ofs
extern "C" int write_output_(char *out_filename, double *A, int *n)
{
std::ofstream ofs(out_filename);
OpenBabel::OBConversion ob(NULL, &ofs);
OpenBabel::OBAtom atom;
OpenBabel::OBMol mol;
int i;
ob.SetOutFormat("CML");
/* Atom is Iridium */
atom.SetAtomicNum(77);
for (i = 0; i < *n; i++)
{
atom.SetVector(A[i*3], A[i*3+1], A[i*3+2]);
mol.AddAtom(atom);
}
//for (i=0; i < *n; i++)
//{
//for (int j=i; j < *n; j++)
//{
//mol.AddBond(i+1, j+1, 0);
//}
//}
ob.Write(&mol);
ob.CloseOutFile();
}
示例4: rings
void
FilterNonaromaticRingFraction::Calculate(OpenBabel::OBMol* mol)
{
// Are there atoms and rings?
unsigned int rings(0);
unsigned int natoms(0);
OpenBabel::OBAtom* atom;
std::vector<OpenBabel::OBAtom*>::iterator i;
for (atom = mol->BeginAtom(i); atom; atom = mol->NextAtom(i))
{
if (atom->IsHydrogen()) continue;
if (atom->IsInRing()) ++rings;
++natoms;
}
if (!natoms)
{
_result = 0.0;
_passed = false;
return;
}
std::set<int> uniqRingIdx;
if (rings)
{
std::vector<OpenBabel::OBRing*> nrings = mol->GetSSSR();
uniqRingIdx.clear();
std::vector<int>::iterator path;
std::vector<OpenBabel::OBRing*>::iterator ri;
for (ri = nrings.begin(); ri != nrings.end(); ++ri)
{
if (!(*ri)->IsAromatic())
{
for (path = (*ri)->_path.begin(); path != (*ri)->_path.end(); ++path)
{
uniqRingIdx.insert(*path);
}
}
}
}
unsigned int ar(uniqRingIdx.size());
if (ar)
{
_result = (double) ar / (double) natoms;
}
else
{
_result = 0.0;
}
if ((_minLimit && (_result < _min)) || (_maxLimit && (_result > _max)))
{
_passed = false;
}
else
{
_passed = true;
}
}
示例5: 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;
}
}
示例6: detectConformers
void ReadFileThread::detectConformers(unsigned int c,
const OpenBabel::OBMol &first,
const OpenBabel::OBMol ¤t)
{
if (!c) {
// this is the first molecule read
m_moleculeFile->setConformerFile(true);
addConformer(current);
return;
}
if (!m_moleculeFile->isConformerFile())
return;
// as long as we are not sure if this really is a
// conformer/trajectory file, add the conformers
addConformer(current);
// performance: check only certain molecule 1-10,20,50
switch (c) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 20:
case 50:
break;
default:
return;
}
if (first.NumAtoms() != current.NumAtoms()) {
m_moleculeFile->setConformerFile(false);
m_moleculeFile->m_conformers.clear();
return;
}
for (unsigned int i = 0; i < first.NumAtoms(); ++i) {
OpenBabel::OBAtom *firstAtom = first.GetAtom(i+1);
OpenBabel::OBAtom *currentAtom = current.GetAtom(i+1);
if (firstAtom->GetAtomicNum() != currentAtom->GetAtomicNum()) {
m_moleculeFile->setConformerFile(false);
m_moleculeFile->m_conformers.clear();
return;
}
}
}
示例7: paint
void StereoCenterItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Molecule *mol = molecule();
painter->save();
painter->setPen(Qt::green);
if (!mol) {
// not connected: default behaviour (draw connectable box)
MolInputItem::paint(painter, option, widget);
painter->restore();
return;
}
const QList<Atom*> &atoms = mol->atoms();
OpenBabel::OBMol *obmol = mol->OBMol();
QPointF offset(-5.0, 5.0);
#ifdef OPENBABEL2_TRUNK
// need to calculate symmetry first
std::vector<unsigned int> symmetry_classes;
OpenBabel::OBGraphSym graphsym(obmol);
graphsym.GetSymmetry(symmetry_classes);
//std::vector<unsigned long> atomIds = FindTetrahedralAtoms(obmol, symmetry_classes);
std::vector<OpenBabel::StereogenicUnit> units = FindStereogenicUnits(obmol, symmetry_classes);
for (unsigned int i = 0; i < units.size(); ++i) {
if (units.at(i).type == OpenBabel::OBStereo::Tetrahedral) {
OpenBabel::OBAtom *obatom = obmol->GetAtomById(units.at(i).id);
painter->drawEllipse(mapFromItem(mol, atoms[obatom->GetIndex()]->pos()), 10, 10);
} else
if (units.at(i).type == OpenBabel::OBStereo::CisTrans) {
OpenBabel::OBBond *obbond = obmol->GetBondById(units.at(i).id);
OpenBabel::OBAtom *obatom1 = obbond->GetBeginAtom();
OpenBabel::OBAtom *obatom2 = obbond->GetEndAtom();
painter->drawEllipse(mapFromItem(mol, atoms[obatom1->GetIndex()]->pos()), 10, 10);
painter->drawEllipse(mapFromItem(mol, atoms[obatom2->GetIndex()]->pos()), 10, 10);
}
}
#else
using OpenBabel::OBMolAtomIter;
FOR_ATOMS_OF_MOL(atom, obmol)
if (atom->IsChiral())
painter->drawEllipse(mapFromItem(mol, atoms[atom->GetIdx()-1]->pos()), 10, 10);
#endif
// default behavious (draw the label())
MolInputItem::paint(painter, option, widget);
painter->restore();
}
示例8: parent
std::list<OpenBabel::OBAtom*>
_hAccGetNeighbors(OpenBabel::OBAtom* a)
{
std::list<OpenBabel::OBAtom*> aList;
OpenBabel::OBMol* parent(a->GetParent());
double r;
OpenBabel::OBElementTable et;
std::vector<OpenBabel::OBAtom*>::iterator ai;
for (OpenBabel::OBAtom* aa = parent->BeginAtom(ai); aa; aa = parent->NextAtom(ai))
{
if (*aa == a)
{
continue;
}
r = et.GetVdwRad(aa->GetAtomicNum());
double delta(H_BOND_DIST + H_RADIUS + r);
double maxDistSq(delta*delta);
double distSq((a->x() - aa->x()) * (a->x() - aa->x()) +
(a->y() - aa->y()) * (a->y() - aa->y()) +
(a->z() - aa->z()) * (a->z() - aa->z()));
if (distSq <= maxDistSq)
{
aList.push_back(aa);
}
}
return aList;
}
示例9: newMol
OpenBabel::OBMol
Schuffenhauer::Rule_1(OpenBabel::OBMol& oldMol)
{
if (oldMol.GetSSSR().size() <= _ringsToBeRetained)
{
return oldMol;
}
OpenBabel::OBMol newMol(oldMol);
std::vector<OpenBabel::OBAtom*>::iterator avi;
OpenBabel::OBBondIterator bi;
OpenBabel::OBAtom* atom;
OpenBabel::OBAtom* nbrAtom[2];
for (atom = newMol.BeginAtom(avi); atom; atom = newMol.NextAtom(avi))
{
if ((atom->MemberOfRingSize() == 3) &&
(atom->IsNitrogen() || atom->IsOxygen()) &&
(atom->MemberOfRingCount() == 1) &&
(atom->GetHvyValence() == 2))
{
nbrAtom[0] = atom->BeginNbrAtom(bi);
nbrAtom[1] = atom->NextNbrAtom(bi);
if (nbrAtom[0] && nbrAtom[1])
{
newMol.DeleteAtom(atom);
newMol.GetBond(nbrAtom[0], nbrAtom[1])->SetBondOrder(2);
}
}
}
return newMol;
}
示例10: bo
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);
}
}
示例11:
void
hAccFuncCalc(OpenBabel::OBMol* mol, Pharmacophore* pharmacophore)
{
// Create for every hydrogen acceptor a pharmacophore point
std::vector<OpenBabel::OBAtom*>::iterator ai;
for (OpenBabel::OBAtom* atom = mol->BeginAtom(ai); atom; atom = mol->NextAtom(ai))
{
if (atom->GetAtomicNum() == 7 || atom->GetAtomicNum() == 8)
{
if (atom->GetFormalCharge() <= 0)
{
if(_hAccDelocalized(atom) || (_hAccCalcAccSurf(atom) < 0.02))
{
continue;
}
PharmacophorePoint p;
p.func = HACC;
p.point.x = atom->x();
p.point.y = atom->y();
p.point.z = atom->z();
p.hasNormal = true;
p.alpha = funcSigma[HACC];
p.normal = _hAccCalcNormal(atom);
pharmacophore->push_back(p);
}
}
}
}
示例12: GetPathAndIdentBond
//--
// [rad] generate path and ident for bond
void RelationBond::GetPathAndIdentBond(const std::string& refMoleculeId, std::string& refPath, std::string& refIdent)
{
refPath = m_vecSatisfiedClasses.front()->GetPrefix() + ":" + m_vecSatisfiedClasses.front()->GetName();
std::stringstream ssConv;
OpenBabel::OBBond* pBond = m_pBond;
OpenBabel::OBAtom* pAtomStart = pBond->GetBeginAtom();
OpenBabel::OBAtom* pAtomEnd = pBond->GetEndAtom();
ssConv << m_vecSatisfiedClasses.front()->GetName() << "_" << refMoleculeId << "_" <<
pAtomStart->GetIdx() << "_" << pAtomEnd->GetIdx();
refIdent = "";
ssConv >> refIdent;
}
示例13: rings
void
FilterAtomsInLargestNonaromaticRing::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)
{
std::vector<OpenBabel::OBRing*> nrings = mol->GetSSSR();
_result = 0;
std::vector<OpenBabel::OBRing*>::iterator ri;
for (ri = nrings.begin(); ri != nrings.end(); ++ri)
{
if ( !(*ri)->IsAromatic() && ((*ri)->Size() > _result))
{
_result = (*ri)->Size();
}
}
if ((_minLimit && (_result < _min)) || (_maxLimit && (_result > _max)))
{
_passed = false;
}
else
{
_passed = true;
}
}
else
{
_result = 0;
_passed = true;
}
}
示例14: GetObjectPropertyPathAndIdentBond
// [rad] generate path and ident for bond
void RelationBond::GetObjectPropertyPathAndIdentBond(int iPosition,
const std::string& refMoleculeId,
std::string& refPath,
std::string& refIdent)
{
refPath = m_vecSatisfiedObjectPropertiesBond[iPosition].first->GetPrefix() + ":" +
m_vecSatisfiedObjectPropertiesBond[iPosition].first->GetName();
std::stringstream ssConv;
OpenBabel::OBAtom* pAtomStart = m_vecSatisfiedObjectPropertiesBond[iPosition].second->m_pBond->GetBeginAtom();
OpenBabel::OBAtom* pAtomEnd = m_vecSatisfiedObjectPropertiesBond[iPosition].second->m_pBond->GetEndAtom();
ssConv << m_vecSatisfiedObjectPropertiesBond[iPosition].second->m_vecSatisfiedClasses.front()->GetName() << "_" << refMoleculeId << "_" <<
pAtomStart->GetIdx() << "_" << pAtomEnd->GetIdx();
refIdent = "";
ssConv >> refIdent;
}
示例15: 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;
}