本文整理汇总了C++中openbabel::OBAtom::GetAtomicNum方法的典型用法代码示例。如果您正苦于以下问题:C++ OBAtom::GetAtomicNum方法的具体用法?C++ OBAtom::GetAtomicNum怎么用?C++ OBAtom::GetAtomicNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openbabel::OBAtom
的用法示例。
在下文中一共展示了OBAtom::GetAtomicNum方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
}
}
}
示例2: 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;
}
}
}
示例3: 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;
}
示例4: 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;
}
示例5:
void
hDonFuncCalc(OpenBabel::OBMol* mol, Pharmacophore* pharmacophore)
{
// Create for every hydrogen donor a pharmacophore point
std::vector<OpenBabel::OBAtom*>::iterator ai;
for (OpenBabel::OBAtom* a = mol->BeginAtom(ai); a; a = mol->NextAtom(ai))
{
if (a->GetAtomicNum() == 7 || a->GetAtomicNum() == 8)
{
if (a->GetFormalCharge() >= 0 && ((a->GetImplicitValence() - a->GetHvyValence()) !=0))
{
PharmacophorePoint p;
p.func = HDON;
p.point.x = a->x();
p.point.y = a->y();
p.point.z = a->z();
p.hasNormal = true;
p.alpha = funcSigma[HDON];
p.normal = _hDonCalcNormal(a);
pharmacophore->push_back(p);
}
}
}
}
示例6: 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;
}
示例7: addHydrogens
void Molecule::addHydrogens(Atom *a,
const QList<unsigned long> &atomIds,
const QList<unsigned long> &bondIds)
{
if (atomIds.size() != bondIds.size()) {
qDebug() << "Error, addHydrogens called with atom & bond id lists of different size!";
}
// Construct an OBMol, call AddHydrogens and translate the changes
OpenBabel::OBMol obmol = OBMol();
if (a) {
OpenBabel::OBAtom *obatom = obmol.GetAtom(a->index()+1);
// Set implicit valence for unusual elements not handled by OpenBabel
// PR#2803076
switch (obatom->GetAtomicNum()) {
case 3:
case 11:
case 19:
case 37:
case 55:
case 85:
case 87:
obatom->SetImplicitValence(1);
obatom->SetHyb(1);
obmol.SetImplicitValencePerceived();
break;
case 4:
case 12:
case 20:
case 38:
case 56:
case 88:
obatom->SetImplicitValence(2);
obatom->SetHyb(2);
obmol.SetImplicitValencePerceived();
break;
case 84: // Po
obatom->SetImplicitValence(2);
obatom->SetHyb(3);
obmol.SetImplicitValencePerceived();
break;
default: // do nothing
break;
}
obmol.AddHydrogens(obatom);
}
else
obmol.AddHydrogens();
// All new atoms in the OBMol must be the additional hydrogens
unsigned int numberAtoms = numAtoms();
int j = 0;
for (unsigned int i = numberAtoms+1; i <= obmol.NumAtoms(); ++i, ++j) {
if (obmol.GetAtom(i)->IsHydrogen()) {
OpenBabel::OBAtom *obatom = obmol.GetAtom(i);
Atom *atom;
if (atomIds.isEmpty())
atom = addAtom();
else if (j < atomIds.size())
atom = addAtom(atomIds.at(j));
else {
qDebug() << "Error - not enough unique ids in addHydrogens.";
break;
}
atom->setOBAtom(obatom);
// Get the neighbor atom
OpenBabel::OBBondIterator iter;
OpenBabel::OBAtom *next = obatom->BeginNbrAtom(iter);
Bond *bond;
if (bondIds.isEmpty())
bond = addBond();
else // Already confirmed by atom ids
bond = addBond(bondIds.at(j));
bond->setEnd(Molecule::atom(atom->index()));
bond->setBegin(Molecule::atom(next->GetIdx()-1));
}
}
for (unsigned int i = 1; i <= numberAtoms; ++i) {
// Warning -- OB atom index off-by-one here
atom(i-1)->setPartialCharge(obmol.GetAtom(i)->GetPartialCharge());
}
}
示例8: m
//.........这里部分代码省略.........
// Remove all endstanding atoms
OpenBabel::OBBondIterator bi;
OpenBabel::OBBond* bond;
std::vector<OpenBabel::OBBond*>::iterator bvi;
bool removed(true);
while (removed)
{
removed = false;
for (atom = m.BeginAtom(avi); atom; atom = m.NextAtom(avi))
{
if (IsEndStanding(atom, false, false))
{
m.DeleteAtom(atom);
removed = true;
break;
}
}
}
// Set all bond orders equal to 1
m.BeginModify();
for (bond = m.BeginBond(bvi); bond; bond = m.NextBond(bvi))
{
bond->SetBondOrder(1);
}
m.EndModify();
// Transform all neighbouring linker atoms into a single bond
removed = true;
OpenBabel::OBAtom* nbrAtom[2];
while (removed)
{
removed = false;
for (atom = m.BeginAtom(avi); atom; atom = m.NextAtom(avi))
{
if (!atom->IsInRing() && (atom->GetValence() == 2))
{
m.BeginModify();
nbrAtom[0] = atom->BeginNbrAtom(bi);
nbrAtom[1] = atom->NextNbrAtom(bi);
if (nbrAtom[0] && nbrAtom[1])
{
m.AddBond(nbrAtom[0]->GetIdx(), nbrAtom[1]->GetIdx(), 1);
m.DeleteAtom(atom);
m.EndModify();
removed = true;
break;
}
}
}
}
// Shrink all rings to their minimum size
removed = true;
while (removed)
{
removed = false;
for (atom = m.BeginAtom(avi); atom; atom = m.NextAtom(avi))
{
if ((atom->MemberOfRingSize() > 3) && (atom->GetValence() == 2))
{
nbrAtom[0] = atom->BeginNbrAtom(bi);
nbrAtom[1] = atom->NextNbrAtom(bi);
if (nbrAtom[0] && nbrAtom[1])
{
if (nbrAtom[0]->GetAtomicNum() == atom->GetAtomicNum())
{
m.BeginModify();
m.AddBond(nbrAtom[0]->GetIdx(), nbrAtom[1]->GetIdx(), 1);
m.DeleteAtom(atom);
m.EndModify();
removed = true;
break;
}
else
if (nbrAtom[1]->GetAtomicNum() == atom->GetAtomicNum())
{
m.BeginModify();
m.AddBond(nbrAtom[0]->GetIdx(), nbrAtom[1]->GetIdx(), 1);
m.DeleteAtom(atom);
m.EndModify();
removed = true;
break;
}
}
}
}
}
if (!m.Empty())
{
_smiles = _mol2can.WriteString(&m, true);
}
else
{
_smiles = "-";
return false;
}
return true;
}
示例9: if
bool
_hAccDelocalized(OpenBabel::OBAtom* a)
{
if (a->GetAtomicNum() != 7)
{
return false;
}
if (a->IsAromatic() && a->GetImplicitValence() == 3)
{
return true;
}
std::vector<OpenBabel::OBBond*>::iterator bi1;
for (OpenBabel::OBBond* b1 = a->BeginBond(bi1); b1; b1 = a->NextBond(bi1))
{
OpenBabel::OBAtom* aa = b1->GetNbrAtom(a);
if (aa->IsAromatic() && a->GetImplicitValence() == 3)
{
return true;
}
if (aa->GetAtomicNum() == 6)
{
std::vector<OpenBabel::OBBond*>::iterator bi2;
for (OpenBabel::OBBond* b2 = aa->BeginBond(bi2); b2; b2 = aa->NextBond(bi2))
{
OpenBabel::OBAtom* aaa = b2->GetNbrAtom(aa);
if (aaa == a)
{
continue;
}
if (b2->GetBO() == 2)
{
if (aaa->GetAtomicNum() == 8) return true;
if (aaa->GetAtomicNum() == 7) return true;
if (aaa->GetAtomicNum() == 16) return true;
}
}
}
else if (aa->GetAtomicNum() == 16)
{
std::vector<OpenBabel::OBBond*>::iterator bi2;
for (OpenBabel::OBBond* b2 = aa->BeginBond(bi2); b2; b2 = aa->NextBond(bi2))
{
OpenBabel::OBAtom* aaa = b2->GetNbrAtom(aa);
if (aaa == a)
{
continue;
}
if ((b2->GetBO() == 2) && (aaa->GetAtomicNum() == 8))
{
return true;
}
}
}
}
return false;
}
示例10: Satisfy
//.........这里部分代码省略.........
{
std::vector<OpenBabel::OBRing*>& refSSSR = pMolecule->GetSSSR();
bool bAromatic = false;
std::vector<OpenBabel::OBRing*>::iterator iter_rings = refSSSR.begin();
while(iter_rings != refSSSR.end())
{
if((*iter_rings)->IsAromatic())
{
bAromatic = true;
break;
}
iter_rings++;
}
ConvertBool(bAromatic, refValue);
}
else if(!refTo.compare("MOLECULE_HAS_HOMOCYCLIC_RING"))
{
std::vector<OpenBabel::OBRing*>& refSSSR = pMolecule->GetSSSR();
std::vector<OpenBabel::OBRing*>::iterator iter_rings = refSSSR.begin();
OpenBabel::OBAtom* pAtom;
bool bHomoCyclic = true;
while(iter_rings != refSSSR.end())
{
std::vector<int>::iterator iter_path = (*iter_rings)->_path.begin();
while(iter_path != (*iter_rings)->_path.end())
{
pAtom = pMolecule->GetAtom((*iter_path));
if(pAtom)
{
if(6 != pAtom->GetAtomicNum())
{
bHomoCyclic = false;
break;
}
}
iter_path++;
}
if(!bHomoCyclic) break;
iter_rings++;
}
ConvertBool(bHomoCyclic, refValue);
}
else if(!refTo.compare("MOLECULE_HAS_HETEROCYCLIC_RING"))
{
std::vector<OpenBabel::OBRing*>& refSSSR = pMolecule->GetSSSR();
std::vector<OpenBabel::OBRing*>::iterator iter_rings = refSSSR.begin();
OpenBabel::OBAtom* pAtom;
bool bHeteroCyclic = false;
while(iter_rings != refSSSR.end())
{
std::vector<int>::iterator iter_path = (*iter_rings)->_path.begin();
while(iter_path != (*iter_rings)->_path.end())
{
pAtom = pMolecule->GetAtom((*iter_path));
if(pAtom)
{
if(6 != pAtom->GetAtomicNum())
{
bHeteroCyclic = true;
break;
}
}
iter_path++;
}
if(bHeteroCyclic) break;
iter_rings++;
}
ConvertBool(bHeteroCyclic, refValue);
}
else
{
// [rad] maybe it's a descriptor?
if(SatisfyDescriptor(pMolecule, refTo, refValue))
{
return(true);
}
// [rad] unknown datatype?
refValue = "";
return(false);
}
return(true);
}
示例11: extract_thermo
static int extract_thermo(OpenBabel::OBMol *mol,string method,double temperature,
double ezpe,double Hcorr,double Gcorr,double E0,double CV,
int RotSymNum,std::vector<double> Scomponents)
{
// Initiate correction database
OpenBabel::OBAtomicHeatOfFormationTable *ahof = new OpenBabel::OBAtomicHeatOfFormationTable();
OpenBabel::OBAtomIterator OBai;
OpenBabel::OBAtom *OBa;
OpenBabel::OBElementTable *OBet;
char valbuf[128];
int ii,atomid,atomicnumber,found,foundall;
double dhofM0, dhofMT, S0MT, DeltaSMT;
double eFactor = HARTEE_TO_KCALPERMOL;
OBet = new OpenBabel::OBElementTable();
// Now loop over atoms in order to correct the Delta H formation
OBai = mol->BeginAtoms();
atomid = 0;
foundall = 0;
dhofM0 = E0*eFactor;
dhofMT = dhofM0+(Hcorr-ezpe)*eFactor;
S0MT = 0;
if (temperature > 0)
{
// Multiply by 1000 to make the unit cal/mol K
S0MT += 1000*eFactor*(Hcorr-Gcorr)/temperature;
}
// Check for symmetry
OBPointGroup obPG;
obPG.Setup(mol);
const char *pg = obPG.IdentifyPointGroup();
double Rgas = 1.9872041; // cal/mol K http://en.wikipedia.org/wiki/Gas_constant
double Srot = -Rgas * log(RotSymNum);
//printf("DHf(M,0) = %g, DHf(M,T) = %g, S0(M,T) = %g\nPoint group = %s RotSymNum = %d Srot = %g\n",
// dhofM0, dhofMT, S0MT, pg, RotSymNum, Srot);
if (RotSymNum > 1)
{
// We assume Gaussian has done this correctly!
Srot = 0;
}
S0MT += Srot;
DeltaSMT = S0MT;
for (OBa = mol->BeginAtom(OBai); (NULL != OBa); OBa = mol->NextAtom(OBai))
{
double dhfx0, dhfxT, S0xT;
atomicnumber = OBa->GetAtomicNum();
found = ahof->GetHeatOfFormation(OBet->GetSymbol(atomicnumber),
0,
method,
temperature,
&dhfx0, &dhfxT, &S0xT);
if (1 == found)
{
dhofM0 += dhfx0;
dhofMT += dhfxT;
DeltaSMT += S0xT;
foundall ++;
}
atomid++;
}
if (foundall == atomid)
{
std::string attr[5];
double result[5];
char buf[32];
attr[0].assign("DeltaHform(0K)");
result[0] = dhofM0;
snprintf(buf, sizeof(buf), "DeltaHform(%gK)", temperature);
attr[1].assign(buf);
result[1] = dhofMT;
snprintf(buf, sizeof(buf), "DeltaSform(%gK)", temperature);
attr[2].assign(buf);
result[2] = DeltaSMT;
snprintf(buf, sizeof(buf), "DeltaGform(%gK)", temperature);
attr[3].assign(buf);
result[3] = dhofMT - temperature*result[2]/1000;
snprintf(buf, sizeof(buf), "S0(%gK)", temperature);
attr[4].assign(buf);
result[4] = S0MT;
add_unique_pairdata_to_mol(mol, "method", method, 0);
for(ii=0; (ii<5); ii++)
{
// Add to molecule properties
sprintf(valbuf,"%f", result[ii]);
add_unique_pairdata_to_mol(mol, attr[ii], valbuf, 0);
}
sprintf(valbuf, "%f", CV);
add_unique_pairdata_to_mol(mol, "cv", valbuf, 0);
sprintf(valbuf, "%f", CV+Rgas);
add_unique_pairdata_to_mol(mol, "cp", valbuf, 0);
// Entropy components
if (Scomponents.size() == 3)
//.........这里部分代码省略.........