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


C++ OBAtom类代码示例

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


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

示例1: 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

示例2: ReadHIN

bool ReadHIN(istream &ifs,OBMol &mol, const char *title)
{ 
  // Right now only read in the first molecule
  int i;
  int max, bo;
  char buffer[BUFF_SIZE];
  string str,str1;
  double x,y,z;
  OBAtom *atom;
  vector<string> vs;

  ifs.getline(buffer, BUFF_SIZE);
  while (strstr(buffer,"mol") == NULL)
    ifs.getline(buffer, BUFF_SIZE);
  ifs.getline(buffer, BUFF_SIZE);
  
  mol.BeginModify();
  while (strstr(buffer,"endmol") == NULL)
    {
      tokenize(vs,buffer); // Don't really know how long it'll be
      if (vs.size() < 11) break;
      atom = mol.NewAtom();
      atom->SetAtomicNum(etab.GetAtomicNum(vs[3].c_str()));
      x = atof((char*)vs[7].c_str());
      y = atof((char*)vs[8].c_str());
      z = atof((char*)vs[9].c_str());
      atom->SetVector(x,y,z);
      
      max = 11 + 2 * atoi((char *)vs[10].c_str());
      for (i = 11; i < max; i+=2)
	{
	  switch(((char*)vs[i+1].c_str())[0]) // First char in next token
	    {
	    case 's': bo = 1; break;
	    case 'd': bo = 2; break;
	    case 't': bo = 3; break;
	    case 'a': bo = 5; break;
	    default : bo = 1; break;
	    }
	  mol.AddBond(mol.NumAtoms(), atoi((char *)vs[i].c_str()), bo);
	}
      ifs.getline(buffer, BUFF_SIZE);
    }
  mol.EndModify();

  mol.SetTitle(title);
  return(true);
}
开发者ID:daju1,项目名称:winlibghemical,代码行数:48,代码来源:hin.cpp

示例3: testIdsAddAtom

void testIdsAddAtom()
{
  OBMol mol;
  // add 5 atoms
  for (int i = 0; i < 5; ++i)
    mol.NewAtom();

  OBAtom a;
  a.SetAtomicNum(6);
  // add a sixth atom
  mol.AddAtom(a);

  OB_REQUIRE( mol.NumAtoms() == 6 );
  OB_REQUIRE( mol.GetAtomById(5) );
  OB_REQUIRE( mol.GetAtomById(5)->GetId() == 5 );
}
开发者ID:Antipina,项目名称:OpenBabel-BFGS,代码行数:16,代码来源:uniqueidtest.cpp

示例4: _parent

  OBMolAtomDFSIter::OBMolAtomDFSIter(OBMol &mol, int StartIndex):
    _parent(&mol), _ptr(_parent->GetAtom(StartIndex))
  {
    _notVisited.Resize(_parent->NumAtoms());
    _notVisited.Negate(); // all on
    _notVisited.SetBitOff(_ptr->GetIdx() - 1);

    vector<OBBond*>::iterator i;
    OBAtom *a;

    for (a = _ptr->BeginNbrAtom(i); a; a = _ptr->NextNbrAtom(i))
      {
        _stack.push(a);
        _notVisited.SetBitOff(a->GetIdx() - 1);
      }
  }
开发者ID:baoilleach,项目名称:obstereo-2-2-x,代码行数:16,代码来源:obiter.cpp

示例5: 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

示例6: ReadMolecule

bool BoxFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)
{

    OBMol* pmol = pOb->CastAndClear<OBMol>();
    if(pmol==NULL)
        return false;

    //Define some references so we can use the old parameter names
    istream &ifs = *pConv->GetInStream();
    OBMol &mol = *pmol;
    const char* title = pConv->GetTitle();

    char buffer[BUFF_SIZE];
    vector<string> vs;
    vector<string>::iterator i;
    OBAtom atom;

    mol.BeginModify();

    while (ifs.getline(buffer,BUFF_SIZE) && !EQn(buffer,"END",3))
    {
        if (EQn(buffer,"ATOM",4))
        {
            string sbuf = &buffer[6];
            /* X, Y, Z */
            string x = sbuf.substr(24,8);
            string y = sbuf.substr(32,8);
            string z = sbuf.substr(40,8);
            vector3 v(atof(x.c_str()),atof(y.c_str()),atof(z.c_str()));
            atom.SetVector(v);
            if (!mol.AddAtom(atom))
                return(false);
        }

        if (EQn(buffer,"CONECT",6))
        {
            tokenize(vs,buffer);
            if (!vs.empty() && vs.size() > 2)
                for (i = vs.begin(),i+=2; i != vs.end(); i++)
                    mol.AddBond(atoi(vs[1].c_str()),atoi((*i).c_str()),1);
        }
    }

    mol.EndModify();
    mol.SetTitle(title);
    return(true);
}
开发者ID:baoilleach,项目名称:openbabel-svn-mirror,代码行数:47,代码来源:boxformat.cpp

