001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.0.10
004 *
005 * Do not make changes to this file unless you know what you are doing--modify
006 * the SWIG interface file instead.
007 * ----------------------------------------------------------------------------- */
008
009package org.sbml.libsbml;
010
011/** 
012 *  Converter to replace reactions with SBML <em>rate rules</em>.
013 <p>
014 * <p style='color: #777; font-style: italic'>
015This class of objects is defined by libSBML only and has no direct
016equivalent in terms of SBML components.  It is a class used in
017the implementation of extra functionality provided by libSBML.
018</p>
019
020 <p>
021 * This converter will take an SBML model and replace the definitions of
022 * reactions in the model with definitions of SBML rate rules.  Equivalent
023 * {@link RateRule} objects are only created for species mentioned in reactions that
024 * have {@link KineticLaw} subobjects, since those are the only reactions that have
025 * an effect on the rates of change of species in the model; however, the
026 * converter removes all {@link Reaction} objects in the model after it is done.
027 <p>
028 * <h2>Configuration and use of {@link SBMLReactionConverter}</h2>
029 <p>
030 * {@link SBMLReactionConverter} is enabled by creating a {@link ConversionProperties} object
031 * with the option <code>'replaceReactions'</code>, and passing this properties object
032 * to {@link SBMLDocument#convert(ConversionProperties)}.  This
033 * converter does not offer any additional configuration options.
034 <p>
035 * <p>
036 * <h2>General information about the use of SBML converters</h2>
037 <p>
038 * The use of all the converters follows a similar approach.  First, one
039 * creates a {@link ConversionProperties} object and calls
040 * {@link ConversionProperties#addOption(ConversionOption)}
041 * on this object with one arguments: a text string that identifies the desired
042 * converter.  (The text string is specific to each converter; consult the
043 * documentation for a given converter to find out how it should be enabled.)
044 <p>
045 * Next, for some converters, the caller can optionally set some
046 * converter-specific properties using additional calls to
047 * {@link ConversionProperties#addOption(ConversionOption)}.
048 * Many converters provide the ability to
049 * configure their behavior to some extent; this is realized through the use
050 * of properties that offer different options.  The default property values
051 * for each converter can be interrogated using the method
052 * {@link SBMLConverter#getDefaultProperties()} on the converter class in question .
053 <p>
054 * Finally, the caller should invoke the method
055 * {@link SBMLDocument#convert(ConversionProperties)}
056 * with the {@link ConversionProperties} object as an argument.
057 <p>
058 * <h3>Example of invoking an SBML converter</h3>
059 <p>
060 * The following code fragment illustrates an example using
061 * {@link SBMLReactionConverter}, which is invoked using the option string 
062 * <code>'replaceReactions':</code>
063 <p>
064<pre class='fragment'>
065{@link ConversionProperties} props = new {@link ConversionProperties}();
066if (props != null) {
067  props.addOption('replaceReactions');
068} else {
069  // Deal with error.
070}
071</pre>
072<p>
073 * In the case of {@link SBMLReactionConverter}, there are no options to affect
074 * its behavior, so the next step is simply to invoke the converter on
075 * an {@link SBMLDocument} object.  Continuing the example code:
076 <p>
077<pre class='fragment'>
078  // Assume that the variable 'document' has been set to an {@link SBMLDocument} object.
079  status = document.convert(config);
080  if (status != libsbml.LIBSBML_OPERATION_SUCCESS)
081  {
082    // Handle error somehow.
083    System.out.println('Error: conversion failed due to the following:');
084    document.printErrors();
085  }
086</pre>
087<p>
088 * Here is an example of using a converter that offers an option. The
089 * following code invokes {@link SBMLStripPackageConverter} to remove the
090 * SBML Level&nbsp;3 <em>Layout</em> package from a model.  It sets the name
091 * of the package to be removed by adding a value for the option named
092 * <code>'package'</code> defined by that converter:
093 <p>
094<pre class='fragment'>
095{@link ConversionProperties} config = new {@link ConversionProperties}();
096if (config != None) {
097  config.addOption('stripPackage');
098  config.addOption('package', 'layout');
099  status = document.convert(config);
100  if (status != LIBSBML_OPERATION_SUCCESS) {
101    // Handle error somehow.
102    System.out.println('Error: unable to strip the {@link Layout} package');
103    document.printErrors();
104  }
105} else {
106  // Handle error somehow.
107  System.out.println('Error: unable to create {@link ConversionProperties} object');
108}
109</pre>
110<p>
111 * <h3>Available SBML converters in libSBML</h3>
112 <p>
113 * LibSBML provides a number of built-in converters; by convention, their
114 * names end in <em>Converter</em>. The following are the built-in converters
115 * provided by libSBML 5.13.0
116:
117 <p>
118 * <p>
119 * <ul>
120 * <li> {@link CobraToFbcConverter}
121 * <li> {@link CompFlatteningConverter}
122 * <li> {@link FbcToCobraConverter}
123 * <li> {@link FbcV1ToV2Converter}
124 * <li> {@link FbcV2ToV1Converter}
125 * <li> {@link SBMLFunctionDefinitionConverter}
126 * <li> {@link SBMLIdConverter}
127 * <li> {@link SBMLInferUnitsConverter}
128 * <li> {@link SBMLInitialAssignmentConverter}
129 * <li> {@link SBMLLevel1Version1Converter}
130 * <li> {@link SBMLLevelVersionConverter}
131 * <li> {@link SBMLLocalParameterConverter}
132 * <li> {@link SBMLReactionConverter}
133 * <li> {@link SBMLRuleConverter}
134 * <li> {@link SBMLStripPackageConverter}
135 * <li> {@link SBMLUnitsConverter}
136 *
137 * </ul>
138 */
139
140public class SBMLReactionConverter extends SBMLConverter {
141   private long swigCPtr;
142
143   protected SBMLReactionConverter(long cPtr, boolean cMemoryOwn)
144   {
145     super(libsbmlJNI.SBMLReactionConverter_SWIGUpcast(cPtr), cMemoryOwn);
146     swigCPtr = cPtr;
147   }
148
149   protected static long getCPtr(SBMLReactionConverter obj)
150   {
151     return (obj == null) ? 0 : obj.swigCPtr;
152   }
153
154   protected static long getCPtrAndDisown (SBMLReactionConverter obj)
155   {
156     long ptr = 0;
157
158     if (obj != null)
159     {
160       ptr             = obj.swigCPtr;
161       obj.swigCMemOwn = false;
162     }
163
164     return ptr;
165   }
166
167  protected void finalize() {
168    delete();
169  }
170
171  public synchronized void delete() {
172    if (swigCPtr != 0) {
173      if (swigCMemOwn) {
174        swigCMemOwn = false;
175        libsbmlJNI.delete_SBMLReactionConverter(swigCPtr);
176      }
177      swigCPtr = 0;
178    }
179    super.delete();
180  }
181
182  
183/** * @internal */ public
184 static void init() {
185    libsbmlJNI.SBMLReactionConverter_init();
186  }
187
188  
189/**
190   * Creates a new {@link SBMLReactionConverter} object.
191   */ public
192 SBMLReactionConverter() {
193    this(libsbmlJNI.new_SBMLReactionConverter__SWIG_0(), true);
194  }
195
196  
197/**
198   * Copy constructor; creates a copy of an {@link SBMLReactionConverter}
199   * object.
200   <p>
201   * @param obj the {@link SBMLReactionConverter} object to copy.
202   */ public
203 SBMLReactionConverter(SBMLReactionConverter obj) {
204    this(libsbmlJNI.new_SBMLReactionConverter__SWIG_1(SBMLReactionConverter.getCPtr(obj), obj), true);
205  }
206
207  
208/**
209   * Creates and returns a deep copy of this {@link SBMLReactionConverter}
210   * object.
211   <p>
212   * @return a (deep) copy of this converter.
213   */ public
214 SBMLConverter cloneObject() {
215    long cPtr = libsbmlJNI.SBMLReactionConverter_cloneObject(swigCPtr, this);
216    return (cPtr == 0) ? null : new SBMLReactionConverter(cPtr, true);
217  }
218
219  
220/**
221   * Returns <code>true</code> if this converter object's properties match the given
222   * properties.
223   <p>
224   * A typical use of this method involves creating a {@link ConversionProperties}
225   * object, setting the options desired, and then calling this method on
226   * an {@link SBMLReactionConverter} object to find out if the object's
227   * property values match the given ones.  This method is also used by
228   * {@link SBMLConverterRegistry#getConverterFor(ConversionProperties)}
229   * to search across all registered converters for one matching particular
230   * properties.
231   <p>
232   * @param props the properties to match.
233   <p>
234   * @return <code>true</code> if this converter's properties match, <code>false</code>
235   * otherwise.
236   */ public
237 boolean matchesProperties(ConversionProperties props) {
238    return libsbmlJNI.SBMLReactionConverter_matchesProperties(swigCPtr, this, ConversionProperties.getCPtr(props), props);
239  }
240
241  
242/**
243   * Perform the conversion.
244   <p>
245   * This method causes the converter to do the actual conversion work,
246   * that is, to convert the {@link SBMLDocument} object set by
247   * {@link SBMLConverter#setDocument(SBMLDocument)} and
248   * with the configuration options set by
249   * {@link SBMLConverter#setProperties(ConversionProperties)}.
250   <p>
251   * <p>
252 * @return integer value indicating success/failure of the
253 * function.   The possible values
254 * returned by this function are:
255   * <ul>
256   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
257   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
258   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
259   * <li> {@link libsbmlConstants#LIBSBML_CONV_INVALID_SRC_DOCUMENT LIBSBML_CONV_INVALID_SRC_DOCUMENT}
260   * </ul>
261   */ public
262 int convert() {
263    return libsbmlJNI.SBMLReactionConverter_convert(swigCPtr, this);
264  }
265
266  
267/**
268   * Returns the default properties of this converter.
269   <p>
270   * A given converter exposes one or more properties that can be adjusted
271   * in order to influence the behavior of the converter.  This method
272   * returns the <em>default</em> property settings for this converter.  It is
273   * meant to be called in order to discover all the settings for the
274   * converter object.
275   <p>
276   * @return the {@link ConversionProperties} object describing the default properties
277   * for this converter.
278   */ public
279 ConversionProperties getDefaultProperties() {
280    return new ConversionProperties(libsbmlJNI.SBMLReactionConverter_getDefaultProperties(swigCPtr, this), true);
281  }
282
283  
284/**
285   * Sets the current SBML document to the given {@link SBMLDocument} object.
286   <p>
287   * @param doc the document to use for this conversion.
288   <p>
289   * <p>
290 * @return integer value indicating success/failure of the
291 * function.   The possible values
292 * returned by this function are:
293   * <ul>
294   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
295   * </ul>
296   */ public
297 int setDocument(SBMLDocument doc) {
298    return libsbmlJNI.SBMLReactionConverter_setDocument(swigCPtr, this, SBMLDocument.getCPtr(doc), doc);
299  }
300
301}