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


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

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


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

示例1: getHCount

int MoleculeSavers::getHCount (BaseMolecule &mol, int index, int atom_number, int atom_charge)
{
   int hydrogens_count = -1;
   if (!mol.isRSite(index) && !mol.isPseudoAtom(index) && !mol.isTemplateAtom(index))
   {
      if (!mol.isQueryMolecule())
      {
         if (mol.getAtomAromaticity(index) == ATOM_AROMATIC &&
            ((atom_number != ELEM_C && atom_number != ELEM_O) || atom_charge != 0))
            hydrogens_count = mol.asMolecule().getImplicitH_NoThrow(index, -1);
      }
      else
      {
         QueryMolecule::Atom &atom = mol.asQueryMolecule().getAtom(index);

         if (!atom.sureValue(QueryMolecule::ATOM_TOTAL_H, hydrogens_count))
         {
            // Try to check if there are only one constraint
            QueryMolecule::Atom *constraint = atom.sureConstraint(QueryMolecule::ATOM_TOTAL_H);
            if (constraint != NULL)
               hydrogens_count = constraint->value_min;
            else
               hydrogens_count = -1;
         }
      }
   }
   return hydrogens_count;
}
开发者ID:Lucas-Gluchowski,项目名称:Indigo,代码行数:28,代码来源:molecule_savers.cpp

示例2: collect

void GrossFormula::collect (BaseMolecule &mol, Array<int> &gross)
{
   int i;

   gross.clear_resize(ELEM_MAX);
   gross.zerofill();

   for (i = mol.vertexBegin(); i < mol.vertexEnd(); i = mol.vertexNext(i))
   {
      if (mol.isPseudoAtom(i) || mol.isRSite(i))
         continue;
      int number = mol.getAtomNumber(i);

      if (number > 0)
         gross[number]++;

      if (!mol.isQueryMolecule())
      {
         int implicit_h = mol.asMolecule().getImplicitH(i);

         if (implicit_h >= 0)
            gross[ELEM_H] += implicit_h;
      }
   }
}
开发者ID:Rillke,项目名称:indigo,代码行数:25,代码来源:gross_formula.cpp

示例3: _makeFingerprint

void MoleculeFingerprintBuilder::_makeFingerprint (BaseMolecule &mol)
{
   QS_DEF(Filter, vfilter);
   int i;

   vfilter.initAll(mol.vertexEnd());

   // remove (possible) hydrogens
   for (i = mol.vertexBegin(); i < mol.vertexEnd(); i = mol.vertexNext(i))
      if (mol.possibleAtomNumber(i, ELEM_H))
         vfilter.hide(i);

   Obj<TautomerSuperStructure> tau_super_structure;
   BaseMolecule *mol_for_enumeration = &mol;
   
   if (!query && _parameters.tau_qwords > 0 && !skip_tau)
   {
      tau_super_structure.create(mol.asMolecule());

      _tau_super_structure = tau_super_structure.get();
      mol_for_enumeration = tau_super_structure.get();
   }
   else
      _tau_super_structure = 0;
   
   if (!skip_ord || !skip_any_atoms || !skip_any_atoms_bonds ||
       !skip_any_bonds || !skip_tau || !skip_sim)
   {
      _initHashCalculations(*mol_for_enumeration);

      CycleEnumerator ce(*mol_for_enumeration);
      GraphSubtreeEnumerator se(*mol_for_enumeration);

      ce.vfilter = &vfilter;
      se.vfilter = &vfilter;

      bool sim_only = skip_ord && skip_tau && skip_any_atoms &&
                      skip_any_atoms_bonds && skip_any_bonds;

      _is_cycle = true;
      ce.context = this;
      ce.max_length = sim_only ? 6 : 8;
      ce.cb_handle_cycle = _handleCycle;
      ce.process();
   
      _is_cycle = false;
      se.context = this;
      se.min_vertices = 1;
      se.max_vertices = sim_only ? 5 : 7;
      se.handle_maximal = false;
      se.maximal_critera_value_callback = _maximalSubgraphCriteriaValue;
      se.callback = _handleTree;
      se.process();
   }
   
   if (!skip_ext && _parameters.ext)
      _calcExtraBits(mol, vfilter);
}
开发者ID:Rillke,项目名称:indigo,代码行数:58,代码来源:molecule_fingerprint.cpp

示例4: cloneGraph

