本文整理汇总了C++中OBAtom::GetIdx方法的典型用法代码示例。如果您正苦于以下问题:C++ OBAtom::GetIdx方法的具体用法?C++ OBAtom::GetIdx怎么用?C++ OBAtom::GetIdx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBAtom
的用法示例。
在下文中一共展示了OBAtom::GetIdx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
OBMolPairIter::OBMolPairIter(OBMol &mol)
{
_parent = &mol;
bool foundPair = false;
OBAtom *a = _parent->BeginAtom(_i);
if (!a)
return;
OBAtom *b = _parent->BeginAtom(_j);
while (!foundPair) {
b = _parent->NextAtom(_j);
if (!b) {
a = _parent->NextAtom(_i);
if (!a)
return;
b = _parent->BeginAtom(_j);
}
if (a->GetIdx() >= b->GetIdx()) continue;
if (a->IsConnected(b)) continue;
if (a->IsOneThree(b)) continue;
foundPair = true;
}
_pair.clear();
_pair.push_back(a->GetIdx());
_pair.push_back(b->GetIdx());
}
示例2:
OBMolAtomDFSIter& OBMolAtomDFSIter::operator++()
{
if (!_stack.empty())
{
_ptr = _stack.top();
_stack.pop();
}
else // are there any disconnected subgraphs?
{
int next = _notVisited.FirstBit();
if (next != _notVisited.EndBit())
{
_ptr = _parent->GetAtom(next + 1);
_notVisited.SetBitOff(next);
}
else
_ptr = NULL;
}
if (_ptr)
{
vector<OBBond*>::iterator i;
OBAtom *a;
for (a = _ptr->BeginNbrAtom(i); a; a = _ptr->NextNbrAtom(i))
if (_notVisited[a->GetIdx() - 1])
{
_stack.push(a);
_notVisited.SetBitOff(a->GetIdx() - 1);
}
}
return *this;
}
示例3: GetChirality
// Seems to make a vector chirality become filled with array of +/- 1 for chiral atoms.
void GetChirality(OBMol &mol, std::vector<int> &chirality)
{
chirality.resize(mol.NumAtoms()+1);
fill(chirality.begin(),chirality.end(),0);
OBAtom *atom;
vector<OBAtom*>::iterator i;
for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
if (atom->IsChiral())
{
if (!atom->HasChiralVolume())
{
double sv = CalcSignedVolume(mol,atom);
if (sv < 0.0)
{
chirality[atom->GetIdx()-1] = -1;
atom->SetNegativeStereo();
}
else if (sv > 0.0)
{
chirality[atom->GetIdx()-1] = 1;
atom->SetPositiveStereo();
}
}
else // already calculated signed volume (e.g., imported from somewhere)
{
if (atom ->IsPositiveStereo())
chirality[atom->GetIdx()-1] = 1;
else
chirality[atom->GetIdx()-1] = -1;
}
}
}
示例4: WriteGromos96
bool WriteGromos96(ostream &ofs,OBMol &mol,double fac)
{
char type_name[10];
char res_name[10],padded_name[10];
char buffer[BUFF_SIZE];
int res_num;
sprintf(buffer,"#GENERATED BY OPEN BABEL %s",BABEL_VERSION);
ofs << buffer << endl;
/* GROMOS wants a TITLE block, so let's write one*/
sprintf(buffer,"TITLE\n%s\nEND",mol.GetTitle());
ofs << buffer << endl;
ofs << "POSITION" << endl;
OBAtom *atom;
OBResidue *res;
vector<OBNodeBase*>::iterator i;
for(atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
{
if (res = atom->GetResidue())
{
strcpy(res_name,(char*)res->GetName().c_str());
strcpy(type_name,(char*)res->GetAtomID(atom).c_str());
res_num = res->GetNum();
}
else
{
strcpy(type_name,etab.GetSymbol(atom->GetAtomicNum()));
strcpy(res_name,"UNK");
sprintf(padded_name,"%2s",type_name);
strcpy(type_name,padded_name);
res_num = 1;
}
sprintf(buffer,"%5d %5s %5s %6d %15.5f %15.5f %15.5f",
res_num,res_name,type_name,atom->GetIdx(),
atom->x()*fac,atom->y()*fac,atom->z()*fac);
ofs << buffer << endl;
if (!(atom->GetIdx()%10))
{
sprintf(buffer,"# %d",atom->GetIdx());
ofs << buffer << endl;
}
}
ofs << "END" << endl;
return(true);
}
示例5: AddAtomLabels
bool OBDepict::AddAtomLabels(AtomLabelType type)
{
d->painter->SetPenColor(OBColor("red"));
d->painter->SetFillColor(OBColor("red"));
d->painter->SetFontSize((int)(GetFontSize() * 0.8));// smaller text
OBAtomIterator i;
for (OBAtom *atom = d->mol->BeginAtom(i); atom; atom = d->mol->NextAtom(i)) {
vector3 pos(atom->GetVector());
std::stringstream ss;
switch (type) {
case AtomId:
ss << atom->GetId();
d->painter->DrawText(pos.x(), pos.y(), ss.str());
break;
case AtomSymmetryClass:
ss << GetAtomSymClass(atom);
d->painter->DrawText(pos.x(), pos.y(), ss.str());
break;
case AtomIndex:
ss << atom->GetIdx();
d->painter->DrawText(pos.x(), pos.y(), ss.str());
break;
default:
break;
}
}
return true;
}
示例6:
void fingerprint2::getFragments(vector<int> levels, vector<int> curfrag,
int level, OBAtom* patom, OBBond* pbond)
{
//Recursive routine to analyse schemical structure and populate fragset and ringset
//Hydrogens,charges(except dative bonds), spinMultiplicity ignored
const int Max_Fragment_Size = 7;
int bo=0;
if(pbond)
{
bo = pbond->IsAromatic() ? 5 : pbond->GetBO();
// OBAtom* pprevat = pbond->GetNbrAtom(patom);
// if(patom->GetFormalCharge() && (patom->GetFormalCharge() == -pprevat->GetFormalCharge()))
// ++bo; //coordinate (dative) bond eg C[N+]([O-])=O is seen as CN(=O)=O
}
curfrag.push_back(bo);
curfrag.push_back(patom->GetAtomicNum());
levels[patom->GetIdx()-1] = level;
vector<OBEdgeBase*>::iterator itr;
OBBond *pnewbond;
// PrintFpt(curfrag,(int)patom);
for (pnewbond = patom->BeginBond(itr);pnewbond;pnewbond = patom->NextBond(itr))
{
if(pnewbond==pbond) continue; //don't retrace steps
OBAtom* pnxtat = pnewbond->GetNbrAtom(patom);
if(pnxtat->GetAtomicNum() == OBElements::Hydrogen) continue;
int atlevel = levels[pnxtat->GetIdx()-1];
if(atlevel) //ring
{
if(atlevel==1)
{
//If complete ring (last bond is back to starting atom) add bond at front
//and save in ringset
curfrag[0] = pnewbond->IsAromatic() ? 5 : pnewbond->GetBO();
ringset.insert(curfrag);
curfrag[0] = 0;
}
}
else //no ring
{
if(level<Max_Fragment_Size)
{
// TRACE("level=%d size=%d %p frag[0]=%p\n",level, curfrag.size(),&curfrag, &(curfrag[0]));
//Do the next atom; levels, curfrag are passed by value and hence copied
getFragments(levels, curfrag, level+1, pnxtat, pnewbond);
}
}
}
//do not save C,N,O single atom fragments
if(curfrag[0]==0 &&
(level>1 || patom->GetAtomicNum()>8 || patom->GetAtomicNum()<6))
{
fragset.insert(curfrag); //curfrag ignored if an identical fragment already present
// PrintFpt(curfrag,level);
}
}
示例7: ReadMolecule
bool BallStickFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)
{
OBMol* pmol = pOb->CastAndClear<OBMol>();
if(pmol==NULL)
return false;
//Define some references so we can use the old parameter names
istream &ifs = *pConv->GetInStream();
OBMol &mol = *pmol;
const char* title = pConv->GetTitle();
int i,natoms;
char buffer[BUFF_SIZE];
if (!ifs.getline(buffer,BUFF_SIZE))
return(false);
if (!ifs.getline(buffer,BUFF_SIZE))
return(false);
sscanf(buffer,"%d",&natoms);
mol.ReserveAtoms(natoms);
mol.BeginModify();
double x,y,z;
OBAtom *atom;
vector<string> vs;
vector<string>::iterator j;
for (i = 1; i <= natoms;i ++)
{
if (!ifs.getline(buffer,BUFF_SIZE))
return(false);
tokenize(vs,buffer);
if (vs.size() < 4)
return(false);
if (vs[0].size() > 1)
vs[0][1] = tolower(vs[0][1]);
atom = mol.NewAtom();
x = atof((char*)vs[1].c_str());
y = atof((char*)vs[2].c_str());
z = atof((char*)vs[3].c_str());
atom->SetVector(x,y,z); //set coordinates
atom->SetAtomicNum(etab.GetAtomicNum(vs[0].c_str()));
for (j = vs.begin()+4;j != vs.end();j++)
mol.AddBond(atom->GetIdx(),atoi((char*)j->c_str()),1);
}
// clean out any remaining blank lines
while(ifs.peek() != EOF && ifs.good() &&
(ifs.peek() == '\n' || ifs.peek() == '\r'))
ifs.getline(buffer,BUFF_SIZE);
mol.EndModify();
mol.SetTitle(title);
return(true);
}
示例8: PropagatePotentialAromatic
void OBAromaticTyper::PropagatePotentialAromatic(OBAtom *atom)
{
int count = 0;
OBAtom *nbr;
vector<OBBond*>::iterator i;
for (nbr = atom->BeginNbrAtom(i);nbr;nbr = atom->NextNbrAtom(i))
if ((*i)->IsInRing() && _vpa[nbr->GetIdx()])
count++;
if (count < 2)
{
_vpa[atom->GetIdx()] = false;
if (count == 1)
for (nbr = atom->BeginNbrAtom(i);nbr;nbr = atom->NextNbrAtom(i))
if ((*i)->IsInRing() && _vpa[nbr->GetIdx()])
PropagatePotentialAromatic(nbr);
}
}
示例9: GenerateRingReference
void GenerateRingReference()
{
std::ifstream ifs;
if (!SafeOpen(ifs,"attype.00.smi")) return;
std::ofstream ofs;
if (!SafeOpen(ofs,"ringresults.txt")) return;
int count;
OBAtom *atom;
OBBond *bond;
char buffer[BUFF_SIZE];
vector<OBRing*> vr;
vector<OBEdgeBase*>::iterator i;
vector<OBNodeBase*>::iterator j;
vector<OBRing*>::iterator k;
OBMol mol(SMI,SMI);
OBFileFormat ff;
for (;ifs;)
{
mol.Clear();
ff.ReadMolecule(ifs, mol);
if (mol.Empty()) continue;
//write out ring bonds
for (bond = mol.BeginBond(i);bond;bond = mol.NextBond(i))
if (bond->IsInRing())
{
sprintf(buffer,"%3d",bond->GetIdx());
ofs << buffer;
}
ofs << endl;
vr = mol.GetSSSR();
//write the total number of rings
ofs << vr.size() << endl;
//write the number of rings that each atom is a member of
for (atom = mol.BeginAtom(j);atom;atom = mol.NextAtom(j))
{
count = 0;
for (k = vr.begin();k != vr.end();k++)
if ((*k)->_pathset[atom->GetIdx()])
count++;
sprintf(buffer,"%3d",count);
ofs << buffer;
}
ofs << endl;
}
ThrowError("Ring perception test results written successfully");
}
示例10: EndElement
bool ChemDrawXMLFormat::EndElement(const string& name)
{
//unsigned int i;
if(name=="n")
{
_pmol->AddAtom(_tempAtom);
atoms[_tempAtom.GetIdx()] = _pmol->NumAtoms();
_tempAtom.Clear();
}
else if(name=="b")
{
_pmol->AddBond(Begin, End, Order, Flag);
Order = -1;
}
else if(name=="fragment") //this is the end of the molecule we are extracting
{
EnsureEndElement();
_pmol->EndModify();
// This alone will already store the "Formula" property in the molecule property block
// The "Formula" is required for older ChemDraw generations allowing to match molecules to reaction properties
string MolFormula=_pmol->GetFormula();
// additional adding of "Formula" property is not required, as described above
//OBPairData *dp = new OBPairData;
//dp->SetAttribute("MolecularFormula");
//dp->SetValue(MolFormula);
//dp->SetOrigin(fileformatInput);
//_pmol->SetData(dp);
// alternative is using the molecular title, but a test is needed for preventing overwriting given titles, aka molecule ID
//_pmol->SetTitle(MolFormula);
atoms.clear();
return false;//means stop parsing
}
/*
// Forget that, the fragment, aka molecule, is in another XML hierachy tree than the data.
// Parsing has already stopped before ever getting to this point
else if(name=="tags")
{
}
else if(name=="tableCell")
{
//OBPairData *dp = new OBPairData;
//dp->SetAttribute(attr);
//dp->SetValue(buff);
//dp->SetOrigin(fileformatInput);
//mol.SetData(dp);
}*/
return true;
}
示例11: BuildOBRTreeVector
void BuildOBRTreeVector(OBAtom *atom,OBRTree *prv,vector<OBRTree*> &vt,OBBitVec &bv)
{
vt[atom->GetIdx()] = new OBRTree (atom,prv);
int i;
OBAtom *nbr;
OBMol *mol = (OBMol*)atom->GetParent();
OBBitVec curr,used,next;
vector<OBBond*>::iterator j;
curr |= atom->GetIdx();
used = bv|curr;
#define OB_RTREE_CUTOFF 20
int level=0;
for (;;)
{
next.Clear();
for (i = curr.NextBit(0);i != bv.EndBit();i = curr.NextBit(i))
{
atom = mol->GetAtom(i);
for (nbr = atom->BeginNbrAtom(j);nbr;nbr = atom->NextNbrAtom(j))
if (!used[nbr->GetIdx()])
{
next |= nbr->GetIdx();
used |= nbr->GetIdx();
vt[nbr->GetIdx()] = new OBRTree (nbr,vt[atom->GetIdx()]);
}
}
if (next.Empty())
break;
curr = next;
level++;
if (level > OB_RTREE_CUTOFF)
break;
}
#undef OB_RTREE_CUTOFF
}
示例12: EnsureEndElement
void ChemDrawXMLFormat::EnsureEndElement(void)
{
if (_tempAtom.GetAtomicNum() != 0)
{
_pmol->AddAtom(_tempAtom);
atoms[_tempAtom.GetIdx()] = _pmol->NumAtoms();
_tempAtom.Clear();
}
else if (Order >= 0)
{
_pmol->AddBond(Begin, End, Order, Flag);
Order = -1;
}
}
示例13:
OBMolAtomDFSIter::OBMolAtomDFSIter(OBMol *mol, int StartIndex):
_parent(mol), _ptr(_parent->GetAtom(StartIndex))
{
_notVisited.Resize(_parent->NumAtoms());
_notVisited.SetRangeOn(0, _parent->NumAtoms() - 1);
if (!_ptr) return;
_notVisited.SetBitOff(_ptr->GetIdx() - 1);
vector<OBBond*>::iterator i;
OBAtom *a;
for (a = _ptr->BeginNbrAtom(i); a; a = _ptr->NextNbrAtom(i))
{
_stack.push(a);
_notVisited.SetBitOff(a->GetIdx() - 1);
}
}
示例14: TraverseCycle
/** \brief Traverse a potentially aromatic cycle starting at @p root.
\return True if the cycle is likely aromatic
\param root The initial, "root" atom in traversing this ring
\param atom The current atom to visit and check
\param prev The bond traversed in moving to this @p atom
\param er The min and max number of pi electrons for this ring
\param depth The maximum number of atoms to visit in a ring (e.g., 6)
This method traverses a potentially aromatic ring, adding up the possible
pi electrons for each atom. At the end (e.g., when @p atom == @p root)
the Huekel 4n+2 rule is checked to see if there is a possible electronic
configuration which corresponds to aromaticity.
**/
bool OBAromaticTyper::TraverseCycle(OBAtom *root, OBAtom *atom, OBBond *prev,
std::pair<int,int> &er,int depth)
{
if (atom == root)
{
int i;
for (i = er.first;i <= er.second;++i)
if (i%4 == 2 && i > 2)
return(true);
return(false);
}
if (!depth || !_vpa[atom->GetIdx()] || _visit[atom->GetIdx()])
return(false);
bool result = false;
depth--;
er.first += _velec[atom->GetIdx()].first;
er.second += _velec[atom->GetIdx()].second;
_visit[atom->GetIdx()] = true;
OBAtom *nbr;
vector<OBBond*>::iterator i;
for (nbr = atom->BeginNbrAtom(i);nbr;nbr = atom->NextNbrAtom(i))
if (*i != prev && (*i)->IsInRing() && _vpa[nbr->GetIdx()])
{
if (TraverseCycle(root,nbr,(OBBond*)(*i),er,depth))
{
result = true;
((OBBond*) *i)->SetAromatic();
}
}
_visit[atom->GetIdx()] = false;
if (result)
atom->SetAromatic();
er.first -= _velec[atom->GetIdx()].first;
er.second -= _velec[atom->GetIdx()].second;
return(result);
}
示例15: WriteChiral
void WriteChiral(ostream &ofs,OBMol &mol)
{
OBAtom *atom;
vector<OBNodeBase*>::iterator i;
char buffer[BUFF_SIZE];
for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
{
if (atom->IsChiral())
{
sprintf(buffer,"%4s %5d is chiral: %s",
etab.GetSymbol(atom->GetAtomicNum()),
atom->GetIdx(),
(atom->IsClockwise() ? "clockwise" : "counterclockwise"));
ofs << buffer << endl;
}
}
}