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


C++ BaseMolecule::getVertex方法代码示例

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


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

示例1: markIgnoredHydrogens

void MoleculeSubstructureMatcher::markIgnoredHydrogens (BaseMolecule &mol, int *arr, int value_keep, int value_ignore)
{
   int i;

   for (i = mol.vertexBegin(); i != mol.vertexEnd(); i = mol.vertexNext(i))
      arr[i] = value_keep;

   for (i = mol.vertexBegin(); i != mol.vertexEnd(); i = mol.vertexNext(i))
   {
      if (mol.getAtomNumber(i) != ELEM_H)
         continue;

      if (!mol.possibleAtomIsotope(i, 0))
         continue;

      if (mol.isQueryMolecule())
      {
         // Check if atom has fragment constraint.
         // For example [$([#1][N])] should be ignored
         if (mol.asQueryMolecule().getAtom(i).hasConstraint(QueryMolecule::ATOM_FRAGMENT))
            continue;
      }

      const Vertex &vertex = mol.getVertex(i);

      if (vertex.degree() == 1)
      {
         int nei_idx = vertex.neiVertex(vertex.neiBegin());

         if (mol.getAtomNumber(nei_idx) == ELEM_H && mol.possibleAtomIsotope(nei_idx, 0))
            continue; // do not ignore rare H-H fragment

         // Check if hydrogen forms a cis-trans bond or stereocenter
         int nei_vertex_idx = vertex.neiVertex(vertex.neiBegin());
         if (mol.stereocenters.exists(nei_vertex_idx))
            continue;

         // For example for this query hydrogens should be unfolded: [H]\\C=C/C
         const Vertex &nei_vertex = mol.getVertex(nei_vertex_idx);
         bool not_ignore = false;
         for (int nei = nei_vertex.neiBegin(); nei != nei_vertex.neiEnd(); nei = nei_vertex.neiNext(nei))
         {
            int edge = nei_vertex.neiEdge(nei);
            if (mol.cis_trans.getParity(edge) != 0)
            {
               not_ignore = true;
               break;
            }
         }
         if (not_ignore)
            continue;

         arr[i] = value_ignore;
      }
   }
}
开发者ID:mojca,项目名称:indigo,代码行数:56,代码来源:molecule_substructure_matcher.cpp

示例2: _commonHasLonePair

bool MoleculeCisTrans::_commonHasLonePair (BaseMolecule &mol, int v1, int v2)
{
   if (v1 != -1 && v2 != -1)
      return false;
   const Vertex *v;
   if (v1 == -1)
      v = &mol.getVertex(v2);
   else
      v = &mol.getVertex(v1);
   int common = v->neiVertex(v->neiBegin());
   if (mol.getAtomNumber(common) == ELEM_N && mol.getAtomCharge(common) == 0)
      return true;
   return false;
}
开发者ID:mojca,项目名称:indigo,代码行数:14,代码来源:molecule_cis_trans.cpp

示例3: _prepare_ee

bool ReactionExactMatcher::_prepare_ee (EmbeddingEnumerator &ee,
        BaseMolecule &submol, Molecule &supermol, void *context)
{
   int i;

   ReactionExactMatcher &self = *(ReactionExactMatcher *)context;
   
   for (i = submol.vertexBegin(); i != submol.vertexEnd(); i = submol.vertexNext(i))
   {
      const Vertex &vertex = submol.getVertex(i);

      if (submol.getAtomNumber(i) == ELEM_H && vertex.degree() == 1 &&
          submol.getAtomNumber(vertex.neiVertex(vertex.neiBegin())) != ELEM_H)
         if (submol.getAtomIsotope(i) == 0 || !(self.flags & MoleculeExactMatcher::CONDITION_ISOTOPE))
            ee.ignoreSubgraphVertex(i);
   }

   for (i = supermol.vertexBegin(); i != supermol.vertexEnd(); i = supermol.vertexNext(i))
   {
      const Vertex &vertex = supermol.getVertex(i);

      if (supermol.getAtomNumber(i) == ELEM_H && vertex.degree() == 1 &&
          supermol.getAtomNumber(vertex.neiVertex(vertex.neiBegin())) != ELEM_H)
         if (supermol.getAtomIsotope(i) == 0 || !(self.flags & MoleculeExactMatcher::CONDITION_ISOTOPE))
            ee.ignoreSupergraphVertex(i);
   }

   if (ee.countUnmappedSubgraphVertices() != ee.countUnmappedSupergraphVertices())
      return false;
   if (ee.countUnmappedSubgraphEdges() != ee.countUnmappedSupergraphEdges())
      return false;

   return true;
}
开发者ID:Lucas-Gluchowski,项目名称:Indigo,代码行数:34,代码来源:reaction_exact_matcher.cpp

