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


C++ MolAtomPtr::getParentResidue方法代码示例

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


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

示例1: drawRings

void BallStickRenderer::drawRings(DisplayContext *pdl)
{
  int i, j;
  MolCoordPtr pMol = getClientMol();

  while (m_atoms.size()>0) {
    std::set<int>::iterator iter = m_atoms.begin();
    int aid = *iter;
    m_atoms.erase(iter);

    MolAtomPtr pa = pMol->getAtom(aid);
    if (pa.isnull()) continue;

    MolResiduePtr pres = pa->getParentResidue();
    
    ResiToppar *ptop = pres->getTopologyObj();
    if (ptop==NULL)
      continue;

    // draw rings
    int nrings = ptop->getRingCount();
    for (i=0; i<nrings; i++) {
      const ResiToppar::RingAtomArray *pmembs = ptop->getRing(i);
      std::list<int> ring_atoms;

      // completeness flag of the ring
      bool fcompl = true;

      for (j=0; j<pmembs->size(); j++) {
        LString nm = pmembs->at(j);
        int maid = pres->getAtomID(nm);
        if (maid<=0) {
          fcompl = false;
          break;
        }

        std::set<int>::const_iterator miter = m_atoms.find(maid);
        if (miter==m_atoms.end()) {
          if (aid!=maid) {
            fcompl = false;
            break;
          }
          else {
            ring_atoms.push_back(aid);
            continue;
          }
        }

        ring_atoms.push_back(*miter);
      }

      if (fcompl)
        drawRingImpl(ring_atoms, pdl);
    }

    // remove drawn ring members from m_atoms
    for (i=0; i<nrings; i++) {
      const ResiToppar::RingAtomArray *pmembs = ptop->getRing(i);
      for (j=0; j<pmembs->size(); j++) {
        LString nm = pmembs->at(j);
        int maid = pres->getAtomID(nm);
        if (maid<=0)
          continue;

        std::set<int>::iterator miter = m_atoms.find(maid);
        if (miter==m_atoms.end())
          continue;

        m_atoms.erase(miter);
      }
    }
  }

}
开发者ID:biochem-fan,项目名称:cuemol2,代码行数:74,代码来源:BallStickRenderer.cpp

示例2: drawRingImpl

void BallStickRenderer::drawRingImpl(const std::list<int> atoms, DisplayContext *pdl)
{
  MolCoordPtr pMol = getClientMol();

  double len;
  int i, nsize = atoms.size();
  Vector4D *pvecs = MB_NEW Vector4D[nsize];
  Vector4D cen;
  std::list<int>::const_iterator iter = atoms.begin();
  std::list<int>::const_iterator eiter = atoms.end();
  MolAtomPtr pPivAtom, pAtom;
  for (i=0; iter!=eiter; ++iter, i++) {
    MolAtomPtr pAtom = pMol->getAtom(*iter);
    if (pAtom.isnull()) return;
    MolResiduePtr pres = pAtom->getParentResidue();
    MolChainPtr pch = pAtom->getParentChain();
    MB_DPRINTLN("RING %s %s", pres->toString().c_str(), pAtom->getName().c_str());
    pvecs[i] = pAtom->getPos();
    cen += pvecs[i];
    if (pPivAtom.isnull() && pAtom->getElement()==ElemSym::C)
      pPivAtom = pAtom;
  }

  if (pPivAtom.isnull())
    pPivAtom = pAtom; // no carbon atom --> last atom becomes pivot

  cen = cen.divide(nsize);

  // calculate the normal vector
  Vector4D norm;
  for (i=0; i<nsize; i++) {
    int ni = (i+1)%nsize;
    Vector4D v1 = pvecs[ni] - pvecs[i];
    Vector4D v2 = cen - pvecs[i];
    Vector4D ntmp;
    ntmp = v1.cross(v2);
    len = ntmp.length();
    if (len<=F_EPS8) {
      LOG_DPRINTLN("BallStick> *****");
      return;
    }
    //ntmp.scale(1.0/len);
    ntmp = ntmp.divide(len);
    norm += ntmp;
  }
  len = norm.length();
  norm = norm.divide(len);
  Vector4D dv = norm.scale(m_tickness);

  ColorPtr col = evalMolColor(m_ringcol, ColSchmHolder::getColor(pPivAtom));

  /*
  ColorPtr col = m_ringcol;

  // check molcol reference
  gfx::MolColorRef *pMolCol = dynamic_cast<gfx::MolColorRef *>(col.get());
  if (pMolCol!=NULL) {
    // molcol ref case --> resolve the pivot's color
    col = ColSchmHolder::getColor(pPivAtom);
  }
  */
  
  pdl->setPolygonMode(gfx::DisplayContext::POLY_FILL_NOEGLN);
  pdl->startTriangleFan();
  pdl->normal(norm);
  pdl->color(col);
  pdl->vertex(cen+dv);
  for (i=0; i<=nsize; i++) {
    pdl->vertex(pvecs[i%nsize]+dv);
  }
  pdl->end();

  pdl->startTriangleFan();
  pdl->normal(-norm);
  pdl->color(col);
  pdl->vertex(cen-dv);
  for (i=nsize; i>=0; i--) {
    pdl->vertex(pvecs[i%nsize]-dv);
  }
  pdl->end();
  pdl->setPolygonMode(gfx::DisplayContext::POLY_FILL);
  
  delete [] pvecs;

}
开发者ID:biochem-fan,项目名称:cuemol2,代码行数:85,代码来源:BallStickRenderer.cpp

