本文整理汇总了C++中OBMol::GetAtomById方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::GetAtomById方法的具体用法?C++ OBMol::GetAtomById怎么用?C++ OBMol::GetAtomById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::GetAtomById方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: testIdsNewAtom1
// OBMol::NewAtom()
void testIdsNewAtom1()
{
OBMol mol;
for (int i = 0; i < 10; ++i) {
OBAtom *atom = mol.NewAtom();
OB_REQUIRE(atom->GetId() == i);
}
OB_REQUIRE( mol.GetAtomById(0) );
OB_REQUIRE( mol.GetAtomById(4) );
OB_REQUIRE( mol.GetAtomById(9) );
OB_REQUIRE( !mol.GetAtomById(10) );
OB_REQUIRE( mol.GetAtomById(0)->GetId() == 0 );
OB_REQUIRE( mol.GetAtomById(4)->GetId() == 4 );
OB_REQUIRE( mol.GetAtomById(9)->GetId() == 9 );
}
示例3: testIdsDeleteAtom
void testIdsDeleteAtom()
{
OBMol mol;
for (int i = 0; i < 10; ++i)
mol.NewAtom();
OB_REQUIRE( mol.GetAtomById(3) );
OB_REQUIRE( mol.GetAtomById(4) );
OB_REQUIRE( mol.GetAtomById(5) );
mol.DeleteAtom(mol.GetAtomById(4));
OB_REQUIRE( mol.GetAtomById(3) );
OB_REQUIRE( mol.GetAtomById(3)->GetId() == 3 );
OB_REQUIRE( !mol.GetAtomById(4) );
OB_REQUIRE( mol.GetAtomById(5) );
OB_REQUIRE( mol.GetAtomById(5)->GetId() == 5 );
}
示例4: testIdsNewAtom2
// OBMol::NewAtom(unsigned long id)
void testIdsNewAtom2()
{
OBMol mol;
for (int i = 0; i < 10; ++i) {
OBAtom *atom = mol.NewAtom(i*2);
OB_REQUIRE(atom->GetId() == i*2);
}
OB_REQUIRE( mol.GetAtomById(0) );
OB_REQUIRE( !mol.GetAtomById(7) );
OB_REQUIRE( mol.GetAtomById(8) );
OB_REQUIRE( !mol.GetAtomById(9) );
OB_REQUIRE( mol.GetAtomById(18) );
OB_REQUIRE( !mol.GetAtomById(19) );
OB_REQUIRE( mol.GetAtomById(0)->GetId() == 0 );
OB_REQUIRE( mol.GetAtomById(8)->GetId() == 8 );
OB_REQUIRE( mol.GetAtomById(18)->GetId() == 18 );
}
示例5: DeleteExpandedAtoms
void AliasData::DeleteExpandedAtoms(OBMol& mol)
{
//The atom that carries the AliasData object remains as an Xx atom with no charge;
//the others are deleted. All the attached hydrogens are also deleted.
for(unsigned i=0;i<_expandedatoms.size();++i)
{
OBAtom* at = mol.GetAtomById(_expandedatoms[i]);
if(!at)
continue;
mol.DeleteHydrogens(at);
if(at->HasData(AliasDataType))
{
at->SetAtomicNum(0);
at->SetFormalCharge(0);
at->SetSpinMultiplicity(0);
}
else
mol.DeleteAtom(at);
}
_expandedatoms.clear();
}
示例6: genericSmilesCanonicalTest
void genericSmilesCanonicalTest(const std::string &smiles)
{
cout << "Testing generic smiles <-> canonical smiles" << endl;
// read a smiles string
OBMol mol;
OBConversion conv;
OB_REQUIRE( conv.SetInFormat("smi") );
OB_REQUIRE( conv.SetOutFormat("can") );
cout << "smiles: " << smiles << endl;
// read a smiles string
OB_REQUIRE( conv.ReadString(&mol, smiles) );
// store the stereo data for the smiles string using unique symmetry ids
std::vector<OBTetrahedralStereo::Config> tetrahedral1;
std::vector<OBCisTransStereo::Config> cistrans1;
std::vector<OBSquarePlanarStereo::Config> squareplanar1;
// get the stereo data
OB_ASSERT( mol.HasData(OBGenericDataType::StereoData) );
std::vector<OBGenericData *> stereoData = mol.GetAllData(OBGenericDataType::StereoData);
std::vector<unsigned int> canlbls;
std::vector<unsigned int> symclasses;
OBGraphSym gs1(&mol);
gs1.GetSymmetry(symclasses);
CanonicalLabels(&mol, symclasses, canlbls);
cout << "mol.NumAtoms = " << mol.NumAtoms() << endl;
for (std::vector<OBGenericData*>::iterator data = stereoData.begin(); data != stereoData.end(); ++data) {
if (((OBStereoBase*)*data)->GetType() == OBStereo::Tetrahedral) {
// convert to tetrahedral data
OBTetrahedralStereo *ts = dynamic_cast<OBTetrahedralStereo*>(*data);
OB_REQUIRE( ts );
OB_ASSERT( ts->IsValid() );
if (!ts->IsValid())
continue;
OBTetrahedralStereo::Config config = ts->GetConfig();
// convert atom ids to symmetry ids
if (mol.GetAtomById(config.center))
config.center = canlbls.at( mol.GetAtomById(config.center)->GetIdx() - 1 );
if (mol.GetAtomById(config.from))
config.from = canlbls.at( mol.GetAtomById(config.from)->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[0]))
config.refs[0] = canlbls.at( mol.GetAtomById(config.refs[0])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[1]))
config.refs[1] = canlbls.at( mol.GetAtomById(config.refs[1])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[2]))
config.refs[2] = canlbls.at( mol.GetAtomById(config.refs[2])->GetIdx() - 1 );
cout << "Config with symmetry ids: " << config << endl;
tetrahedral1.push_back(config);
} else
if (((OBStereoBase*)*data)->GetType() == OBStereo::CisTrans) {
// convert to tetrahedral data
OBCisTransStereo *ct = dynamic_cast<OBCisTransStereo*>(*data);
OB_REQUIRE( ct );
OB_ASSERT( ct->IsValid() );
OBCisTransStereo::Config config = ct->GetConfig();
// convert atom ids to symmetry ids
config.begin = canlbls.at( mol.GetAtomById(config.begin)->GetIdx() - 1 );
config.end = canlbls.at( mol.GetAtomById(config.end)->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[0]))
config.refs[0] = canlbls.at( mol.GetAtomById(config.refs[0])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[1]))
config.refs[1] = canlbls.at( mol.GetAtomById(config.refs[1])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[2]))
config.refs[2] = canlbls.at( mol.GetAtomById(config.refs[2])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[3]))
config.refs[3] = canlbls.at( mol.GetAtomById(config.refs[3])->GetIdx() - 1 );
cout << "Config with symmetry ids: " << config << endl;
cistrans1.push_back(config);
} else
if (((OBStereoBase*)*data)->GetType() == OBStereo::SquarePlanar) {
// convert to tetrahedral data
OBSquarePlanarStereo *sp = dynamic_cast<OBSquarePlanarStereo*>(*data);
OB_REQUIRE( sp );
OB_ASSERT( sp->IsValid() );
if (!sp->IsValid())
continue;
OBSquarePlanarStereo::Config config = sp->GetConfig();
// convert atom ids to symmetry ids
if (mol.GetAtomById(config.center))
config.center = canlbls.at( mol.GetAtomById(config.center)->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[0]))
config.refs[0] = canlbls.at( mol.GetAtomById(config.refs[0])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[1]))
config.refs[1] = canlbls.at( mol.GetAtomById(config.refs[1])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[2]))
config.refs[2] = canlbls.at( mol.GetAtomById(config.refs[2])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[3]))
config.refs[3] = canlbls.at( mol.GetAtomById(config.refs[3])->GetIdx() - 1 );
cout << "Config with symmetry ids: " << config << endl;
squareplanar1.push_back(config);
}
}
// write to can smiles
//.........这里部分代码省略.........