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


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

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


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

示例1: construct_g_matrix

  //! Construct the matrix G, which puts each atoms valence+1
  //! on the diagonal and and -1 on the off diagonal if two
  //! atoms are connected.
  void construct_g_matrix(OBMol &mol, std::vector<std::vector<double> > &m)
  {
    unsigned int i,j;

    OBAtom *atm1,*atm2;
    vector<OBAtom*>::iterator aint,bint;

    m.resize(mol.NumAtoms());
    for (i = 0; i < m.size(); ++i)
      m[i].resize(mol.NumAtoms());

    for (atm1 = mol.BeginAtom(aint),i=0;atm1;atm1 = mol.NextAtom(aint),++i)
      for (atm2 = mol.BeginAtom(bint),j=0;atm2;atm2 = mol.NextAtom(bint),++j)
        {
          if (i == j)
            {
              m[i][j] = atm1->GetValence() + 1;
              m[i][j] += (double)atm1->GetAtomicNum()/10.0;
              m[i][j] += (double)atm1->GetHyb()/100.0;
            }
          else
            {
              if (atm1->IsConnected(atm2))
                m[i][j] = -1;
              else
                m[i][j] = 0;
            }
        }
  }
开发者ID:candycode,项目名称:openbabel,代码行数:32,代码来源:chiral.cpp

示例2: WriteCSRCoords

void CSRFormat::WriteCSRCoords(ostream &ofs,OBMol &mol)
{
    int the_size,jconf;
    double x,y,z,energy;
    char title[100];
    char *tag;

    the_size = sizeof(int) + sizeof(double) + (80 * sizeof(char));

    jconf = 1;
    energy = -2.584565;

    snprintf(title, 80, "%s:%d",mol.GetTitle(),MolCount);
    tag = PadString(title,80);

    WriteSize(the_size,ofs);
    ofs.write((char*)&jconf,sizeof(int));
    ofs.write((char*)&energy,sizeof(double));
    ofs.write(tag,80*sizeof(char));
    WriteSize(the_size,ofs);

    WriteSize(mol.NumAtoms()*sizeof(double),ofs);

    OBAtom *atom;
    vector<OBAtom*>::iterator i;
    for (atom = mol.BeginAtom(i); atom; atom = mol.NextAtom(i))
    {
        x = atom->x();
        ofs.write((char*)&x,sizeof(double));
    }
    WriteSize(mol.NumAtoms()*sizeof(double),ofs);

    WriteSize(mol.NumAtoms()*sizeof(double),ofs);
    for (atom = mol.BeginAtom(i); atom; atom = mol.NextAtom(i))
    {
        y = atom->y();
        ofs.write((char*)&y,sizeof(double));
    }
    WriteSize(mol.NumAtoms()*sizeof(double),ofs);

    WriteSize(mol.NumAtoms()*sizeof(double),ofs);
    for (atom = mol.BeginAtom(i); atom; atom = mol.NextAtom(i))
    {
        z = atom->z();
        ofs.write((char*)&z,sizeof(double));
    }
    WriteSize(mol.NumAtoms()*sizeof(double),ofs);

    delete [] tag;
}
开发者ID:CooperLiu,项目名称:openbabel,代码行数:50,代码来源:CSRformat.cpp

示例3: AssignHyb

  void OBAtomTyper::AssignHyb(OBMol &mol)
  {
    if (!_init)
      Init();

    aromtyper.AssignAromaticFlags(mol);

    mol.SetHybridizationPerceived();
    obErrorLog.ThrowError(__FUNCTION__,
                          "Ran OpenBabel::AssignHybridization", obAuditMsg);

    OBAtom *atom;
    vector<OBAtom*>::iterator k;
    for (atom = mol.BeginAtom(k);atom;atom = mol.NextAtom(k))
      atom->SetHyb(0);

    vector<vector<int> >::iterator j;
    vector<pair<OBSmartsPattern*,int> >::iterator i;

    for (i = _vinthyb.begin();i != _vinthyb.end();++i)
      if (i->first->Match(mol))
        {
          _mlist = i->first->GetMapList();
          for (j = _mlist.begin();j != _mlist.end();++j)
            mol.GetAtom((*j)[0])->SetHyb(i->second);
        }
  }
