Exemple #1
0
std::vector< std::vector<unsigned long> > getIdRingPaths(OBMol &mol)
{
  mol.UnsetFlag(OB_LSSR_MOL);
  mol.DeleteData("LSSR");
  std::vector<OBRing*> lssr = mol.GetLSSR();

  std::vector< std::vector<unsigned long> > idPaths;

  for (unsigned int i = 0; i < lssr.size(); ++i) {
    OBRing *ring = lssr[i];
    std::vector<unsigned long> idPath;
    for (unsigned int j = 0; j < ring->_path.size(); ++j) {
      idPath.push_back(mol.GetAtom(ring->_path[j])->GetId());
    }

    std::sort(idPath.begin(), idPath.end());  
    idPaths.push_back(idPath);
  }

  /*
  cout << "# idPaths = " << idPaths.size() << endl;
  for (unsigned int i = 0; i < idPaths.size(); ++i) {
    cout << "    ring: ";
    for (unsigned int j = 0; j < idPaths[i].size(); ++j) {
      cout << idPaths[i][j] << " ";    
    }
    cout << endl;
  }
  */

  return idPaths;
}
Exemple #2
0
bool verifyLSSR(const std::string &filename, const LSSR &ref)
{
  cout << "Verify LSSR: " << filename << endl;
  std::string file = OBTestUtil::GetFilename(filename);
  // read a smiles string
  OBMol mol;
  OBConversion conv;
  OBFormat *format = conv.FormatFromExt(file.c_str());
  OB_REQUIRE( format );
  OB_REQUIRE( conv.SetInFormat(format) );

  std::ifstream ifs;
  ifs.open(file.c_str());
  OB_REQUIRE( ifs );
  OB_REQUIRE( conv.Read(&mol, &ifs) );

  std::vector<int> ringSizeCount(20, 0); 
  std::vector<OBRing*> lssr = mol.GetLSSR();

  for (unsigned int i = 0; i < lssr.size(); ++i) {
    ringSizeCount[lssr[i]->_path.size()]++;
  }

  /*
  cout << "ringSize: ringCount" << endl;
  cout << "3: " << ringSizeCount[3] << endl;
  cout << "4: " << ringSizeCount[4] << endl;
  cout << "5: " << ringSizeCount[5] << endl;
  cout << "6: " << ringSizeCount[6] << endl;
  */

  bool fail = false;
  for (unsigned int i = 0; i < ref.size_count.size(); ++i) {
    const LSSR::Size_Count &size_count = ref.size_count[i];
    OB_ASSERT( ringSizeCount[size_count.ringSize] == size_count.ringCount );
  }

  return true;
}