コード例 #1
0
ファイル: crf_saver.cpp プロジェクト: cambDI/camb
void CrfSaver::_writeReactionInfo (Reaction &reaction)
{
   _output.writePackedUInt(reaction.reactantsCount());
   _output.writePackedUInt(reaction.productsCount());

   byte features = CrfFeatureFlags::CRF_AAM;
   if (reaction.catalystCount() > 0)
      features |= CrfFeatureFlags::CRF_CATALYST;

   _output.writeByte(features);
   if (reaction.catalystCount() > 0)
      _output.writePackedUInt(reaction.catalystCount());
}
コード例 #2
0
ファイル: crf_saver.cpp プロジェクト: cambDI/camb
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))
         _writeReactionMolecule(reaction, i);

   for (i = reaction.productBegin(); i < reaction.productEnd(); i = reaction.productNext(i))
         _writeReactionMolecule(reaction, i);

   if (reaction.catalystCount() > 0)
   {
      for (i = reaction.catalystBegin(); i < reaction.catalystEnd(); i = reaction.catalystNext(i))
         _writeReactionMolecule(reaction, i);
   }

   if (_encoder.get() != 0)
      _encoder->finish();
}
コード例 #3
0
ファイル: reaction_cml_saver.cpp プロジェクト: mojca/indigo
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");
}