hSimulator.library
Class Model

java.lang.Object
  extended by hSimulator.library.Model
All Implemented Interfaces:
Serializable, Cloneable

public class Model
extends Object
implements Serializable, Cloneable

This object implements a reaction model.

Version:
1.0
Author:
Luca Marchetti
See Also:
Serialized Form

Field Summary
 double numMoleculesInAMole
          Number of variable molecules in a mole (Avogadro's number).
static String variableCompartmentSeparator
          Variable - Compartment separator used to identify variable IDs.
 
Constructor Summary
Model(String spec)
          Constructs a new model according to the provided textual specification.
 
Method Summary
 Model clone()
          Clones the model.
static Model createFromFile(String fileName)
          Creates a new model according to the textual specification stored in a file.
 List<String> getVariables()
          Returns the list of variable IDs of the model.
static Model loadModel(String filePath)
          Loads a model from file.
static void saveModel(Model m, String filePath)
          Saves a model to file.
 String toString()
          Returns the textual specification of the model provided by the user.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

variableCompartmentSeparator

public static final String variableCompartmentSeparator
Variable - Compartment separator used to identify variable IDs.

See Also:
Constant Field Values

numMoleculesInAMole

public double numMoleculesInAMole
Number of variable molecules in a mole (Avogadro's number).

Constructor Detail

Model

public Model(String spec)
      throws ParseException
Constructs a new model according to the provided textual specification.

Parameters:
spec - textual specification of the model
Throws:
ParseException - if an error occurred during the parsing of the textual specification of the model
Method Detail

toString

public String toString()
Returns the textual specification of the model provided by the user.

Overrides:
toString in class Object
Returns:
the textual representation

getVariables

public List<String> getVariables()
Returns the list of variable IDs of the model. Variable IDs are indicated according to the following notation: variableName + variableCompartmentSeparator + compartmentName.

Returns:
the list of variables

clone

public Model clone()
            throws CloneNotSupportedException
Clones the model.

Overrides:
clone in class Object
Returns:
the cloned model
Throws:
CloneNotSupportedException

saveModel

public static void saveModel(Model m,
                             String filePath)
                      throws FileNotFoundException,
                             IOException
Saves a model to file.

Parameters:
m - the Model object which needs to be saved
filePath - path pointing out the resource where the model needs to be saved
Throws:
FileNotFoundException - if the file specified in filePath exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
IOException - if an input/output error occurred while writing the object

loadModel

public static Model loadModel(String filePath)
                       throws FileNotFoundException,
                              IOException,
                              ClassNotFoundException
Loads a model from file.

Parameters:
filePath - path pointing out the resource where the model is saved
Returns:
the loaded Model object
Throws:
FileNotFoundException - if the file specified in filePath exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
IOException - if an input/output error occurred while reading the object
ClassNotFoundException - if the object saved in filePath is not a Model object

createFromFile

public static Model createFromFile(String fileName)
                            throws FileNotFoundException,
                                   IOException,
                                   ParseException
Creates a new model according to the textual specification stored in a file.

Parameters:
fileName - file storing the model specification
Returns:
the instance of the loaded model
Throws:
FileNotFoundException - if the specified file does not exist
IOException - if an input/output error occurred during the reading (from file) of the textual specification of the model
ParseException - if an error occurred during the parsing of the textual specification of the model