Example #1
0
void CrfSaver::saveReaction (Reaction &reaction)
{
   _writeReactionInfo(reaction);

   int i;

   _atom_stereo_flags = 0;
   _bond_rc_flags = 0;
   _aam = 0;

   for (i = reaction.reactantBegin(); i < reaction.reactantEnd(); i = reaction.reactantNext(i))
   {
      _atom_stereo_flags = reaction.getInversionArray(i).ptr();
      _bond_rc_flags = reaction.getReactingCenterArray(i).ptr();
      _aam = reaction.getAAMArray(i).ptr();
      _writeMolecule(reaction.getMolecule(i));
   }

   for (i = reaction.productBegin(); i < reaction.productEnd(); i = reaction.productNext(i))
   {
      _atom_stereo_flags = reaction.getInversionArray(i).ptr();
      _bond_rc_flags = reaction.getReactingCenterArray(i).ptr();
      _aam = reaction.getAAMArray(i).ptr();
      _writeMolecule(reaction.getMolecule(i));
   }

   if (_encoder.get() != 0)
      _encoder->finish();
}
Example #2
0
void ReactionCmlSaver::saveReaction (Reaction &rxn)
{
   if (!skip_cml_tag)
   {
      _output.printf("<?xml version=\"1.0\" ?>\n");
      _output.printf("<cml>\n");
   }

   if (rxn.name.ptr() != 0)
   {
      if (strchr(rxn.name.ptr(), '\"') != NULL)
         throw Error("can not save reaction with '\"' in title");
      _output.printf("<reaction title=\"%s\">\n", rxn.name.ptr());
   }
   else
      _output.printf("<reaction>\n");

   int i;

   MoleculeCmlSaver molsaver(_output);

   molsaver.skip_cml_tag = true;

   if (rxn.reactantsCount() > 0)
   {
      _output.printf("<reactantList>\n");
      for (i = rxn.reactantBegin(); i != rxn.reactantEnd(); i = rxn.reactantNext(i))
         molsaver.saveMolecule(rxn.getMolecule(i));
      _output.printf("</reactantList>\n");
   }
   if (rxn.productsCount() > 0)
   {
      _output.printf("<productList>\n");
      for (i = rxn.productBegin(); i != rxn.productEnd(); i = rxn.productNext(i))
         molsaver.saveMolecule(rxn.getMolecule(i));
      _output.printf("</productList>\n");
   }
   if (rxn.catalystCount() > 0)
   {
      _output.printf("<spectatorList>\n");
      for (i = rxn.catalystBegin(); i != rxn.catalystEnd(); i = rxn.catalystNext(i))
         molsaver.saveMolecule(rxn.getMolecule(i));
      _output.printf("</spectatorList>\n");
   }
   _output.printf("</reaction>\n");
   if (!skip_cml_tag)
      _output.printf("</cml>\n");
}
Example #3
0
void CrfSaver::_writeReactionMolecule (Reaction &reaction, int i)
{
   _atom_stereo_flags = reaction.getInversionArray(i).ptr();
   _bond_rc_flags = reaction.getReactingCenterArray(i).ptr();
   _aam = reaction.getAAMArray(i).ptr();
   _writeMolecule(reaction.getMolecule(i));
}
void ReactionAtomNeighbourhoodCounters::calculate(Reaction &reac) {
   int i;

   _counters.resize(reac.count());

   for (i = reac.begin(); i < reac.end(); i = reac.next(i))
      _counters[i].calculate(reac.getMolecule(i));
}
Example #5
0
void CrfLoader::_loadReactionMolecule (Reaction &reaction, int index, bool have_aam)
{
   _bond_rc_flags = &reaction.getReactingCenterArray(index);
   _atom_stereo_flags = &reaction.getInversionArray(index);
   if (have_aam)
      _aam = &reaction.getAAMArray(index);

   _loadMolecule(reaction.getMolecule(index));
}
bool ReactionExactMatcher::_match_atoms (BaseReaction &query_, Reaction &target,
           int sub_mol_idx, int sub_atom_idx, int super_mol_idx, int super_atom_idx,
           void *context)
{
   ReactionExactMatcher &self = *(ReactionExactMatcher *)context;
   Reaction &query = query_.asReaction();
   Molecule &submol = query.getMolecule(sub_mol_idx);
   Molecule &supermol = target.getMolecule(super_mol_idx);

   if (!MoleculeExactMatcher::matchAtoms(submol, supermol, sub_atom_idx, super_atom_idx, self.flags))
      return false;

   if (self.flags & CONDITION_AAM)
   {
      if ((query.getAAM(sub_mol_idx, sub_atom_idx) == 0) !=
          (target.getAAM(super_mol_idx, super_atom_idx) == 0))
         return false;
   }
   
   return true;
}
bool ReactionExactMatcher::_match_bonds (BaseReaction &query_, Reaction &target,
           int sub_mol_idx, int sub_bond_idx, int super_mol_idx, int super_bond_idx,
           AromaticityMatcher *am, void *context)
{
   ReactionExactMatcher &self = *(ReactionExactMatcher *)context;
   Reaction &query = query_.asReaction();
   Molecule &submol = query.getMolecule(sub_mol_idx);
   Molecule &supermol = target.getMolecule(super_mol_idx);

   if (!MoleculeExactMatcher::matchBonds(submol, supermol, sub_bond_idx, super_bond_idx, self.flags))
      return false;

   if (self.flags & CONDITION_REACTING_CENTERS)
   {
      int sub_change = query.getReactingCenter(sub_mol_idx, sub_bond_idx);
      int super_change = target.getReactingCenter(super_mol_idx, super_bond_idx);

      if (sub_change != super_change)
         return false;
   }

   return true;
}