开发者ID:annulen,项目名称:openbabel,代码行数:27,代码来源:typer.cpp

示例4: GetChirality

  // Seems to make a vector chirality become filled with array of +/- 1 for chiral atoms.
  void GetChirality(OBMol &mol, std::vector<int> &chirality)
  {
    chirality.resize(mol.NumAtoms()+1);
    fill(chirality.begin(),chirality.end(),0);

    OBAtom *atom;
    vector<OBAtom*>::iterator i;
    for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
      if (atom->IsChiral())
        {
          if (!atom->HasChiralVolume())
            {
              double sv = CalcSignedVolume(mol,atom);
              if (sv < 0.0)
                {
                  chirality[atom->GetIdx()-1] = -1;
                  atom->SetNegativeStereo();
                }
              else if (sv > 0.0)
                {
                  chirality[atom->GetIdx()-1] = 1;
                  atom->SetPositiveStereo();
                }
            }
          else // already calculated signed volume (e.g., imported from somewhere)
            {
              if (atom ->IsPositiveStereo())
                chirality[atom->GetIdx()-1] = 1;
              else
                chirality[atom->GetIdx()-1] = -1;
            }
        }
  }
开发者ID:candycode,项目名称:openbabel,代码行数:34,代码来源:chiral.cpp

示例5: AssignImplicitValence

  void OBAtomTyper::AssignImplicitValence(OBMol &mol)
  {
    // FF Make sure that valence has not been perceived
    if(mol.HasImplicitValencePerceived())
      return;

    if (!_init)
      Init();

    mol.SetImplicitValencePerceived();
    obErrorLog.ThrowError(__FUNCTION__,
                          "Ran OpenBabel::AssignImplicitValence", obAuditMsg);

    // FF Ensure that the aromatic typer will not be called
    int oldflags = mol.GetFlags(); // save the current state flags
    mol.SetAromaticPerceived();    // and set the aromatic perceived flag on

    OBAtom *atom;
    vector<OBAtom*>::iterator k;
    for (atom = mol.BeginAtom(k);atom;atom = mol.NextAtom(k))
      atom->SetImplicitValence(atom->GetValence());

    vector<vector<int> >::iterator j;
    vector<pair<OBSmartsPattern*,int> >::iterator i;

    for (i = _vimpval.begin();i != _vimpval.end();++i)
      if (i->first->Match(mol))
        {
          _mlist = i->first->GetMapList();
          for (j = _mlist.begin();j != _mlist.end();++j)
            mol.GetAtom((*j)[0])->SetImplicitValence(i->second);
        }

    if (!mol.HasAromaticCorrected())
      CorrectAromaticNitrogens(mol);

    for (atom = mol.BeginAtom(k);atom;atom = mol.NextAtom(k))
      {
        if (atom->GetImplicitValence() < atom->GetValence())
          atom->SetImplicitValence(atom->GetValence());
      }

    // FF Come back to the initial flags
    mol.SetFlags(oldflags);

    return;
  }
开发者ID:annulen,项目名称:openbabel,代码行数:47,代码来源:typer.cpp