示例7: WriteCharges

  void WriteCharges(ostream &ofs,OBMol &mol)
  {
    unsigned int i;
    OBAtom *atom;
    char buffer[BUFF_SIZE];
    
    for(i = 1;i <= mol.NumAtoms(); i++)
      {
	atom = mol.GetAtom(i);
	sprintf(buffer,"%4s%4d   % 2.10f",
		etab.GetSymbol(atom->GetAtomicNum()),
		i,
		atom->GetPartialCharge());
	
	ofs << buffer << endl;
      }
  }
开发者ID:daju1,项目名称:winlibghemical,代码行数:17,代码来源:report.cpp

示例8: _parent

  OBMolAtomDFSIter::OBMolAtomDFSIter(OBMol *mol, int StartIndex):
    _parent(mol), _ptr(_parent->GetAtom(StartIndex))
  {
    _notVisited.Resize(_parent->NumAtoms());
    _notVisited.SetRangeOn(0, _parent->NumAtoms() - 1);
    if (!_ptr) return;
    _notVisited.SetBitOff(_ptr->GetIdx() - 1);

    vector<OBBond*>::iterator i;
    OBAtom *a;

    for (a = _ptr->BeginNbrAtom(i); a; a = _ptr->NextNbrAtom(i))
      {
        _stack.push(a);
        _notVisited.SetBitOff(a->GetIdx() - 1);
      }
  }
开发者ID:Acpharis,项目名称:openbabel,代码行数:17,代码来源:obiter.cpp

示例9: WriteCharges

  void ReportFormat::WriteCharges(ostream &ofs,OBMol &mol)
  {
    unsigned int i;
    OBAtom *atom;
    char buffer[BUFF_SIZE];

    for(i = 1;i <= mol.NumAtoms(); i++)
      {
        atom = mol.GetAtom(i);
        snprintf(buffer, BUFF_SIZE, "%4s%4d   % 2.10f",
                OBElements::GetSymbol(atom->GetAtomicNum()),
                i,
                atom->GetPartialCharge());

        ofs << buffer << "\n";
      }
  }
开发者ID:Reinis,项目名称:openbabel,代码行数:17,代码来源:reportformat.cpp

示例10: testIdsNewAtom1

// OBMol::NewAtom()
void testIdsNewAtom1()
{
  OBMol mol;
  for (int i = 0; i < 10; ++i) {
    OBAtom *atom = mol.NewAtom();
    OB_REQUIRE(atom->GetId() == i);
  }

  OB_REQUIRE( mol.GetAtomById(0) );
  OB_REQUIRE( mol.GetAtomById(4) );
  OB_REQUIRE( mol.GetAtomById(9) );
  OB_REQUIRE( !mol.GetAtomById(10) );

  OB_REQUIRE( mol.GetAtomById(0)->GetId() == 0 );
  OB_REQUIRE( mol.GetAtomById(4)->GetId() == 4 );
  OB_REQUIRE( mol.GetAtomById(9)->GetId() == 9 );
}
开发者ID:Antipina,项目名称:OpenBabel-BFGS,代码行数:18,代码来源:uniqueidtest.cpp

