本文整理汇总了C++中OBMol::AddAtom方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::AddAtom方法的具体用法?C++ OBMol::AddAtom怎么用?C++ OBMol::AddAtom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::AddAtom方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
OBAtom a, b, c;
a.SetAtomicNum(8);
b.SetAtomicNum(6);
c.SetAtomicNum(8);
OBMol mol;
mol.AddAtom(a);
mol.AddAtom(b);
mol.AddAtom(c);
mol.AddBond(1,2,2);
mol.AddBond(2,3,2);
OBConversion conv;
conv.SetOutFormat("SMI");
cout << conv.WriteString(&mol,1) << endl;
OBSmartsPattern sp;
sp.Init ("C~*");
sp.Match (mol,false);
cout << sp.NumMatches() << endl;
cout << sp.GetUMapList().size() << endl;
return EXIT_SUCCESS;
}
示例2: testIdsAddAtom
void testIdsAddAtom()
{
OBMol mol;
// add 5 atoms
for (int i = 0; i < 5; ++i)
mol.NewAtom();
OBAtom a;
a.SetAtomicNum(6);
// add a sixth atom
mol.AddAtom(a);
OB_REQUIRE( mol.NumAtoms() == 6 );
OB_REQUIRE( mol.GetAtomById(5) );
OB_REQUIRE( mol.GetAtomById(5)->GetId() == 5 );
}
示例3: ReadMolecule
bool ThermoFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)
{
OBMol* pmol = pOb->CastAndClear<OBMol>();
if(!pmol)
return false;
bool stopOnEnd = pConv->IsOption("e",OBConversion::INOPTIONS)!=NULL;
pmol->SetDimension(0);
OBNasaThermoData* pND = new OBNasaThermoData; //to store rate constant data
pND->SetOrigin(fileformatInput);
pmol->SetData(pND);
istream &ifs = *pConv->GetInStream();
double DefaultMidT = 1500;
char ln[BUFF_SIZE];
unsigned int i;
//find line with 1 in col 80
do
{
if(!ifs.getline(ln,BUFF_SIZE) || stopOnEnd && !strncasecmp(ln,"END",3))
return false;
}while(ln[79]!='1');
char phase, nam[25], dum[7], elname[3];
elname[2]=0;
int elnum;
double Coeff[14];
sscanf(ln,"%18s%6s",nam,dum);
pmol->SetTitle(nam);
char* p=ln+24;
if(ln[80]=='&')
{
//Reaction Design extension
p+=20;
string line;
if(!getline(ifs,line))return false;
vector<string> toks;
tokenize(toks,line," \t\n\r");
for(i=0;i<toks.size();i+=2)
{
OBAtom atom;
atom.SetAtomicNum(etab.GetAtomicNum(toks[i].c_str()));
elnum = atoi(toks[i+1].c_str());
atom.ForceNoH();
for(;elnum>0;--elnum)
pmol->AddAtom(atom);
}
}
else
{
for(i=0;i<4;i++,p+=5)
{
char snum[4]={0,0,0,0};//Was problem with F 10 0 reading as ten
sscanf(p,"%c%c%c%c%c",elname,elname+1,snum,snum+1,snum+2);
elnum=atoi(snum);
if(elname[0]!=' ' && elname[0]!='0')
{
if(elname[1]==' ')
elname[1]=0;
OBAtom atom;
atom.SetAtomicNum(etab.GetAtomicNum(elname));
atom.ForceNoH();
for(;elnum>0;--elnum)
pmol->AddAtom(atom);
}
}
}
double LoT, HiT, MidT=0;
/* int nc = */sscanf(p,"%c%10lf%10lf10%lf",&phase, &LoT, &HiT, &MidT);
pND->SetPhase(phase);
pND->SetLoT(LoT);
pND->SetHiT(HiT);
if(MidT>HiT || MidT<LoT)
MidT=DefaultMidT;
pND->SetMidT(MidT);
if (!ifs.getline(ln, BUFF_SIZE)) return false;
p=ln;
for(i=0;i<5;i++,p+=15)
sscanf(p,"%15lf",&Coeff[i]);
if (!ifs.getline(ln, BUFF_SIZE)) return false;
p=ln;
for(i=5;i<10;i++,p+=15)
sscanf(p,"%15lf",&Coeff[i]);
if (!ifs.getline(ln, BUFF_SIZE)) return false;
p=ln;
for(i=10;i<14;i++,p+=15)
sscanf(p,"%15lf",&Coeff[i]);
for(i=0;i<14;++i)
pND->SetCoeff(i, Coeff[i]);
pmol->AssignSpinMultiplicity();
return true;
}
示例4: parseAtomRecord
//.........这里部分代码省略.........
resname == "GPG" || resname == "NAD" || resname == "NAL" ||
resname == "NDP" || resname == "ABA") {
if (type.size() > 1)
type = type.substr(0,1);
//type.erase(1,type.size()-1);
} else // other residues
if (isdigit(type[0])){
type = type.substr(1,1);
}
else
if (type.size() > 1 && isdigit(type[1]))
type = type.substr(0,1);
else
if (type.size() > 1 && isalpha(type[1])) {
if (type[0] == 'O' && type[1] == 'H')
type = type.substr(0,1); // no "Oh" element (e.g. 1MBN)
else if(isupper(type[1])) {
type[1] = tolower(type[1]);
}
}
}
} // HETATM records
} // no element column to use
OBAtom atom;
/* X, Y, Z */
string xstr = sbuf.substr(24,8);
string ystr = sbuf.substr(32,8);
string zstr = sbuf.substr(40,8);
vector3 v(atof(xstr.c_str()),atof(ystr.c_str()),atof(zstr.c_str()));
atom.SetVector(v);
atom.ForceImplH();
// useful for debugging unknown atom types (e.g., PR#1577238)
// cout << mol.NumAtoms() + 1 << " : '" << element << "'" << " " << etab.GetAtomicNum(element.c_str()) << endl;
if (elementFound)
atom.SetAtomicNum(etab.GetAtomicNum(element.c_str()));
else // use our old-style guess from athe atom type
atom.SetAtomicNum(etab.GetAtomicNum(type.c_str()));
if ( (! scharge.empty()) && " " != scharge )
{
if ( isdigit(scharge[0]) && ('+' == scharge[1] || '-' == scharge[1]) )
{
const char reorderCharge[3] = { scharge[1], scharge[0], '\0' };
const int charge = atoi(reorderCharge);
atom.SetFormalCharge(charge);
}
else
{
stringstream errorMsg;
errorMsg << "WARNING: Problems reading a PDB file\n"
<< " Problems reading a HETATM or ATOM record.\n"
<< " According to the PDB specification,\n"
<< " columns 79-80 should contain charge of the atom\n"
<< " but OpenBabel found '" << scharge << "' (atom " << mol.NumAtoms()+1 << ").";
obErrorLog.ThrowError(__FUNCTION__, errorMsg.str(), obWarning);
}
}
else {
atom.SetFormalCharge(0);
}
/* residue sequence number */
string resnum = sbuf.substr(16,4);
OBResidue *res = (mol.NumResidues() > 0) ? mol.GetResidue(mol.NumResidues()-1) : NULL;
if (res == NULL
|| res->GetName() != resname
|| res->GetNumString() != resnum
|| res->GetChain() != chain)
{
vector<OBResidue*>::iterator ri;
for (res = mol.BeginResidue(ri) ; res ; res = mol.NextResidue(ri))
if (res->GetName() == resname
&& res->GetNumString() == resnum
&& static_cast<int>(res->GetChain()) == chain)
break;
if (res == NULL) {
res = mol.NewResidue();
res->SetChain(chain);
res->SetName(resname);
res->SetNum(resnum);
}
}
if (!mol.AddAtom(atom))
return(false);
else {
OBAtom *atom = mol.GetAtom(mol.NumAtoms());
res->AddAtom(atom);
res->SetSerialNum(atom, atoi(serno.c_str()));
res->SetAtomID(atom, sbuf.substr(6,4));
res->SetHetAtom(atom, hetatm);
return(true);
}
} // end reading atom records