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


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

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


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

示例1: CorrectForPH

  void OBPhModel::CorrectForPH(OBMol &mol, double pH)
  {
    if (!_init)
      Init();
    if (mol.IsCorrectedForPH())
      return;
    if (mol.GetDimension() > 0 && !mol.AutomaticFormalCharge())
      return;

    mol.SetCorrectedForPH();

    obErrorLog.ThrowError(__FUNCTION__,
                          "Ran OpenBabel::CorrectForPH", obAuditMsg);

    mol.DeleteHydrogens();

    for (unsigned int i = 0; i < _vtsfm.size(); ++i) {

      if (_vpKa[i] > 1E+9) {
        // always apply when pKa is > 1e+9
        _vtsfm[i]->Apply(mol);
      } else {
        // 10^(pKa - pH) = [HA] / [A-]
        //
        // > 1 : [HA] > [A-]
        // < 1 : [HA] < [A-]
        if (_vtsfm[i]->IsAcid()) {
          //cout << "IsAcid == " << _vtsfm[i]->IsAcid() << endl;
          //cout << "pKa == " << _vpKa[i] << endl;
          //cout << "pow(10, _vpKa[i] - pH) == " << pow(10, _vpKa[i] - pH) << endl;
          if (pow(10, _vpKa[i] - pH) < 1.0) {
            //cout << "APPLY!!" << endl;
            _vtsfm[i]->Apply(mol);
          }
        }

        // 10^(pKa - pH) = [BH+] / [B:]
        //
        // > 1 : [BH+] > [B:]
        // < 1 : [BH+] < [B:]
        if (_vtsfm[i]->IsBase()) {
          //cout << "IsBase == " << _vtsfm[i]->IsBase() << endl;
          //cout << "pKa == " << _vpKa[i] << endl;
          //cout << "pow(10, _vpKa[i] - pH) == " << pow(10, _vpKa[i] - pH) << endl;
          if (pow(10, _vpKa[i] - pH) > 1.0) {
            //cout << "APPLY!!" << endl;
            _vtsfm[i]->Apply(mol);
          }
        }
      }
    }

    atomtyper.CorrectAromaticNitrogens(mol);
  }
开发者ID:baoilleach,项目名称:openbabel-svn-mirror,代码行数:54,代码来源:phmodel.cpp

示例2: Do

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

  map<string,string>::const_iterator itr;

  // Is there an -s option?
  if(pConv->IsFirstInput())
  {
    _pOpIsoM = NULL; //assume no -s option
    itr = pmap->find("s");
    if(itr!=pmap->end())
    {
      //There is an -s option; check it is ok
      _pOpIsoM = static_cast<OpNewS*>(OBOp::FindType("s"));
      _stext = itr->second; //get its parameter(s)
      if(!_pOpIsoM || _stext.empty())
      {
        obErrorLog.ThrowError(__FUNCTION__,
        "No parameter on -s option, or its OBOp version is not loaded", obError);
        pConv->SetOneObjectOnly(); //to finish
        return false;
      }
    }
  }

  // If the output format is a 2D depiction format, then we should align
  // on the 2D coordinates and not the 3D coordinates (if present). This
  //means we need to generate the 2D coordinates at this point.
  if(pmol->GetDimension()==3 && (pConv->GetOutFormat()->Flags() & DEPICTION2D))
  {
    OBOp* pgen = OBOp::FindType("gen2D");
    if(pgen)
      pgen->Do(pmol);
  }

  // All molecules must have coordinates, so add them if 0D
  // They may be added again later when gen2D or gen3D is called, but they will be the same.
  // It would be better if this op was called after them, which would happen
  // if its name was alphabetically after "gen" (and before "s").
  if(pmol->GetDimension()==0)
  {
    //Will the coordinates be 2D or 3D?
    itr = pmap->find("gen3D");
    OBOp* pgen = (itr==pmap->end()) ? OBOp::FindType("gen2D") : OBOp::FindType("gen3D");
    if(pgen)
      pgen->Do(pmol);
  }

  //Do the alignment in 2D if the output format is svg, png etc. and there is no -xn option
  if(pmol->GetDimension()==3 && pConv && !pConv->IsOption("n"))
  {
    OBFormat* pOutFormat = pConv->GetOutFormat();
    if(pOutFormat->Flags() & DEPICTION2D)
    {
      OBOp* pgen = OBOp::FindType("gen2D");
      if(pgen)
        pgen->Do(pmol);
    }
  }

  if(pConv->IsFirstInput() || _refMol.NumAtoms()==0)
  {
    _refvec.clear();
    // Reference molecule is basically the first molecule
    _refMol = *pmol;
    if(!_pOpIsoM)
     //no -s option. Use a molecule reference.
     _align.SetRefMol(_refMol);
    else
    {
      //If there is a -s option, reference molecule has only those atoms that are matched
      //Call the -s option from here
      bool ret = _pOpIsoM->Do(pmol, _stext.c_str(), pmap, pConv);
      // Get the atoms that were matched
      vector<int> ats = _pOpIsoM->GetMatchAtoms();
      if(!ats.empty())
      {
        // Make a vector of the matching atom coordinates...
        for(vector<int>::iterator iter=ats.begin(); iter!=ats.end(); ++iter)
          _refvec.push_back((pmol->GetAtom(*iter))->GetVector());
        // ...and use a vector reference
        _align.SetRef(_refvec);
      }
      // Stop -s option being called normally, although it will still be called once
      //  in the DoOps loop already started for the current (first) molecule.
      pConv->RemoveOption("s",OBConversion::GENOPTIONS);
      if(!ret)
      {
        // the first molecule did not match the -s option so a reference molecule
        // could not be made. Keep trying.
        _refMol.Clear();
        //obErrorLog.ThrowError(__FUNCTION__, "The first molecule did not match the -s option\n"
        //  "so the reference structure was not derived from it", obWarning, onceOnly);
        return false; //not matched
      }
    }
  }
//.........这里部分代码省略.........
开发者ID:bgruening,项目名称:pgchem_tigress,代码行数:101,代码来源:opalign.cpp


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