本文整理汇总了C++中OBMol::FindChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::FindChildren方法的具体用法?C++ OBMol::FindChildren怎么用?C++ OBMol::FindChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::FindChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: Setup
void OBRotamerList::Setup(OBMol &mol,OBRotorList &rl)
{
//clear the old stuff out if necessary
_vres.clear();
vector<unsigned char*>::iterator j;
for (j = _vrotamer.begin();j != _vrotamer.end();++j)
delete [] *j;
_vrotamer.clear();
vector<pair<OBAtom**,vector<int> > >::iterator k;
for (k = _vrotor.begin();k != _vrotor.end();++k)
delete [] k->first;
_vrotor.clear();
_vrings.clear();
_vringTors.clear();
//create the new list
OBRotor *rotor;
vector<OBRotor*>::iterator i;
vector<int> children;
int ref[4];
OBAtom **atomlist;
for (rotor = rl.BeginRotor(i);rotor;rotor = rl.NextRotor(i))
{
atomlist = new OBAtom* [4];
rotor->GetDihedralAtoms(ref);
atomlist[0] = mol.GetAtom(ref[0]);
atomlist[1] = mol.GetAtom(ref[1]);
atomlist[2] = mol.GetAtom(ref[2]);
atomlist[3] = mol.GetAtom(ref[3]);
mol.FindChildren(children,ref[1],ref[2]);
_vrotor.push_back(pair<OBAtom**,vector<int> > (atomlist,children));
_vres.push_back(rotor->GetResolution());
}
// if the rotor list has ring bonds, build up an index
if (rl.HasRingRotors()){
// go through rings
// for each step of the path, see if there's a matching rotor
vector<int> path;
int pSize;
vector<double> ringTorsions;
vector<int> ringRotors;
FOR_RINGS_OF_MOL(r, mol)
{
ringTorsions.clear();
ringRotors.clear();
pSize = r->Size();
if (pSize < 4)
continue; // not rotatable
path = r->_path;
for (int j = 0; j < pSize; ++j) {
double torsion = mol.GetTorsion(path[(j + pSize - 1) % pSize],
path[(j + pSize) % pSize],
path[(j + pSize + 1) % pSize],
path[(j + pSize + 2) % pSize]);
ringTorsions.push_back(torsion);
// now check to see if any of these things are rotors
int rotorIndex = -1; // not a rotor
OBBond *bond = mol.GetBond(path[(j + pSize) % pSize], path[(j + pSize + 1) % pSize]);
for (rotor = rl.BeginRotor(i);rotor;rotor = rl.NextRotor(i))
{
if (bond != rotor->GetBond())
continue; // no match at all
// Central bond matches, make sure 1..4 atoms are in the path
rotor->GetDihedralAtoms(ref);
if ( (ref[0] == path[(j + pSize - 1) % pSize] &&
ref[3] == path[(j + pSize + 2) % pSize])
||
(ref[3] == path[(j + pSize - 1) % pSize] &&
ref[0] == path[(j + pSize + 2) % pSize]) ) {
rotorIndex = rotor->GetIdx();
}
} // end checking all the rotors
ringRotors.push_back(rotorIndex); // could be -1 if it's not rotatable
}
_vringTors.push_back(ringTorsions);
_vrings.push_back(ringRotors);
} // finished with the rings