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 that sorts SBML rules and assignments. 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 reorders assignments in a model. Specifically, it sorts 022 * the list of assignment rules (i.e., the {@link AssignmentRule} objects contained 023 * in the ListOfAssignmentRules within the {@link Model} object) and the initial 024 * assignments (i.e., the {@link InitialAssignment} objects contained in the 025 * {@link ListOfInitialAssignments}) such that, within each set, assignments that 026 * depend on <em>prior</em> values are placed <em>after</em> the values are set. For 027 * example, if there is an assignment rule stating <i>a = b + 1</i>, and 028 * another rule stating <i>b = 3</i>, the list of rules is sorted and the 029 * rules are arranged so that the rule for <i>b = 3</i> appears <em>before</em> 030 * the rule for <i>a = b + 1</i>. Similarly, if dependencies of this 031 * sort exist in the list of initial assignments in the model, the initial 032 * assignments are sorted as well. 033 <p> 034 * Beginning with SBML Level 2, assignment rules have no ordering 035 * required—the order in which the rules appear in an SBML file has 036 * no significance. Software tools, however, may need to reorder 037 * assignments for purposes of evaluating them. For example, for 038 * simulators that use time integration methods, it would be a good idea to 039 * reorder assignment rules such as the following, 040 <p> 041 * <i>b = a + 10 seconds</i><br> 042 * <i>a = time</i> 043 <p> 044 * so that the evaluation of the rules is independent of integrator 045 * step sizes. (This is due to the fact that, in this case, the order in 046 * which the rules are evaluated changes the result.) {@link SBMLRuleConverter} 047 * can be used to reorder the SBML objects regardless of whether the 048 * input file contained them in the desired order. 049 <p> 050 * Note that the two sets of SBML assignments (list of assignment rules on 051 * the one hand, and list of initial assignments on the other hand) are 052 * handled <em>independently</em>. In an SBML model, these entities are treated 053 * differently and no amount of sorting can deal with inter-dependencies 054 * between assignments of the two kinds. 055<p> 056 * <h2>Configuration and use of {@link SBMLRuleConverter}</h2> 057 <p> 058 * {@link SBMLRuleConverter} is enabled by creating a {@link ConversionProperties} object 059 * with the option <code>'sortRules'</code>, and passing this properties object to 060 * {@link SBMLDocument#convert(ConversionProperties)}. This 061 * converter offers no other options. 062 <p> 063 * <p> 064 * <h2>General information about the use of SBML converters</h2> 065 <p> 066 * The use of all the converters follows a similar approach. First, one 067 * creates a {@link ConversionProperties} object and calls 068 * {@link ConversionProperties#addOption(ConversionOption)} 069 * on this object with one arguments: a text string that identifies the desired 070 * converter. (The text string is specific to each converter; consult the 071 * documentation for a given converter to find out how it should be enabled.) 072 <p> 073 * Next, for some converters, the caller can optionally set some 074 * converter-specific properties using additional calls to 075 * {@link ConversionProperties#addOption(ConversionOption)}. 076 * Many converters provide the ability to 077 * configure their behavior to some extent; this is realized through the use 078 * of properties that offer different options. The default property values 079 * for each converter can be interrogated using the method 080 * {@link SBMLConverter#getDefaultProperties()} on the converter class in question . 081 <p> 082 * Finally, the caller should invoke the method 083 * {@link SBMLDocument#convert(ConversionProperties)} 084 * with the {@link ConversionProperties} object as an argument. 085 <p> 086 * <h3>Example of invoking an SBML converter</h3> 087 <p> 088 * The following code fragment illustrates an example using 089 * {@link SBMLReactionConverter}, which is invoked using the option string 090 * <code>'replaceReactions':</code> 091 <p> 092<pre class='fragment'> 093{@link ConversionProperties} props = new {@link ConversionProperties}(); 094if (props != null) { 095 props.addOption('replaceReactions'); 096} else { 097 // Deal with error. 098} 099</pre> 100<p> 101 * In the case of {@link SBMLReactionConverter}, there are no options to affect 102 * its behavior, so the next step is simply to invoke the converter on 103 * an {@link SBMLDocument} object. Continuing the example code: 104 <p> 105<pre class='fragment'> 106 // Assume that the variable 'document' has been set to an {@link SBMLDocument} object. 107 status = document.convert(config); 108 if (status != libsbml.LIBSBML_OPERATION_SUCCESS) 109 { 110 // Handle error somehow. 111 System.out.println('Error: conversion failed due to the following:'); 112 document.printErrors(); 113 } 114</pre> 115<p> 116 * Here is an example of using a converter that offers an option. The 117 * following code invokes {@link SBMLStripPackageConverter} to remove the 118 * SBML Level 3 <em>Layout</em> package from a model. It sets the name 119 * of the package to be removed by adding a value for the option named 120 * <code>'package'</code> defined by that converter: 121 <p> 122<pre class='fragment'> 123{@link ConversionProperties} config = new {@link ConversionProperties}(); 124if (config != None) { 125 config.addOption('stripPackage'); 126 config.addOption('package', 'layout'); 127 status = document.convert(config); 128 if (status != LIBSBML_OPERATION_SUCCESS) { 129 // Handle error somehow. 130 System.out.println('Error: unable to strip the {@link Layout} package'); 131 document.printErrors(); 132 } 133} else { 134 // Handle error somehow. 135 System.out.println('Error: unable to create {@link ConversionProperties} object'); 136} 137</pre> 138<p> 139 * <h3>Available SBML converters in libSBML</h3> 140 <p> 141 * LibSBML provides a number of built-in converters; by convention, their 142 * names end in <em>Converter</em>. The following are the built-in converters 143 * provided by libSBML 5.13.0 144: 145 <p> 146 * <p> 147 * <ul> 148 * <li> {@link CobraToFbcConverter} 149 * <li> {@link CompFlatteningConverter} 150 * <li> {@link FbcToCobraConverter} 151 * <li> {@link FbcV1ToV2Converter} 152 * <li> {@link FbcV2ToV1Converter} 153 * <li> {@link SBMLFunctionDefinitionConverter} 154 * <li> {@link SBMLIdConverter} 155 * <li> {@link SBMLInferUnitsConverter} 156 * <li> {@link SBMLInitialAssignmentConverter} 157 * <li> {@link SBMLLevel1Version1Converter} 158 * <li> {@link SBMLLevelVersionConverter} 159 * <li> {@link SBMLLocalParameterConverter} 160 * <li> {@link SBMLReactionConverter} 161 * <li> {@link SBMLRuleConverter} 162 * <li> {@link SBMLStripPackageConverter} 163 * <li> {@link SBMLUnitsConverter} 164 * 165 * </ul> 166 */ 167 168public class SBMLRuleConverter extends SBMLConverter { 169 private long swigCPtr; 170 171 protected SBMLRuleConverter(long cPtr, boolean cMemoryOwn) 172 { 173 super(libsbmlJNI.SBMLRuleConverter_SWIGUpcast(cPtr), cMemoryOwn); 174 swigCPtr = cPtr; 175 } 176 177 protected static long getCPtr(SBMLRuleConverter obj) 178 { 179 return (obj == null) ? 0 : obj.swigCPtr; 180 } 181 182 protected static long getCPtrAndDisown (SBMLRuleConverter obj) 183 { 184 long ptr = 0; 185 186 if (obj != null) 187 { 188 ptr = obj.swigCPtr; 189 obj.swigCMemOwn = false; 190 } 191 192 return ptr; 193 } 194 195 protected void finalize() { 196 delete(); 197 } 198 199 public synchronized void delete() { 200 if (swigCPtr != 0) { 201 if (swigCMemOwn) { 202 swigCMemOwn = false; 203 libsbmlJNI.delete_SBMLRuleConverter(swigCPtr); 204 } 205 swigCPtr = 0; 206 } 207 super.delete(); 208 } 209 210 211/** * @internal */ public 212 static void init() { 213 libsbmlJNI.SBMLRuleConverter_init(); 214 } 215 216 217/** 218 * Creates a new {@link SBMLLevelVersionConverter} object. 219 */ public 220 SBMLRuleConverter() { 221 this(libsbmlJNI.new_SBMLRuleConverter__SWIG_0(), true); 222 } 223 224 225/** 226 * Copy constructor; creates a copy of an {@link SBMLLevelVersionConverter} 227 * object. 228 <p> 229 * @param obj the {@link SBMLLevelVersionConverter} object to copy. 230 */ public 231 SBMLRuleConverter(SBMLRuleConverter obj) { 232 this(libsbmlJNI.new_SBMLRuleConverter__SWIG_1(SBMLRuleConverter.getCPtr(obj), obj), true); 233 } 234 235 236/** 237 * Creates and returns a deep copy of this {@link SBMLLevelVersionConverter} 238 * object. 239 <p> 240 * @return a (deep) copy of this converter. 241 */ public 242 SBMLConverter cloneObject() { 243 long cPtr = libsbmlJNI.SBMLRuleConverter_cloneObject(swigCPtr, this); 244 return (cPtr == 0) ? null : new SBMLRuleConverter(cPtr, true); 245 } 246 247 248/** 249 * Returns <code>true</code> if this converter object's properties match the given 250 * properties. 251 <p> 252 * A typical use of this method involves creating a {@link ConversionProperties} 253 * object, setting the options desired, and then calling this method on 254 * an {@link SBMLLevelVersionConverter} object to find out if the object's 255 * property values match the given ones. This method is also used by 256 * {@link SBMLConverterRegistry#getConverterFor(ConversionProperties)} 257 * to search across all registered converters for one matching particular 258 * properties. 259 <p> 260 * @param props the properties to match. 261 <p> 262 * @return <code>true</code> if this converter's properties match, <code>false</code> 263 * otherwise. 264 */ public 265 boolean matchesProperties(ConversionProperties props) { 266 return libsbmlJNI.SBMLRuleConverter_matchesProperties(swigCPtr, this, ConversionProperties.getCPtr(props), props); 267 } 268 269 270/** 271 * Perform the conversion. 272 <p> 273 * This method causes the converter to do the actual conversion work, 274 * that is, to convert the {@link SBMLDocument} object set by 275 * {@link SBMLConverter#setDocument(SBMLDocument)} and 276 * with the configuration options set by 277 * {@link SBMLConverter#setProperties(ConversionProperties)}. 278 <p> 279 * <p> 280 * @return integer value indicating success/failure of the 281 * function. The possible values 282 * returned by this function are: 283 * <ul> 284 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 285 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 286 * <li> {@link libsbmlConstants#LIBSBML_CONV_INVALID_SRC_DOCUMENT LIBSBML_CONV_INVALID_SRC_DOCUMENT} 287 * </ul> 288 */ public 289 int convert() { 290 return libsbmlJNI.SBMLRuleConverter_convert(swigCPtr, this); 291 } 292 293 294/** 295 * Returns the default properties of this converter. 296 <p> 297 * A given converter exposes one or more properties that can be adjusted 298 * in order to influence the behavior of the converter. This method 299 * returns the <em>default</em> property settings for this converter. It is 300 * meant to be called in order to discover all the settings for the 301 * converter object. 302 <p> 303 * @return the {@link ConversionProperties} object describing the default properties 304 * for this converter. 305 */ public 306 ConversionProperties getDefaultProperties() { 307 return new ConversionProperties(libsbmlJNI.SBMLRuleConverter_getDefaultProperties(swigCPtr, this), true); 308 } 309 310}