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


C++ OBConversion::SetInStream方法代码示例

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


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

示例1: main

int main(int argc, char **argv)
{
  if (argc < 3) {
    std::cerr << "Usage: " << argv[0] << " <molecule_file> <output_score_file>" << std::endl;
    return 1;
  }

  unsigned long numAtoms = 0;
  unsigned long numAromaticAtoms = 0;
  unsigned long numCyclicAtoms = 0;
  std::map<int, unsigned long> mass;
  std::map<int, unsigned long> elem;
  std::map<int, unsigned long> aromelem;
  std::map<int, unsigned long> aliphelem;
  std::map<int, unsigned long> hcount;
  std::map<int, unsigned long> charge;
  std::map<int, unsigned long> connect;
  std::map<int, unsigned long> degree;
  std::map<int, unsigned long> implicit;
  std::map<int, unsigned long> rings;
  std::map<int, unsigned long> size;
  std::map<int, unsigned long> valence;
  std::map<int, unsigned long> chiral;
  std::map<int, unsigned long> hyb;
  std::map<int, unsigned long> ringconnect;

  unsigned long numBonds = 0;
  unsigned long numSingleBonds = 0;
  unsigned long numDoubleBonds = 0;
  unsigned long numTripleBonds = 0;
  unsigned long numAromaticBonds = 0;
  unsigned long numRingBonds = 0;

  OBConversion conv;
  conv.SetInFormat(conv.FormatFromExt(argv[1]));
  std::ifstream ifs(argv[1]);
  conv.SetInStream(&ifs);

  OBMol mol;
  unsigned long molecule = 0;
  while (conv.Read(&mol)) {
    ++molecule;
    //if ((molecule % 1000) == 0)
    //  std::cout << molecule << std::endl;

    FOR_ATOMS_OF_MOL (atom, mol) {
      numAtoms++;
      if (atom->IsAromatic()) {
        numAromaticAtoms++;
        aromelem[atom->GetAtomicNum()]++;
      } else
        aliphelem[atom->GetAtomicNum()]++;
      if (atom->IsInRing())
        numCyclicAtoms++;
      mass[atom->GetIsotope()]++;
      elem[atom->GetAtomicNum()]++;
      hcount[atom->ExplicitHydrogenCount() + atom->ImplicitHydrogenCount()]++;
      charge[atom->GetFormalCharge()]++;
      connect[atom->GetImplicitValence()]++;
      degree[atom->GetValence()]++;
      implicit[atom->ImplicitHydrogenCount()]++;
      rings[atom->MemberOfRingCount()]++;
      for (int i = 3; i < 25; ++i)
        if (atom->IsInRingSize(i))
          size[i]++;
      valence[atom->KBOSum() - (atom->GetSpinMultiplicity() ? atom->GetSpinMultiplicity() - 1 : 0)]++;
      hyb[atom->GetHyb()]++;
      ringconnect[atom->CountRingBonds()]++;    
    }

    FOR_BONDS_OF_MOL (bond, mol) {
      numBonds++;
      if (bond->IsSingle())
        numSingleBonds++;
      else if (bond->IsDouble())
        numDoubleBonds++;
      else if (bond->IsTriple())
        numTripleBonds++;
      if (bond->IsAromatic())
        numAromaticBonds++;
      if (bond->IsInRing())
        numRingBonds++;;
    }
开发者ID:timvdm,项目名称:SmartsCompiler,代码行数:83,代码来源:smartsscores.cpp


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