本文整理汇总了C++中OBMol::GetAtom方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::GetAtom方法的具体用法?C++ OBMol::GetAtom怎么用?C++ OBMol::GetAtom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::GetAtom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsGood
bool OBStericConformerFilter::IsGood(const OBMol &mol, const RotorKey &key, double *conformer)
{
unsigned int numAtoms = mol.NumAtoms();
for (unsigned int a1 = 0; a1 < numAtoms; ++a1) {
for (unsigned int a2 = 0; a2 < numAtoms; ++a2) {
// skip the pair if the atoms are the same
// also, only check each pair once
if (a1 <= a2)
continue;
OBAtom *atom1 = mol.GetAtom(a1+1);
OBAtom *atom2 = mol.GetAtom(a2+1);
if (atom1->IsHydrogen())
continue;
if (atom2->IsHydrogen())
continue;
// skip connected atoms
if (mol.GetAtom(a1+1)->IsConnected(mol.GetAtom(a2+1)))
continue;
// compute the distance
double dx = conformer[a1*3 ] - conformer[a2*3 ];
double dy = conformer[a1*3+1] - conformer[a2*3+1];
double dz = conformer[a1*3+2] - conformer[a2*3+2];
double distance = sqrt(dx*dx + dy*dy + dz*dz);
// check distance
if (distance < m_cutoff)
return false;
}
}
return true;
}
示例2: GetRootAtom
unsigned int OBRing::GetRootAtom()
{
vector<int>::iterator i;
OBMol *mol = (OBMol*)GetParent();
//if (!IsAromatic())
// return 0;
if (Size() == 6)
for (i = _path.begin();i != _path.end();++i)
if (!(mol->GetAtom(*i))->IsCarbon())
return (*i);
if (Size() == 5)
for (i = _path.begin();i != _path.end();++i) {
OBAtom *atom = mol->GetAtom(*i);
if (atom->IsSulfur() && (atom->GetValence() == 2))
return (*i);
if (atom->IsOxygen() && (atom->GetValence() == 2))
return (*i);
if (atom->IsNitrogen() && (atom->BOSum() == atom->GetValence()))
return (*i);
}
return 0;
}
示例3: GetRootAtom
unsigned int OBRing::GetRootAtom()
{
vector<int>::iterator i;
OBMol *mol = (OBMol*)GetParent();
//if (!IsAromatic())
// return 0;
if (Size() == 6)
for (i = _path.begin();i != _path.end();++i)
if (mol->GetAtom(*i)->GetAtomicNum() != OBElements::Carbon)
return (*i);
if (Size() == 5)
for (i = _path.begin();i != _path.end();++i) {
OBAtom *atom = mol->GetAtom(*i);
switch (atom->GetAtomicNum()) {
case OBElements::Sulfur:
if (atom->GetValence() == 2)
return (*i);
break;
case OBElements::Oxygen:
if (atom->GetValence() == 2)
return (*i);
break;
case OBElements::Nitrogen:
if (atom->BOSum() == atom->GetValence())
return (*i);
break;
}
}
return 0;
}
示例4: memset
static unsigned int FindRingAtomsAndBonds2(OBMol &mol)
{
mol.SetRingAtomsAndBondsPerceived(); // mol.SetFlag(OB_RINGFLAGS_MOL);
mol.SetClosureBondsPerceived(); // mol.SetFlag(OB_CLOSURE_MOL);
unsigned int bsize = mol.NumBonds()+1;
unsigned char *bvisit = (unsigned char*)malloc(bsize);
memset(bvisit,0,bsize);
unsigned int acount = mol.NumAtoms();
unsigned int asize = (unsigned int)((acount+1)*sizeof(int));
int *avisit = (int*)malloc(asize);
memset(avisit,0,asize);
unsigned int frj = 0;
for(unsigned int i=1; i<=acount; i++ )
if(avisit[i] == 0) {
avisit[i] = 1;
OBAtom *atom = mol.GetAtom(i);
FindRings(atom,avisit,bvisit,frj,1);
}
free(avisit);
free(bvisit);
return frj;
}
示例5: WriteXYZ
bool WriteXYZ(ostream &ofs,OBMol &mol)
{
unsigned int i;
char buffer[BUFF_SIZE];
sprintf(buffer,"%d", mol.NumAtoms());
ofs << buffer << endl;
sprintf(buffer,"%s\tEnergy: %15.7f", mol.GetTitle(), mol.GetEnergy());
ofs << buffer << endl;
OBAtom *atom;
string str,str1;
for(i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
sprintf(buffer,"%3s%15.5f%15.5f%15.5f",
etab.GetSymbol(atom->GetAtomicNum()),
atom->GetX(),
atom->GetY(),
atom->GetZ());
ofs << buffer << endl;
}
return(true);
}
示例6: WriteViewMol
bool WriteViewMol(ostream &ofs,OBMol &mol)
{
unsigned int i;
char buffer[BUFF_SIZE];
if (strlen(mol.GetTitle()) > 0)
ofs << "$title" << endl << mol.GetTitle() << endl;
ofs << "$coord 1.0" << endl;
OBAtom *atom;
for(i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
sprintf(buffer,"%22.14f%22.14f%22.14f %s",
atom->GetX(),
atom->GetY(),
atom->GetZ(),
etab.GetSymbol(atom->GetAtomicNum()));
ofs << buffer << endl;
}
ofs << "$end" << endl;
return(true);
}
示例7: removeAndScore
float ColoredMol::removeAndScore(std::vector<bool> removeList, bool isRec)
{
std::string molString;
OBMol mol;
if(isRec)
{
molString = hRec;
mol = hRecMol;
}
else
{
molString = hLig;
mol = hLigMol;
}
if(!(isRec)) //if ligand
{
OBAtom* atom;
for(int i = 0;i < removeList.size(); ++i)
{
if (removeList[i]) //index is in removeList
{
atom = mol.GetAtom(i);
FOR_NBORS_OF_ATOM(neighbor, atom)
{
if(neighbor->GetAtomicNum() == 1)
{
//std::cout << "adding: " << neighbor->GetIdx() << '\n';
removeList[neighbor->GetIdx()] = true;
}
}
}
}
}
示例8: getIdRingPaths
std::vector< std::vector<unsigned long> > getIdRingPaths(OBMol &mol)
{
mol.UnsetFlag(OB_LSSR_MOL);
mol.DeleteData("LSSR");
std::vector<OBRing*> lssr = mol.GetLSSR();
std::vector< std::vector<unsigned long> > idPaths;
for (unsigned int i = 0; i < lssr.size(); ++i) {
OBRing *ring = lssr[i];
std::vector<unsigned long> idPath;
for (unsigned int j = 0; j < ring->_path.size(); ++j) {
idPath.push_back(mol.GetAtom(ring->_path[j])->GetId());
}
std::sort(idPath.begin(), idPath.end());
idPaths.push_back(idPath);
}
/*
cout << "# idPaths = " << idPaths.size() << endl;
for (unsigned int i = 0; i < idPaths.size(); ++i) {
cout << " ring: ";
for (unsigned int j = 0; j < idPaths[i].size(); ++j) {
cout << idPaths[i][j] << " ";
}
cout << endl;
}
*/
return idPaths;
}
示例9: AssignHyb
void OBAtomTyper::AssignHyb(OBMol &mol)
{
if (!_init)
Init();
aromtyper.AssignAromaticFlags(mol);
mol.SetHybridizationPerceived();
obErrorLog.ThrowError(__FUNCTION__,
"Ran OpenBabel::AssignHybridization", obAuditMsg);
OBAtom *atom;
vector<OBAtom*>::iterator k;
for (atom = mol.BeginAtom(k);atom;atom = mol.NextAtom(k))
atom->SetHyb(0);
vector<vector<int> >::iterator j;
vector<pair<OBSmartsPattern*,int> >::iterator i;
for (i = _vinthyb.begin();i != _vinthyb.end();++i)
if (i->first->Match(mol))
{
_mlist = i->first->GetMapList();
for (j = _mlist.begin();j != _mlist.end();++j)
mol.GetAtom((*j)[0])->SetHyb(i->second);
}
}
示例10: generateCovarMatrixFromMolecule
void generateCovarMatrixFromMolecule(vector<double> &matrix, OBMol &molecule) {
double uX = 0, uY = 0, uZ = 0, *moleculeCoords = molecule.GetCoordinates();
for (unsigned int i=0; i < 3 * molecule.NumAtoms(); i+=3) {
uX += moleculeCoords[i];
uY += moleculeCoords[i+1];
uZ += moleculeCoords[i+2];
}
uX /= molecule.NumAtoms();
uY /= molecule.NumAtoms();
uZ /= molecule.NumAtoms();
double cXX = 0, cYY = 0, cZZ = 0, cXY = 0, cXZ = 0, cYZ = 0;
for (unsigned int i=0; i < 3 * molecule.NumAtoms(); i+=3) {
double atomWeight = molecule.GetAtom(i/3 + 1)->GetAtomicMass(); // getAtoms is 1-based instead of 0-based
cXX += pow(moleculeCoords[i] - uX, 2) * atomWeight;
cYY += pow(moleculeCoords[i+1] - uY, 2) * atomWeight;
cZZ += pow(moleculeCoords[i+2] - uZ, 2) * atomWeight;
cXY += (moleculeCoords[i] - uX) * (moleculeCoords[i+1] - uY) * atomWeight;
cXZ += (moleculeCoords[i] - uX) * (moleculeCoords[i+2] - uZ) * atomWeight;
cYZ += (moleculeCoords[i+1] - uY) * (moleculeCoords[i+2] - uZ) * atomWeight;
}
matrix.clear();
matrix.resize(9);
matrix[0] = cXX;
matrix[1] = matrix[3] = cXY;
matrix[2] = matrix[6] = cXZ;
matrix[4] = cYY;
matrix[5] = matrix[7] = cYZ;
matrix[8] = cZZ;
for (unsigned int i=0; i < matrix.size(); i++) matrix[i] /= molecule.GetMolWt();
}
示例11: turnMolMT
void turnMolMT(OBMol& mol,vector< vector <int> >& maplist,int k)
{
if (k<0)
return;
if (k>=maplist.size())
return;
OBAtom *a1, *a2, *a3, *a4;
pthread_t threadList[angleSum];
for (int i=0;i<angleSum;++i) {
pthread_create(threadList+i,NULL,turnMolSingle,new MolData(mol,maplist,k-1));
a2 = mol.GetAtom(maplist[k][0]);
a3 = mol.GetAtom(maplist[k][1]);
std::vector<OBEdgeBase*>::iterator temp = a2->BeginBonds();
a1 = a2->BeginNbrAtom(temp);
if (a1==a3)
a1 = a2->NextNbrAtom(temp);
temp = a3->BeginBonds();
a4 = a3->BeginNbrAtom(temp);
if (a4==a2)
a4 = a3->NextNbrAtom(temp);
mol.SetTorsion(a1, a2, a3, a4, i * angle * DEG_TO_RAD);
}
for (int i=0;i<angleSum;++i) {
pthread_join(threadList[i],NULL);
}
}
示例12: SetLength
void OBBond::SetLength(OBAtom *fixed, double length)
{
unsigned int i;
OBMol *mol = (OBMol*)fixed->GetParent();
vector3 v1,v2,v3,v4,v5;
vector<int> children;
obErrorLog.ThrowError(__FUNCTION__,
"Ran OpenBabel::SetBondLength", obAuditMsg);
int a = fixed->GetIdx();
int b = GetNbrAtom(fixed)->GetIdx();
if (a == b)
return; // this would be a problem...
mol->FindChildren(children,a,b);
children.push_back(b);
v1 = GetNbrAtom(fixed)->GetVector();
v2 = fixed->GetVector();
v3 = v1 - v2;
if (IsNearZero(v3.length_2())) { // too small to normalize, move the atoms apart
obErrorLog.ThrowError(__FUNCTION__,
"Atoms are both at the same location, moving out of the way.", obWarning);
v3.randomUnitVector();
} else {
v3.normalize();
}
v3 *= length;
v3 += v2;
v4 = v3 - v1;
cerr << "v3: " << v3 << " v4: " << v4 << endl;
for ( i = 0 ; i < children.size() ; i++ )
{
v1 = mol->GetAtom(children[i])->GetVector();
v1 += v4;
mol->GetAtom(children[i])->SetVector(v1);
}
}
示例13: WriteAngles
void ReportFormat::WriteAngles(ostream &ofs,OBMol &mol)
{
OBAtom *a, *b, *c;
char buffer[BUFF_SIZE];
double ang;
FOR_ANGLES_OF_MOL(angle, mol)
{
b = mol.GetAtom((*angle)[0] + 1);
a = mol.GetAtom((*angle)[1] + 1);
c = mol.GetAtom((*angle)[2] + 1);
ang = a->GetAngle(b->GetIdx(), c->GetIdx());
snprintf(buffer, BUFF_SIZE, "%4d %4d %4d %4s %4s %4s %10.3f",
a->GetIdx(),b->GetIdx(),c->GetIdx(),
a->GetType(),b->GetType(),c->GetType(),
ang);
ofs << buffer << "\n";
}
示例14: IsAromatic
bool OBRing::IsAromatic()
{
OBMol *mol = _parent;
vector<int>::iterator i;
for (i = _path.begin();i != _path.end();++i)
if (!(mol->GetAtom(*i))->IsAromatic())
return(false);
return(true);
}
示例15: UpdateCoordinates
bool OBForceField::UpdateCoordinates(OBMol &mol)
{
OBAtom *atom;
if (_mol.NumAtoms() != mol.NumAtoms())
return false;
// Copy coordinates for current conformer only
FOR_ATOMS_OF_MOL (a, _mol) {
atom = mol.GetAtom(a->GetIdx());
atom->SetVector(a->GetVector());
}