001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.8 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 turn local parameters into global ones. 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 essentially promotes local parameters to global parameters. 022 * It works by examining every {@link Reaction} object for {@link LocalParameter} objects, 023 * then creating {@link Parameter} objects on the model for each one found, and 024 * finally removing the original {@link LocalParameter} objects. It creates new 025 * identifiers for the fresh {@link Parameter} objects by concatenating the 026 * identifier of the reaction with the identifier of the original 027 * {@link LocalParameter} object. 028 <p> 029 * This converter can be useful for software applications that do not have 030 * the ability to handle local parameters on reactions. Such applications 031 * could check incoming models for local parameters and run those models 032 * through this converter before proceeding with other steps. 033 <p> 034 * <h2>Configuration and use of {@link SBMLLocalParameterConverter}</h2> 035 <p> 036 * {@link SBMLLocalParameterConverter} is enabled by creating a {@link ConversionProperties} 037 * object with the option <code>'promoteLocalParameters'</code>, and passing this 038 * properties object to {@link SBMLDocument#convert(ConversionProperties)}. The converter offers no other options. 039 <p> 040 * <p> 041 * <h2>General information about the use of SBML converters</h2> 042 <p> 043 * The use of all the converters follows a similar approach. First, one 044 * creates a {@link ConversionProperties} object and calls 045 * {@link ConversionProperties#addOption(ConversionOption)} 046 * on this object with one arguments: a text string that identifies the desired 047 * converter. (The text string is specific to each converter; consult the 048 * documentation for a given converter to find out how it should be enabled.) 049 <p> 050 * Next, for some converters, the caller can optionally set some 051 * converter-specific properties using additional calls to 052 * {@link ConversionProperties#addOption(ConversionOption)}. 053 * Many converters provide the ability to 054 * configure their behavior to some extent; this is realized through the use 055 * of properties that offer different options. The default property values 056 * for each converter can be interrogated using the method 057 * {@link SBMLConverter#getDefaultProperties()} on the converter class in question . 058 <p> 059 * Finally, the caller should invoke the method 060 * {@link SBMLDocument#convert(ConversionProperties)} 061 * with the {@link ConversionProperties} object as an argument. 062 <p> 063 * <h3>Example of invoking an SBML converter</h3> 064 <p> 065 * The following code fragment illustrates an example using 066 * {@link SBMLReactionConverter}, which is invoked using the option string 067 * <code>'replaceReactions':</code> 068 <p> 069<pre class='fragment'> 070{@link ConversionProperties} props = new {@link ConversionProperties}(); 071if (props != null) { 072 props.addOption('replaceReactions'); 073} else { 074 // Deal with error. 075} 076</pre> 077<p> 078 * In the case of {@link SBMLReactionConverter}, there are no options to affect 079 * its behavior, so the next step is simply to invoke the converter on 080 * an {@link SBMLDocument} object. Continuing the example code: 081 <p> 082<pre class='fragment'> 083 // Assume that the variable 'document' has been set to an {@link SBMLDocument} object. 084 status = document.convert(config); 085 if (status != libsbml.LIBSBML_OPERATION_SUCCESS) 086 { 087 // Handle error somehow. 088 System.out.println('Error: conversion failed due to the following:'); 089 document.printErrors(); 090 } 091</pre> 092<p> 093 * Here is an example of using a converter that offers an option. The 094 * following code invokes {@link SBMLStripPackageConverter} to remove the 095 * SBML Level 3 <em>Layout</em> package from a model. It sets the name 096 * of the package to be removed by adding a value for the option named 097 * <code>'package'</code> defined by that converter: 098 <p> 099<pre class='fragment'> 100{@link ConversionProperties} config = new {@link ConversionProperties}(); 101if (config != None) { 102 config.addOption('stripPackage'); 103 config.addOption('package', 'layout'); 104 status = document.convert(config); 105 if (status != LIBSBML_OPERATION_SUCCESS) { 106 // Handle error somehow. 107 System.out.println('Error: unable to strip the {@link Layout} package'); 108 document.printErrors(); 109 } 110} else { 111 // Handle error somehow. 112 System.out.println('Error: unable to create {@link ConversionProperties} object'); 113} 114</pre> 115<p> 116 * <h3>Available SBML converters in libSBML</h3> 117 <p> 118 * LibSBML provides a number of built-in converters; by convention, their 119 * names end in <em>Converter</em>. The following are the built-in converters 120 * provided by libSBML 5.12.0 121: 122 <p> 123 * <p> 124 * <ul> 125 * <li> {@link CobraToFbcConverter} 126 * <li> {@link CompFlatteningConverter} 127 * <li> {@link FbcToCobraConverter} 128 * <li> {@link FbcV1ToV2Converter} 129 * <li> {@link FbcV2ToV1Converter} 130 * <li> {@link SBMLFunctionDefinitionConverter} 131 * <li> {@link SBMLIdConverter} 132 * <li> {@link SBMLInferUnitsConverter} 133 * <li> {@link SBMLInitialAssignmentConverter} 134 * <li> {@link SBMLLevel1Version1Converter} 135 * <li> {@link SBMLLevelVersionConverter} 136 * <li> {@link SBMLLocalParameterConverter} 137 * <li> {@link SBMLReactionConverter} 138 * <li> {@link SBMLRuleConverter} 139 * <li> {@link SBMLStripPackageConverter} 140 * <li> {@link SBMLUnitsConverter} 141 * 142 * </ul> 143 */ 144 145public class SBMLLocalParameterConverter extends SBMLConverter { 146 private long swigCPtr; 147 148 protected SBMLLocalParameterConverter(long cPtr, boolean cMemoryOwn) 149 { 150 super(libsbmlJNI.SBMLLocalParameterConverter_SWIGUpcast(cPtr), cMemoryOwn); 151 swigCPtr = cPtr; 152 } 153 154 protected static long getCPtr(SBMLLocalParameterConverter obj) 155 { 156 return (obj == null) ? 0 : obj.swigCPtr; 157 } 158 159 protected static long getCPtrAndDisown (SBMLLocalParameterConverter obj) 160 { 161 long ptr = 0; 162 163 if (obj != null) 164 { 165 ptr = obj.swigCPtr; 166 obj.swigCMemOwn = false; 167 } 168 169 return ptr; 170 } 171 172 protected void finalize() { 173 delete(); 174 } 175 176 public synchronized void delete() { 177 if (swigCPtr != 0) { 178 if (swigCMemOwn) { 179 swigCMemOwn = false; 180 libsbmlJNI.delete_SBMLLocalParameterConverter(swigCPtr); 181 } 182 swigCPtr = 0; 183 } 184 super.delete(); 185 } 186 187 188/** * @internal */ public 189 static void init() { 190 libsbmlJNI.SBMLLocalParameterConverter_init(); 191 } 192 193 194/** 195 * Creates a new {@link SBMLLocalParameterConverter} object. 196 */ public 197 SBMLLocalParameterConverter() { 198 this(libsbmlJNI.new_SBMLLocalParameterConverter__SWIG_0(), true); 199 } 200 201 202/** 203 * Copy constructor; creates a copy of an {@link SBMLLocalParameterConverter} 204 * object. 205 <p> 206 * @param obj the {@link SBMLLocalParameterConverter} object to copy. 207 */ public 208 SBMLLocalParameterConverter(SBMLLocalParameterConverter obj) { 209 this(libsbmlJNI.new_SBMLLocalParameterConverter__SWIG_1(SBMLLocalParameterConverter.getCPtr(obj), obj), true); 210 } 211 212 213/** 214 * Creates and returns a deep copy of this {@link SBMLLocalParameterConverter} 215 * object. 216 <p> 217 * @return a (deep) copy of this converter. 218 */ public 219 SBMLConverter cloneObject() { 220 long cPtr = libsbmlJNI.SBMLLocalParameterConverter_cloneObject(swigCPtr, this); 221 return (cPtr == 0) ? null : new SBMLLocalParameterConverter(cPtr, true); 222 } 223 224 225/** 226 * Returns <code>true</code> if this converter object's properties match the given 227 * properties. 228 <p> 229 * A typical use of this method involves creating a {@link ConversionProperties} 230 * object, setting the options desired, and then calling this method on 231 * an {@link SBMLLocalParameterConverter} object to find out if the object's 232 * property values match the given ones. This method is also used by 233 * {@link SBMLConverterRegistry#getConverterFor(ConversionProperties)} 234 * to search across all registered converters for one matching particular 235 * properties. 236 <p> 237 * @param props the properties to match. 238 <p> 239 * @return <code>true</code> if this converter's properties match, <code>false</code> 240 * otherwise. 241 */ public 242 boolean matchesProperties(ConversionProperties props) { 243 return libsbmlJNI.SBMLLocalParameterConverter_matchesProperties(swigCPtr, this, ConversionProperties.getCPtr(props), props); 244 } 245 246 247/** 248 * Perform the conversion. 249 <p> 250 * This method causes the converter to do the actual conversion work, 251 * that is, to convert the {@link SBMLDocument} object set by 252 * {@link SBMLConverter#setDocument(SBMLDocument)} and 253 * with the configuration options set by 254 * {@link SBMLConverter#setProperties(ConversionProperties)}. 255 <p> 256 * <p> 257 * @return integer value indicating success/failure of the 258 * function. The possible values 259 * returned by this function are: 260 * <ul> 261 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 262 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 263 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 264 * </ul> 265 */ public 266 int convert() { 267 return libsbmlJNI.SBMLLocalParameterConverter_convert(swigCPtr, this); 268 } 269 270 271/** 272 * Returns the default properties of this converter. 273 <p> 274 * A given converter exposes one or more properties that can be adjusted 275 * in order to influence the behavior of the converter. This method 276 * returns the <em>default</em> property settings for this converter. It is 277 * meant to be called in order to discover all the settings for the 278 * converter object. 279 <p> 280 * @return the {@link ConversionProperties} object describing the default properties 281 * for this converter. 282 */ public 283 ConversionProperties getDefaultProperties() { 284 return new ConversionProperties(libsbmlJNI.SBMLLocalParameterConverter_getDefaultProperties(swigCPtr, this), true); 285 } 286 287}