当前位置: 首页>>代码示例>>C++>>正文


C++ OBMol::RenumberAtoms方法代码示例

本文整理汇总了C++中OBMol::RenumberAtoms方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::RenumberAtoms方法的具体用法?C++ OBMol::RenumberAtoms怎么用?C++ OBMol::RenumberAtoms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OBMol的用法示例。


在下文中一共展示了OBMol::RenumberAtoms方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Do

bool OpCanonical::Do(OBBase* pOb, const char* OptionText, OpMap* pOptions, OBConversion* pConv)
{
  OBMol* pmol = dynamic_cast<OBMol*>(pOb);
  if(!pmol)
    return false;

  std::vector<OBAtom*> atoms;
  FOR_ATOMS_OF_MOL (atom, pmol)
    atoms.push_back(&*atom);

  std::vector<unsigned int> symmetry_classes;
  OBGraphSym gs(pmol);
  gs.GetSymmetry(symmetry_classes);

  std::vector<unsigned int> canon_labels;
  CanonicalLabels(pmol, symmetry_classes, canon_labels);

  std::vector<OBAtom*> newatoms(atoms.size(), 0);
  for (std::size_t i = 0; i < canon_labels.size(); ++i)
    newatoms[canon_labels[i]-1] = atoms[i];

  pmol->RenumberAtoms(newatoms);

  return true;
}
开发者ID:baoilleach,项目名称:openbabel-svn-mirror,代码行数:25,代码来源:canonical.cpp

示例2: doShuffleTestMolecule

bool doShuffleTestMolecule(OBMol &mol)
{
  //cout << "-------------------------------------------------------------------------" << endl;
  int N = 100;

  std::vector< std::vector<unsigned long> > ref = getIdRingPaths(mol);

  std::vector<OBAtom*> atoms;
  FOR_ATOMS_OF_MOL(atom, mol)
    atoms.push_back(&*atom);
  
  for (int i = 0; i < N; ++i) {
    // shuffle the atoms
    std::random_shuffle(atoms.begin(), atoms.end());
    mol.RenumberAtoms(atoms);
    // get rings
    std::vector< std::vector<unsigned long> > rings = getIdRingPaths(mol);
    OB_ASSERT( rings.size() == ref.size() );
    if (rings.size() == ref.size()) {
      for (unsigned int j = 0; j < rings.size(); ++j) {
        bool found = false;
        for (unsigned int k = 0; k < ref.size(); ++k) {
          if (rings[j] == ref[k]) {
            found = true;
            break;
          }
        }
        OB_ASSERT( found );
      }
    }
  }

  return true;
}
开发者ID:Reinis,项目名称:openbabel,代码行数:34,代码来源:lssrtest.cpp

示例3: main

int main(int argc, char **argv)
{
  // Define location of file formats for testing
#ifdef FORMATDIR
    char env[BUFF_SIZE];
    snprintf(env, BUFF_SIZE, "BABEL_LIBDIR=%s", FORMATDIR);
    putenv(env);
#endif  

  std::ifstream ifs(GetFilename("canonstable.can").c_str());
  OB_REQUIRE( ifs );


  OBMol mol;
  OBConversion conv;
  conv.SetInFormat("smi");
  conv.SetOutFormat("can");

  std::string line;
  while (std::getline(ifs, line)) {
    OB_REQUIRE( conv.ReadString(&mol, line.c_str()) );

    std::vector<OBAtom*> atoms;
    FOR_ATOMS_OF_MOL(atom, mol)
      atoms.push_back(&*atom);

    for (int i = 0; i < 5; ++i) {
      // shuffle the atoms
      std::random_shuffle(atoms.begin(), atoms.end());
      mol.RenumberAtoms(atoms);

      // get can smiles
      mol.SetTitle("");
      std::string cansmi = conv.WriteString(&mol, true);
      // comapare with ref
      if (cansmi != line) {
        cout << "ref = " << line << endl;
        cout << "can = " << cansmi << endl;
        OB_ASSERT( cansmi == line );
      }
    }
  }
 
  return 0;
}
开发者ID:AlbertDeFusco,项目名称:openbabel,代码行数:45,代码来源:canonstabletest.cpp


注:本文中的OBMol::RenumberAtoms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。