示例6: IsClosure

  bool OBBond::IsClosure()
  {
    OBMol *mol = (OBMol*)GetParent();
    if (!mol)
      return(false);
    if (mol->HasClosureBondsPerceived())
      return(HasFlag(OB_CLOSURE_BOND));

    mol->SetClosureBondsPerceived();

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

    OBBond *bond;
    OBAtom *atom,*nbr;
    OBBitVec uatoms,ubonds;
    vector<OBAtom*> curr,next;
    vector<OBAtom*>::iterator i;
    vector<OBBond*>::iterator j;

    uatoms.Resize(mol->NumAtoms()+1);
    ubonds.Resize(mol->NumAtoms()+1);

    for (;static_cast<unsigned int>(uatoms.CountBits()) < mol->NumAtoms();)
      {
        if (curr.empty())
          for (atom = mol->BeginAtom(i);atom;atom = mol->NextAtom(i))
            if (!uatoms[atom->GetIdx()])
              {
                uatoms |= atom->GetIdx();
                curr.push_back(atom);
                break;
              }

        for (;!curr.empty();)
          {
            for (i = curr.begin();i != curr.end();++i)
              for (nbr = ((OBAtom*)*i)->BeginNbrAtom(j);nbr;nbr = ((OBAtom*)*i)->NextNbrAtom(j))
                if (!uatoms[nbr->GetIdx()])
                  {
                    uatoms |= nbr->GetIdx();
                    ubonds |= (*j)->GetIdx();
                    next.push_back(nbr);
                  }

            curr = next;
            next.clear();
          }
      }

    for (bond = mol->BeginBond(j);bond;bond = mol->NextBond(j))
      if (!ubonds[bond->GetIdx()])
        bond->SetClosure();

    return(HasFlag(OB_CLOSURE_BOND));
  }
开发者ID:AlbertDeFusco,项目名称:openbabel,代码行数:56,代码来源:bond.cpp

示例7: CopyPositionsToMol

 bool OBFunction::CopyPositionsToMol(OBMol& mol) const
 {
   if (mol.NumAtoms() != m_positions.size())
     return false;
   std::vector<OBAtom*>::iterator itr;
   std::vector<Eigen::Vector3d>::const_iterator itr2;
   OBAtom *atom;
   for (atom = mol.BeginAtom(itr), itr2=m_positions.begin(); atom; atom = mol.NextAtom(itr), ++itr2)
     atom->SetVector(const_cast<double *>(itr2->data()));
   return true;
 }
开发者ID:timvdm,项目名称:OBForceField,代码行数:11,代码来源:obfunction.cpp

示例8: snprintf

  bool CHEM3D1Format::WriteChem3d(ostream &ofs,OBMol &mol, const char *mol_typ)
  {
    int atnum;
    int type_num;
    char buffer[BUFF_SIZE],type_name[16],ele_type[16];

    ofs << mol.NumAtoms();
    if (EQ(mol_typ,"MMADS"))
      {
        ofs << " " << mol.GetTitle();
        ttab.SetToType("MM2");
      }
    else
      ttab.SetToType(mol_typ);
    ofs << endl;

    ttab.SetFromType("INT");

    OBAtom *atom,*nbr;
    vector<OBAtom*>::iterator i;
    vector<OBBond*>::iterator j;

    for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
      {
        if (!ttab.Translate(type_name,atom->GetType()))
          {
            snprintf(buffer, BUFF_SIZE,
                     "Unable to assign %s type to atom %d type = %s\n",
                     mol_typ,atom->GetIdx(),atom->GetType());
            obErrorLog.ThrowError(__FUNCTION__, buffer, obInfo);
            atnum = atom->GetAtomicNum();
            type_num = atnum * 10 + atom->GetValence();
            snprintf(type_name, sizeof(type_num), "%d",type_num);
          }
        strncpy(ele_type, etab.GetSymbol(atom->GetAtomicNum()), sizeof(ele_type));
        ele_type[sizeof(ele_type) - 1] = '\0';
        snprintf(buffer, BUFF_SIZE, "%-3s %-5d %8.4f  %8.4f  %8.4f %5s",
                ele_type,
                atom->GetIdx(),
                atom->x(),
                atom->y(),
                atom->z(),
                type_name);
        ofs << buffer;

        for (nbr = atom->BeginNbrAtom(j);nbr;nbr = atom->NextNbrAtom(j))
          {
            snprintf(buffer, BUFF_SIZE, "%6d",nbr->GetIdx());
            ofs << buffer;
          }
        ofs << endl;
      }
    return(true);
  }
开发者ID:Acpharis,项目名称:openbabel,代码行数:54,代码来源:chem3dformat.cpp

示例9: WriteGromos96

