本文整理汇总了C++中OBAtom::GetAtomicNum方法的典型用法代码示例。如果您正苦于以下问题:C++ OBAtom::GetAtomicNum方法的具体用法?C++ OBAtom::GetAtomicNum怎么用?C++ OBAtom::GetAtomicNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBAtom
的用法示例。
在下文中一共展示了OBAtom::GetAtomicNum方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: WriteMolecule
bool PQSFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv)
{
OBMol* pmol = dynamic_cast<OBMol*>(pOb);
if(pmol==NULL)
return false;
//Define some references so we can use the old parameter names
ostream &ofs = *pConv->GetOutStream();
OBMol &mol = *pmol;
unsigned int i;
char buffer[BUFF_SIZE];
OBAtom *atom;
ofs<<"TEXT="<<mol.GetTitle()<<endl;
ofs<<"GEOM=PQS"<<endl;
for (i=1; i<=mol.NumAtoms(); i++)
{
atom=mol.GetAtom(i);
snprintf(buffer, BUFF_SIZE, "%s %10.6lf %10.6lf %10.6lf",
OBElements::GetSymbol(atom->GetAtomicNum()),
atom->GetX(),
atom->GetY(),
atom->GetZ());
ofs<<buffer<<endl;
}
return(true);
}
示例3: 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);
}
示例4: WriteMolecule
bool TurbomoleFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv)
{
OBMol* pmol = dynamic_cast<OBMol*>(pOb);
if(pmol==NULL)
return false;
//Define some references so we can use the old parameter names
ostream &ofs = *pConv->GetOutStream();
OBMol &mol = *pmol;
double UnitConv=AAU;
if(pConv->IsOption("a"))
UnitConv=1;
ofs << "$coord" <<endl;
char buffer[BUFF_SIZE];
OBAtom *atom;
vector<OBAtom*>::iterator i;
for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
{
char symb[8];
strcpy(symb,OBElements::GetSymbol(atom->GetAtomicNum()));
snprintf(buffer, BUFF_SIZE, "%20.14f %20.14f %20.14f %s",
atom->GetX()/UnitConv,
atom->GetY()/UnitConv,
atom->GetZ()/UnitConv,
strlwr(symb) );
ofs << buffer << endl;
}
ofs << "$end" << endl;
return true;
}
示例5: 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;
}
示例6: WriteMolecule
bool JaguarInputFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv)
{
OBMol* pmol = dynamic_cast<OBMol*>(pOb);
if(pmol==NULL) return false;
//Define some references so we can use the old parameter names
ostream &ofs = *pConv->GetOutStream();
OBMol &mol = *pmol;
unsigned int i;
char buffer[BUFF_SIZE];
OBAtom *atom;
ofs << mol.GetTitle() << endl << endl;
ofs << "&gen" << endl;
ofs << "&" << endl;
ofs << "&zmat" << endl;
for (i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
snprintf(buffer, BUFF_SIZE, " %s%d %12.7f %12.7f %12.7f",
etab.GetSymbol(atom->GetAtomicNum()), i,
atom->GetX(),
atom->GetY(),
atom->GetZ());
ofs << buffer << endl;
}
ofs << "&" << endl;
return(true);
}
示例7:
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);
}
}
示例8: WriteMolFile
static void WriteMolFile(OBMol* pmol, OBConversion* pconv, OBFormat* pformat)
{
ostream &ofs = *pconv->GetOutStream();
ofs << "$MOL" << '\n';
// Treat a dummy atom with "rxndummy" as the empty file
if (pmol->NumAtoms() == 1) {
OBAtom *atm = pmol->GetFirstAtom();
if (atm->GetAtomicNum() == 0 && atm->HasData("rxndummy"))
pmol->DeleteAtom(atm);
}
pformat->WriteMolecule(pmol, pconv);
}
示例9: 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);
}
示例10: 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;
}
}
示例11: WriteCharges
void WriteCharges(ostream &ofs,OBMol &mol)
{
unsigned int i;
OBAtom *atom;
char buffer[BUFF_SIZE];
for(i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
sprintf(buffer,"%4s%4d % 2.10f",
etab.GetSymbol(atom->GetAtomicNum()),
i,
atom->GetPartialCharge());
ofs << buffer << endl;
}
}
示例12: WriteCharges
void ReportFormat::WriteCharges(ostream &ofs,OBMol &mol)
{
unsigned int i;
OBAtom *atom;
char buffer[BUFF_SIZE];
for(i = 1;i <= mol.NumAtoms(); i++)
{
atom = mol.GetAtom(i);
snprintf(buffer, BUFF_SIZE, "%4s%4d % 2.10f",
OBElements::GetSymbol(atom->GetAtomicNum()),
i,
atom->GetPartialCharge());
ofs << buffer << "\n";
}
}
示例13: 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;
}
}
}
示例14: WriteMolecule
bool CacaoFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv)
{
OBMol* pmol = dynamic_cast<OBMol*>(pOb);
if(pmol==NULL)
return false;
//Define some references so we can use the old parameter names
ostream &ofs = *pConv->GetOutStream();
OBMol &mol = *pmol;
OBAtom *atom;
char buffer[BUFF_SIZE];
vector<OBAtom*>::iterator i;
snprintf(buffer, BUFF_SIZE, "%s\n",mol.GetTitle());
ofs << buffer;
snprintf(buffer, BUFF_SIZE, "%3d DIST 0 0 0\n",mol.NumAtoms());
ofs << buffer;
if (!mol.HasData(OBGenericDataType::UnitCell))
ofs << "CELL 1.,1.,1.,90.,90.,90.\n";
else
{
OBUnitCell *uc = (OBUnitCell*)mol.GetData(OBGenericDataType::UnitCell);
snprintf(buffer, BUFF_SIZE, "CELL %f,%f,%f,%f,%f,%f\n",
uc->GetA(), uc->GetB(), uc->GetC(),
uc->GetAlpha(), uc->GetBeta(), uc->GetGamma());
ofs << buffer;
}
for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
{
snprintf(buffer,BUFF_SIZE,"%2s %7.4f, %7.4f, %7.4f\n",
etab.GetSymbol(atom->GetAtomicNum()),
atom->x(),
atom->y(),
atom->z());
ofs << buffer;
}
return(true);
}
示例15: levels
bool fingerprint2::GetFingerprint(OBBase* pOb, vector<unsigned int>&fp, int nbits)
{
OBMol* pmol = dynamic_cast<OBMol*>(pOb);
if(!pmol) return false;
fp.resize(1024/Getbitsperint());
fragset.clear();//needed because now only one instance of fp class
ringset.clear();
//identify fragments starting at every atom
OBAtom *patom;
vector<OBNodeBase*>::iterator i;
for (patom = pmol->BeginAtom(i);patom;patom = pmol->NextAtom(i))
{
if(patom->GetAtomicNum() == OBElements::Hydrogen) continue;
vector<int> curfrag;
vector<int> levels(pmol->NumAtoms());
getFragments(levels, curfrag, 1, patom, NULL);
}
// TRACE("%s %d frags before; ",pmol->GetTitle(),fragset.size());
//Ensure that each chemically identical fragment is present only in a single
DoRings();
DoReverses();
SetItr itr;
_ss.str("");
for(itr=fragset.begin();itr!=fragset.end();++itr)
{
//Use hash of fragment to set a bit in the fingerprint
int hash = CalcHash(*itr);
SetBit(fp,hash);
if(!(Flags() & FPT_NOINFO))
PrintFpt(*itr,hash);
}
if(nbits)
Fold(fp, nbits);
// TRACE("%d after\n",fragset.size());
return true;
}