示例11: ring

  /** \brief Traverse a potentially aromatic cycle starting at @p root.
      \return  True if the cycle is likely aromatic
      \param root  The initial, "root" atom in traversing this ring
      \param atom  The current atom to visit and check
      \param prev  The bond traversed in moving to this @p atom
      \param er    The min and max number of pi electrons for this ring
      \param depth The maximum number of atoms to visit in a ring (e.g., 6)

      This method traverses a potentially aromatic ring, adding up the possible
      pi electrons for each atom. At the end (e.g., when @p atom == @p root)
      the Huekel 4n+2 rule is checked to see if there is a possible electronic
      configuration which corresponds to aromaticity.
  **/
  bool OBAromaticTyper::TraverseCycle(OBAtom *root, OBAtom *atom, OBBond *prev, 
                                      std::pair<int,int> &er,int depth)
  {
    if (atom == root)
      {
        int i;
        for (i = er.first;i <= er.second;++i)
          if (i%4 == 2 && i > 2)
            return(true);

        return(false);
      }

    if (!depth || !_vpa[atom->GetIdx()] || _visit[atom->GetIdx()])
      return(false);

    bool result = false;

    depth--;
    er.first  += _velec[atom->GetIdx()].first;
    er.second += _velec[atom->GetIdx()].second;

    _visit[atom->GetIdx()] = true;
    OBAtom *nbr;
    vector<OBBond*>::iterator i;
    for (nbr = atom->BeginNbrAtom(i);nbr;nbr = atom->NextNbrAtom(i))
      if (*i != prev && (*i)->IsInRing() && _vpa[nbr->GetIdx()])
        {
          if (TraverseCycle(root,nbr,(OBBond*)(*i),er,depth))
            {
              result = true;
              ((OBBond*) *i)->SetAromatic();
            }
        }

    _visit[atom->GetIdx()] = false;
    if (result)
      atom->SetAromatic();

    er.first  -= _velec[atom->GetIdx()].first;
    er.second -= _velec[atom->GetIdx()].second;

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

示例12: 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

示例13: testIdsNewAtom2

// OBMol::NewAtom(unsigned long id)
void testIdsNewAtom2()
{
  OBMol mol;
  for (int i = 0; i < 10; ++i) {
    OBAtom *atom = mol.NewAtom(i*2);
    OB_REQUIRE(atom->GetId() == i*2);
  }

  OB_REQUIRE( mol.GetAtomById(0) );
  OB_REQUIRE( !mol.GetAtomById(7) );
  OB_REQUIRE( mol.GetAtomById(8) );
  OB_REQUIRE( !mol.GetAtomById(9) );
  OB_REQUIRE( mol.GetAtomById(18) );
  OB_REQUIRE( !mol.GetAtomById(19) );

  OB_REQUIRE( mol.GetAtomById(0)->GetId() == 0 );
  OB_REQUIRE( mol.GetAtomById(8)->GetId() == 8 );
  OB_REQUIRE( mol.GetAtomById(18)->GetId() == 18 );
}
开发者ID:Antipina,项目名称:OpenBabel-BFGS,代码行数:20,代码来源:uniqueidtest.cpp

示例14: PropagatePotentialAromatic

  void OBAromaticTyper::PropagatePotentialAromatic(OBAtom *atom)
  {
    int count = 0;
    OBAtom *nbr;
    vector<OBBond*>::iterator i;

    for (nbr = atom->BeginNbrAtom(i);nbr;nbr = atom->NextNbrAtom(i))
      if ((*i)->IsInRing() && _vpa[nbr->GetIdx()])
        count++;

    if (count < 2)
      {
        _vpa[atom->GetIdx()] = false;
        if (count == 1)
          for (nbr = atom->BeginNbrAtom(i);nbr;nbr = atom->NextNbrAtom(i))
            if ((*i)->IsInRing() && _vpa[nbr->GetIdx()])
              PropagatePotentialAromatic(nbr);
      }
  }
开发者ID:annulen,项目名称:openbabel,代码行数:19,代码来源:typer.cpp

示例15: atomPos

BoundingBox
NXOpenGLRenderingEngine::GetBoundingBox(OBMol *const molPtr)
{
    BoundingBox bbox;
    OBAtomIterator atomIter;
    OBAtom *atomPtr = NULL;

    for(atomPtr = molPtr->BeginAtom(atomIter);
        atomPtr != NULL;
        atomPtr = molPtr->NextAtom(atomIter))
    {
        Vector atomPos(real(atomPtr->GetX()),
                       real(atomPtr->GetY()),
                       real(atomPtr->GetZ()));
        bbox += atomPos;
    }

    return bbox;
}
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:19,代码来源:NXOpenGLRenderingEngine.cpp


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