bool WriteGromos96(ostream &ofs,OBMol &mol,double fac)
{ 
  char type_name[10];
  char res_name[10],padded_name[10];
  char buffer[BUFF_SIZE];
  int res_num;

  sprintf(buffer,"#GENERATED BY OPEN BABEL %s",BABEL_VERSION);
  ofs << buffer << endl;

  /* GROMOS wants a TITLE block, so let's write one*/
  sprintf(buffer,"TITLE\n%s\nEND",mol.GetTitle());
  ofs << buffer << endl;
  ofs << "POSITION" << endl;

  OBAtom *atom;
  OBResidue *res;
  vector<OBNodeBase*>::iterator i;

  for(atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
    {
      if (res = atom->GetResidue())
	{
	  strcpy(res_name,(char*)res->GetName().c_str());
	  strcpy(type_name,(char*)res->GetAtomID(atom).c_str());
	  res_num = res->GetNum();
	}
      else
	{
	  strcpy(type_name,etab.GetSymbol(atom->GetAtomicNum()));
	  strcpy(res_name,"UNK");
	  sprintf(padded_name,"%2s",type_name);
	  strcpy(type_name,padded_name);
	  res_num = 1;
	}
      
      sprintf(buffer,"%5d %5s %5s %6d %15.5f %15.5f %15.5f",
	      res_num,res_name,type_name,atom->GetIdx(),
	      atom->x()*fac,atom->y()*fac,atom->z()*fac);
      ofs << buffer << endl;

      if (!(atom->GetIdx()%10))
      {
	sprintf(buffer,"# %d",atom->GetIdx());
	ofs << buffer << endl;
      }
    }

  ofs << "END" << endl;

  return(true);
}
开发者ID:daju1,项目名称:winlibghemical,代码行数:52,代码来源:gromos96.cpp

示例10: GetDFFVector

  bool GetDFFVector(OBMol &mol,vector<int> &dffv,OBBitVec &bv)
  {
    dffv.clear();
    dffv.resize(mol.NumAtoms());

    int dffcount,natom;
    OBBitVec used,curr,next;
    OBAtom *atom,*atom1;
    OBBond *bond;
    vector<OBAtom*>::iterator i;
    vector<OBBond*>::iterator j;

    next.Clear();

    for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
      {
        if (bv[atom->GetIdx()])
          {
            dffv[atom->GetIdx()-1] = 0;
            continue;
          }

        dffcount = 0;
        used.Clear();
        curr.Clear();
        used.SetBitOn(atom->GetIdx());
        curr.SetBitOn(atom->GetIdx());

        while (!curr.IsEmpty() && (bv&curr).Empty())
          {
            next.Clear();
            for (natom = curr.NextBit(-1);natom != curr.EndBit();natom = curr.NextBit(natom))
              {
                atom1 = mol.GetAtom(natom);
                for (bond = atom1->BeginBond(j);bond;bond = atom1->NextBond(j))
                  if (!used.BitIsOn(bond->GetNbrAtomIdx(atom1)) &&
                      !curr.BitIsOn(bond->GetNbrAtomIdx(atom1)))
                    if (!(bond->GetNbrAtom(atom1))->IsHydrogen())
                      next.SetBitOn(bond->GetNbrAtomIdx(atom1));
              }

            used |= next;
            curr = next;
            dffcount++;
          }

        dffv[atom->GetIdx()-1] = dffcount;
      }

    return(true);
  }
开发者ID:luolingqi,项目名称:fragmap_2,代码行数:51,代码来源:rotor.cpp

示例11: construct_c_matrix

  //! Construct the matrix C, which is simply a column vector
  //! consisting of the valence for each atom
  void construct_c_matrix(OBMol &mol,std::vector<std::vector<double > > &m)
  {
    unsigned int i;
    OBAtom *atm1;
    vector<OBAtom*>::iterator aint;

    m.resize(mol.NumAtoms());
    for (i = 0; i < m.size(); ++i)
      m[i].resize(1);
    for (atm1 = mol.BeginAtom(aint),i=0;atm1;atm1 = mol.NextAtom(aint),++i)
      {
        m[i][0] = atm1->GetValence();
      }
  }
开发者ID:candycode,项目名称:openbabel,代码行数:16,代码来源:chiral.cpp

示例12: FillChargeVectors

 void OBChargeModel::FillChargeVectors(OBMol &mol)
 {
   OBAtom *atom;
   vector<OBAtom*>::iterator itr;
   m_partialCharges.clear();
   m_partialCharges.reserve(mol.NumAtoms());
   m_formalCharges.clear();
   m_formalCharges.reserve(mol.NumAtoms());
   
   for (atom = mol.BeginAtom(itr);atom;atom = mol.NextAtom(itr))
     {
       m_partialCharges.push_back(atom->GetPartialCharge());
       m_formalCharges.push_back((double)(atom->GetFormalCharge()));
     }
 }
开发者ID:annulen,项目名称:openbabel,代码行数:15,代码来源:chargemodel.cpp

示例13: ExcludeSmallRing

  void OBAromaticTyper::ExcludeSmallRing(OBMol &mol)
  {
    OBAtom *atom,*nbr1,*nbr2;
    vector<OBAtom*>::iterator i;
    vector<OBBond*>::iterator j,k;

    for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
      if (_root[atom->GetIdx()])
        for (nbr1 = atom->BeginNbrAtom(j);nbr1;nbr1 = atom->NextNbrAtom(j))
          if ((*j)->IsInRing() && _vpa[nbr1->GetIdx()])
            for (nbr2 = nbr1->BeginNbrAtom(k);nbr2;nbr2 = nbr1->NextNbrAtom(k))
              if (nbr2 != atom && (*k)->IsInRing() && _vpa[nbr2->GetIdx()])
                if (atom->IsConnected(nbr2))
                  _root[atom->GetIdx()] = false;
  }
开发者ID:annulen,项目名称:openbabel,代码行数:15,代码来源:typer.cpp

示例14: AssignTypes

  void OBAtomTyper::AssignTypes(OBMol &mol)
  {
    if (!_init)
      Init();

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

    mol.SetAtomTypesPerceived();

    vector<vector<int> >::iterator j;
    vector<pair<OBSmartsPattern*,string> >::iterator i;

    for (i = _vexttyp.begin();i != _vexttyp.end();++i)
      if (i->first->Match(mol))
        {
          _mlist = i->first->GetMapList();
          for (j = _mlist.begin();j != _mlist.end();++j)
            mol.GetAtom((*j)[0])->SetType(i->second);
        }

    // Special cases
    vector<OBAtom*>::iterator a;
    OBAtom* atom;
    for (atom = mol.BeginAtom(a); atom; atom = mol.NextAtom(a)) {
      // guanidinium. Fixes PR#1800964
      if (strncasecmp(atom->GetType(),"C2", 2) == 0) {
        int guanidineN = 0;
        OBAtom *nbr;
        vector<OBBond*>::iterator k;
        for (nbr = atom->BeginNbrAtom(k);nbr;nbr = atom->NextNbrAtom(k)) {
          if (strncasecmp(nbr->GetType(),"Npl", 3) == 0 ||
              strncasecmp(nbr->GetType(),"N2", 2) == 0 ||
              strncasecmp(nbr->GetType(),"Ng+", 3) == 0)
            ++guanidineN;
        }
        if (guanidineN == 3)
          atom->SetType("C+");

      } // end C2 carbon for guanidinium

    } // end special cases
  }
开发者ID:annulen,项目名称:openbabel,代码行数:43,代码来源:typer.cpp

示例15: WriteChiral

  void WriteChiral(ostream &ofs,OBMol &mol)
  {
    OBAtom *atom;
    vector<OBNodeBase*>::iterator i;
    char buffer[BUFF_SIZE];

    for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
      {
	if (atom->IsChiral())
	  {
	    sprintf(buffer,"%4s %5d is chiral: %s",
		    etab.GetSymbol(atom->GetAtomicNum()),
		    atom->GetIdx(),
		    (atom->IsClockwise() ? "clockwise" : "counterclockwise"));
	
	    ofs << buffer << endl;
	  }
      }
  }
开发者ID:daju1,项目名称:winlibghemical,代码行数:19,代码来源:report.cpp


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