示例4: _compare_in_loop

int MoleculeSubstructureMatcher::_compare_in_loop (BaseMolecule &mol, int i1, int i2)
{
   const Vertex &v1 = mol.getVertex(i1);
   const Vertex &v2 = mol.getVertex(i2);

   int in_loop1 = 0;
   for (int nei = v1.neiBegin(); nei != v1.neiEnd(); nei = v1.neiNext(nei))
   {
      int nei_edge = v1.neiEdge(nei);
      if (mol.getEdgeTopology(nei_edge) == TOPOLOGY_RING)
      {
         in_loop1 = 1;
         break;
      }
   }
   int in_loop2 = 0;
   for (int nei = v2.neiBegin(); nei != v2.neiEnd(); nei = v2.neiNext(nei))
   {
      int nei_edge = v2.neiEdge(nei);
      if (mol.getEdgeTopology(nei_edge) == TOPOLOGY_RING)
      {
         in_loop2 = 1;
         break;
      }
   }
   return in_loop2 - in_loop1;
}
开发者ID:mojca,项目名称:indigo,代码行数:27,代码来源:molecule_substructure_matcher.cpp

示例5: canApply

bool MoleculeLayoutMacrocycles::canApply (BaseMolecule &mol)
{
   if (!mol.isConnected(mol)) {
      return false;
   }

   for (int v = mol.vertexBegin(); v != mol.vertexEnd(); v = mol.vertexNext(v)) {
      if (mol.getVertex(v).degree() != 2) {
         return false;
      }
   }

   return true;
}
开发者ID:epam,项目名称:Indigo,代码行数:14,代码来源:molecule_layout_macrocycles.cpp

示例6: _fillAtomExplicitHydrogens

void MoleculeCisTrans::_fillAtomExplicitHydrogens (BaseMolecule &mol, int atom_idx, int subst[2])
{
   const Vertex &vertex = mol.getVertex(atom_idx);

   for (int i = vertex.neiBegin(); i != vertex.neiEnd(); i = vertex.neiNext(i))
   {
      int nei = vertex.neiVertex(i);
      // check [H]\N=C\C
      if (_pureH(mol, nei))
      {
         if (subst[0] != nei)
            subst[1] = nei;
         else if (subst[1] != nei)
            subst[0] = nei;
         else
            throw Error("internal error in _fillAtomExplicitHydrogens");
      }
   }
}
开发者ID:mojca,项目名称:indigo,代码行数:19,代码来源:molecule_cis_trans.cpp

示例7: _collectCrossBonds

void _collectCrossBonds (Array<int>& crossBonds, Array<bool>& crossBondOut, BaseMolecule& mol, const Array<int>& atoms)
{
   QS_DEF(Array<bool>, atomMask);
   atomMask.clear_resize(mol.vertexEnd());
   atomMask.fill(false);
   for (int i = 0; i < atoms.size(); ++i) {
      int aid = atoms[i];
      atomMask[aid] = true;
   }
   crossBonds.clear();
   crossBondOut.clear();
   for (int i = 0; i < atoms.size(); ++i) {
      int aid = atoms[i];
      const Vertex& v = mol.getVertex(aid);
      for (int j = v.neiBegin(); j < v.neiEnd(); j = v.neiNext(j)) {
         int naid = v.neiVertex(j);
         if (!atomMask[naid]) {
            int bid = v.neiEdge(j);
            crossBonds.push(bid);
            crossBondOut.push(mol.getEdge(bid).beg == aid);
         }
      }
   }
}
开发者ID:Lucas-Gluchowski,项目名称:Indigo,代码行数:24,代码来源:molecule_layout.cpp

示例8: isGeomStereoBond