示例3: if


//.........这里部分代码省略.........

      atommap.insert(std::pair<int,int>(ind, naid));
      m_nReadAtoms++;
    }

    prev_resid = iresid;

  }
  
  // Search BOND record
  for (;;) {
    sline = lin.readLine().chomp();
    if (sline.isEmpty() && !lin.ready())
      return false; // EOF
  
    if (sline.equals("@<TRIPOS>BOND")) {
      break;
    }
  }

  int natm1, natm2;
  int natm_id1, natm_id2;
  std::map<int,int>::const_iterator iter;
  
  for (i=0; i<nbonds; ++i) {

    sline = lin.readLine().chomp();
    slist.clear();
    split(sline, ' ', std::back_inserter(slist));
    if (slist.size()<4) {
      MB_THROW(MOL2FormatException, "Invalid bond record");
    }

    if (!slist[1].toInt(&natm1)) {
      MB_THROW(MOL2FormatException, "Invalid bond line (atom1)");
    }
    if (!slist[2].toInt(&natm2)) {
      MB_THROW(MOL2FormatException, "Invalid bond line (atom2)");
    }
    LString sbont = slist[3];

    if (!bskip) {
      iter = atommap.find(natm1);
      if (iter==atommap.end())
	MB_THROW(MOL2FormatException, "Invalid bond line (bond atom1 not found)");
      natm_id1 = iter->second;

      iter = atommap.find(natm2);
      if (iter==atommap.end())
	MB_THROW(MOL2FormatException, "Invalid bond line (bond atom2 not found)");
      natm_id2 = iter->second;

      MolBond *pB = m_pMol->makeBond(natm_id1, natm_id2, true);
      if (pB==NULL)
	MB_THROW(MOL2FormatException, "makeBond failed");

      if (sbont.equals("1"))
	pB->setType(MolBond::SINGLE);
      else if (sbont.equals("2"))
	pB->setType(MolBond::DOUBLE);
      else if (sbont.equals("3"))
	pB->setType(MolBond::TRIPLE);
      else if (sbont.equals("ar")||sbont.equals("am"))
	pB->setType(MolBond::DELOC);

      m_nReadBonds++;
    }

    //LOG_DPRINTLN("bond %d<-->%d: %d", natm_id1, natm_id2, nbont);
  }
  
  if (bApplyTopo) {
    m_pMol->applyTopology();
    if (mol_type.equals("PROTEIN"))
      m_pMol->calcProt2ndry(-500.0);
    if (mol_type.equals("NUCLEIC_ACID"))
      m_pMol->calcBasePair(3.7, 30);
  }
  else {
    // Set noautogen prop to this residue,
    // to avoid topology autogen, when saved to and loaded from the qdf stream.
    if (!bskip) {
      iter = atommap.begin();
      if (iter!=atommap.end()) {
	int aid0 = iter->second;
	MolAtomPtr pA = m_pMol->getAtom(aid0);
	if (!pA.isnull()) {
	  MolResiduePtr pRes = pA->getParentResidue();
	  if (!pRes.isnull()) {
	    pRes->setPropStr("noautogen", "true");
	  }
	}
      }      
    }
  }
  /*
  */

  return true;
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:101,代码来源:MOL2MolReader.cpp


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