LayeredMolecules::LayeredMolecules(BaseMolecule& molecule)
   :_layersAromatized(0)
{
   _proto.clone(molecule.asMolecule(), 0, 0);
   _proto.dearomatize(AromaticityOptions());

   cloneGraph(_proto, 0);

   for (auto e_idx : _proto.edges())
   {
      for(auto i = 0; i < BOND_TYPES_NUMBER; ++i)
      {
         _bond_masks[i].push();
         _bond_masks[i].top().resize(1);
      }

      _bond_masks[BOND_ZERO].top().reset(0);
      _bond_masks[BOND_SINGLE].top().reset(0);
      _bond_masks[BOND_DOUBLE].top().reset(0);
      _bond_masks[BOND_TRIPLE].top().reset(0);
      _bond_masks[BOND_AROMATIC].top().reset(0);
      _bond_masks[_proto.getBondOrder(e_idx)].top().set(0);
   }

   _mobilePositions.expandFill(_proto.vertexCount(), false);
   _mobilePositionsOccupied.expand(_proto.vertexCount());

   layers = 1;

   unsigned node = _trie.getRoot();
   for (auto i : _proto.edges())
   {
      bool stub;
      node = _trie.add(node, _proto.getBondOrder(i), stub);
   }
   _hashs.push(node);
}
开发者ID:Lucas-Gluchowski,项目名称:Indigo,代码行数:37,代码来源:molecule_layered_molecules.cpp

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

示例6: _loadMolecule

void MoleculeAutoLoader::_loadMolecule (BaseMolecule &mol, bool query)
{
   properties.clear();

   // check for GZip format
   if (!query && _scanner->length() >= 2)
   {
      byte id[2];
      int pos = _scanner->tell();

      _scanner->readCharsFix(2, (char *)id);
      _scanner->seek(pos, SEEK_SET);

      if (id[0] == 0x1f && id[1] == 0x8b)
      {
         GZipScanner gzscanner(*_scanner);
         QS_DEF(Array<char>, buf);

         gzscanner.readAll(buf);
         MoleculeAutoLoader loader2(buf);

         loader2.ignore_stereocenter_errors = ignore_stereocenter_errors;
         loader2.ignore_noncritical_query_features = ignore_noncritical_query_features;
         loader2.treat_x_as_pseudoatom = treat_x_as_pseudoatom;
         loader2.skip_3d_chirality = skip_3d_chirality;
         loader2.loadMolecule((Molecule &)mol);
         return;
      }
   }

   // check for MDLCT format
   {
      QS_DEF(Array<char>, buf);
      if (tryMDLCT(*_scanner, buf))
      {
         BufferScanner scanner2(buf);
         MolfileLoader loader(scanner2);
         loader.ignore_stereocenter_errors = ignore_stereocenter_errors;
         loader.ignore_noncritical_query_features = ignore_noncritical_query_features;
         loader.skip_3d_chirality = skip_3d_chirality;
         loader.treat_x_as_pseudoatom = treat_x_as_pseudoatom;

         if (query)
            loader.loadQueryMolecule((QueryMolecule &)mol);
         else
            loader.loadMolecule((Molecule &)mol);
         return;
      }
   }

   // check for ICM format
   if (!query && _scanner->length() >= 4)
   {
      char id[3];
      int pos = _scanner->tell();

      _scanner->readCharsFix(3, id);
      _scanner->seek(pos, SEEK_SET);
      if (IcmSaver::checkVersion(id))
      {
         if (query)
            throw Error("cannot load query molecule from ICM format");

         IcmLoader loader(*_scanner);
         loader.loadMolecule((Molecule &)mol);
         return;
      }
   }

   // check for CML format
   {
      int pos = _scanner->tell();
      _scanner->skipSpace();

      if (_scanner->lookNext() == '<')
      {
         if (_scanner->findWord("<molecule"))
         {
            MoleculeCmlLoader loader(*_scanner);
            loader.ignore_stereochemistry_errors = ignore_stereocenter_errors;
            if (query)
               throw Error("CML queries not supported");
            loader.loadMolecule(mol.asMolecule());
            return;
         }
      }

      _scanner->seek(pos, SEEK_SET);
   }

   // check for SMILES format
   if (Scanner::isSingleLine(*_scanner))
   {
      SmilesLoader loader(*_scanner);

      loader.ignore_closing_bond_direction_mismatch =
             ignore_closing_bond_direction_mismatch;
      loader.ignore_stereochemistry_errors = ignore_stereocenter_errors;
      if (query)
         loader.loadQueryMolecule((QueryMolecule &)mol);
//.........这里部分代码省略.........
开发者ID:Rillke,项目名称:indigo,代码行数:101,代码来源:molecule_auto_loader.cpp


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