bool MoleculeCisTrans::isGeomStereoBond (BaseMolecule &mol, int bond_idx,
                                         int *substituents, bool have_xyz)
{
   int substituents_local[4];

   if (substituents == 0)
      substituents = substituents_local;

   // it must be [C,N,Si,Ge]=[C,N,Si,Ge] bond
   if (!mol.possibleBondOrder(bond_idx, BOND_DOUBLE))
      return false;

   const Edge &edge = mol.getEdge(bond_idx);
   int beg_idx = edge.beg;
   int end_idx = edge.end;

   if (!mol.possibleAtomNumber(beg_idx, ELEM_C) &&
       !mol.possibleAtomNumber(beg_idx, ELEM_N) &&
       !mol.possibleAtomNumber(beg_idx, ELEM_Si) &&
       !mol.possibleAtomNumber(beg_idx, ELEM_Ge))
      return false;
   if (!mol.possibleAtomNumber(end_idx, ELEM_C) &&
       !mol.possibleAtomNumber(end_idx, ELEM_N) &&
       !mol.possibleAtomNumber(end_idx, ELEM_Si) &&
       !mol.possibleAtomNumber(end_idx, ELEM_Ge))
      return false;

   // Double bonds with R-sites are excluded because cis-trans configuration 
   // cannot be determined when R-site is substituted with R-group
   if (mol.isRSite(beg_idx) || mol.isRSite(end_idx))
      return false;

   // the atoms should have 1 or 2 single bonds
   // (apart from the double bond under consideration)
   const Vertex &beg = mol.getVertex(beg_idx);
   const Vertex &end = mol.getVertex(end_idx);

   if (beg.degree() < 2 || beg.degree() > 3 ||
       end.degree() < 2 || end.degree() > 3)
      return false;

   substituents[0] = -1;
   substituents[1] = -1;
   substituents[2] = -1;
   substituents[3] = -1;

   int i;

   for (i = beg.neiBegin(); i != beg.neiEnd(); i = beg.neiNext(i))
   {
      int nei_edge_idx = beg.neiEdge(i);

      if (nei_edge_idx == bond_idx)
         continue;
      
      if (!mol.possibleBondOrder(nei_edge_idx, BOND_SINGLE))
         return false;

      if (substituents[0] == -1)
         substituents[0] = beg.neiVertex(i);
      else // (substituents[1] == -1)
         substituents[1] = beg.neiVertex(i);
   }

   for (i = end.neiBegin(); i != end.neiEnd(); i = end.neiNext(i))
   {
      int nei_edge_idx = end.neiEdge(i);

      if (nei_edge_idx == bond_idx)
         continue;
      
      if (!mol.possibleBondOrder(nei_edge_idx, BOND_SINGLE))
         return false;

      if (substituents[2] == -1)
         substituents[2] = end.neiVertex(i);
      else // (substituents[3] == -1)
         substituents[3] = end.neiVertex(i);
   }

   // Check trianges when substituents are the same: CC1=C(N)C1
   if (substituents[0] >= 0)
      if (substituents[0] == substituents[2] || substituents[0] == substituents[3])
         return false;
   if (substituents[1] >= 0)
      if (substituents[1] == substituents[2] || substituents[1] == substituents[3])
         return false;

   if (have_xyz)
   {
      if (substituents[1] != -1 &&
          _sameside(mol, beg_idx, end_idx, substituents[0], substituents[1]) != -1)
         return false;
      else if (_sameline(mol, beg_idx, end_idx, substituents[0]))
         return false;

      if (substituents[3] != -1 &&
          _sameside(mol, beg_idx, end_idx, substituents[2], substituents[3]) != -1)
         return false;
      else if (_sameline(mol, beg_idx, end_idx, substituents[2]))
//.........这里部分代码省略.........
开发者ID:mojca,项目名称:indigo,代码行数:101,代码来源:molecule_cis_trans.cpp

示例9: Error

bool MoleculeSubstructureMatcher::matchQueryAtom
         (QueryMolecule::Atom *query, BaseMolecule &target, int super_idx,
         FragmentMatchCache *fmcache, dword flags)
{
   int i;

   switch (query->type)
   {
      case QueryMolecule::OP_NONE:
         return true;
      case QueryMolecule::OP_AND:
         for (i = 0; i < query->children.size(); i++)
            if (!matchQueryAtom(query->child(i), target, super_idx, fmcache, flags))
               return false;
         return true;
      case QueryMolecule::OP_OR:
         for (i = 0; i < query->children.size(); i++)
            if (matchQueryAtom(query->child(i), target,
                               super_idx, fmcache, flags))
               return true;
         return false;
      case QueryMolecule::OP_NOT:
         return !matchQueryAtom(query->child(0), target, super_idx, fmcache,
                                flags ^ MATCH_DISABLED_AS_TRUE);

      case QueryMolecule::ATOM_NUMBER:
         return query->valueWithinRange(target.getAtomNumber(super_idx));
      case QueryMolecule::ATOM_PSEUDO:
         return target.isPseudoAtom(super_idx) &&
                 strcmp(query->alias.ptr(), target.getPseudoAtom(super_idx)) == 0;
      case QueryMolecule::ATOM_RSITE:
         return true;
      case QueryMolecule::ATOM_ISOTOPE:
         return query->valueWithinRange(target.getAtomIsotope(super_idx));
      case QueryMolecule::ATOM_CHARGE:
      {
         if (flags & MATCH_ATOM_CHARGE)
            return query->valueWithinRange(target.getAtomCharge(super_idx));
         return (flags & MATCH_DISABLED_AS_TRUE) != 0;
      }
      case QueryMolecule::ATOM_RADICAL:
      {
         if (target.isPseudoAtom(super_idx) || target.isRSite(super_idx))
            return false;
         return query->valueWithinRange(target.getAtomRadical(super_idx));
      }
      case QueryMolecule::ATOM_VALENCE:
      {
         if (flags & MATCH_ATOM_VALENCE)
         {
            if (target.isPseudoAtom(super_idx) || target.isRSite(super_idx))
               return false;
            return query->valueWithinRange(target.getAtomValence(super_idx));
         }
         return (flags & MATCH_DISABLED_AS_TRUE) != 0;
      }
      case QueryMolecule::ATOM_CONNECTIVITY:
      {
         int conn = target.getVertex(super_idx).degree();
         if (!target.isPseudoAtom(super_idx) && !target.isRSite(super_idx))
            conn += target.asMolecule().getImplicitH(super_idx);
         return query->valueWithinRange(conn);
      }
      case QueryMolecule::ATOM_TOTAL_BOND_ORDER:
      {
         // TODO: target.isPseudoAtom(super_idx) || target.isRSite(super_idx)
         return query->valueWithinRange(target.asMolecule().getAtomConnectivity(super_idx));
      }
      case QueryMolecule::ATOM_TOTAL_H:
      {
         if (target.isPseudoAtom(super_idx) || target.isRSite(super_idx))
            return false;
         return query->valueWithinRange(target.getAtomTotalH(super_idx));
      }
      case QueryMolecule::ATOM_SUBSTITUENTS:
         return query->valueWithinRange(target.getAtomSubstCount(super_idx));
      case QueryMolecule::ATOM_SSSR_RINGS:
         return query->valueWithinRange(target.vertexCountSSSR(super_idx));
      case QueryMolecule::ATOM_SMALLEST_RING_SIZE:
         return query->valueWithinRange(target.vertexSmallestRingSize(super_idx));
      case QueryMolecule::ATOM_RING_BONDS:
      case QueryMolecule::ATOM_RING_BONDS_AS_DRAWN:
         return query->valueWithinRange(target.getAtomRingBondsCount(super_idx));
      case QueryMolecule::ATOM_UNSATURATION:
         return !target.isSaturatedAtom(super_idx);
      case QueryMolecule::ATOM_FRAGMENT:
      {
         if (fmcache == 0)
            throw Error("unexpected 'fragment' constraint");

         QueryMolecule *fragment = query->fragment.get();
         const char *smarts = fragment->fragment_smarts.ptr();

         if (fragment->vertexCount() == 0)
            throw Error("empty fragment");

         if (smarts != 0 && strlen(smarts) > 0)
         {
            fmcache->expand(super_idx + 1);
            int *value = fmcache->at(super_idx).at2(smarts);
//.........这里部分代码省略.........
开发者ID:mojca,项目名称:indigo,代码行数:101,代码来源:molecule_substructure_matcher.cpp

示例10: _compare_degree_asc

int MoleculeSubstructureMatcher::_compare_degree_asc (BaseMolecule &mol, int i1, int i2)
{
   return mol.getVertex(i2).degree() - mol.getVertex(i1).degree();
}
开发者ID:mojca,项目名称:indigo,代码行数:4,代码来源:molecule_substructure_matcher.cpp


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