Module modelmage :: Module generator :: Class CpsHandler
[hide private]
[frames] | no frames]

Class CpsHandler

source code

Holds a Copasifile and has methods to manipulate it. The class is used to merge the root copasifile with the submodels.

Instance Methods [hide private]
 
__init__(self, filename, history, map=None) source code
 
__addFitItem(self, importFile, problem, model, ReactionName, parameter) source code
 
__removeExperimentalPar(self, valueDict, parameter) source code
minidom.Node
__getTask(self, type)
Returns all tasks of type 'type'.
source code
minidom.Node
__getReport(self, type)
Returns all tasks of type 'type'.
source code
[str] @return list of reaction names
__getReactionNames(self)
Return the names of all reactions of the model in a list.
source code
[str] @return list of reaction ids
__getReactionIds(self)
Return the ids of all reactions of the model in a list.
source code
[str] @return list of metabolite names
__getMetaboliteNames(self)
Return the names of all metabolites/species of the model in a list.
source code
[str] @return list of metabolite ids
__getMetaboliteIds(self)
Return the ids of all metabolites/species of the model in a list.
source code
[str] @return list of global quantities
__getModelValues(self)
Return the names of all global quantities of the model in a list.
source code
[str]
__getReactionParameters(self, reaction)
Returns all parameter names that belong to a specific reaction.
source code
[str]
__getGlobalParameters(self)
Returns all parameter names that belong to a specific reaction.
source code
 
__fitItem(self, model, ReactionName, parameter) source code
list
getExperimentalDataFiles(self)
Gets the paths to experimental data files specified for a parameter estimation and returns them in a list.
source code
 
__getFitItems(self, task) source code
 
__getExperimentalData(self, task) source code
 
__createValueDict(self, longString) source code
 
assignFunctionNames(self, functionReactionMap, functionsIdName, modelName, KineticNameMap)
gives kinetics with a changed formula the corresponding name
source code
 
importTask(self, file, taskType)
Adds a task to the cps file and overwrites tasks of the same type.
source code
str
__encodeAttributes(self, string)
Converts encoding of attributes.
source code
bool
writeCPS(self, filename)
Writes the file to the path filename.
source code
Method Details [hide private]

__init__(self, filename, history, map=None)
(Constructor)

source code 
Parameters:
  • filename (str) - path to the copasifile
  • history (dict) - the node history of the candidate models

__getTask(self, type)

source code 

Returns all tasks of type 'type'. For example:

>>>self.getTask('parameterFitting')

would return a minidom object containing the corresponding task.

Parameters:
  • type (unicode) - type of the task to return
Returns: minidom.Node
task of type type

__getReport(self, type)

source code 

Returns all tasks of type 'type'. For example:

>>>self.getReport('parameterFitting')

would return a minidom object containing the corresponding report.

Parameters:
  • type (unicode) - type of the report to return
Returns: minidom.Node
report of type type

__getReactionParameters(self, reaction)

source code 

Returns all parameter names that belong to a specific reaction.

Parameters:
  • reaction (str) - a reaction belonging to the model
Returns: [str]
a list of parameternames

__getGlobalParameters(self)

source code 

Returns all parameter names that belong to a specific reaction.

Returns: [str]
a list of parameternames

getExperimentalDataFiles(self)

source code 

Gets the paths to experimental data files specified for a parameter estimation and returns them in a list.

Returns: list
ist of paths to the specified experimental data files

assignFunctionNames(self, functionReactionMap, functionsIdName, modelName, KineticNameMap)

source code 

gives kinetics with a changed formula the corresponding name

Parameters:
  • functionReactionMap (map ( produced in def getFunction_Id_Name_XML in modelmage.py)) - {function_id : reaction_id}
  • functionsIdName (map (produced in def getMasterSBMLFunctions(input) in modelmage.py)) - {function_id : function_name}
  • modelName (str) - current name of candidate model
  • KineticNameMap (map (produced in def __lawtoSBML())) - {function_id: kineticName}

importTask(self, file, taskType)

source code 

Adds a task to the cps file and overwrites tasks of the same type. The method automatically sets attributes that relate to other elements in the file(e.g. report reference) to the correct values.

Filenames for resultfiles are automatically set to: filname_est.txt

Parameters:
  • file (str) - the file from which the task will be imported
  • taskType (str) - the type of task that shall be imported

__encodeAttributes(self, string)

source code 

Converts encoding of attributes. There are some characters which Copasi interprets as html encoding, these characters are switched to this encoding.

Parameters:
  • string (str) - the string that will be changed
Returns: str
a new string with exchanged special characters

writeCPS(self, filename)

source code 

Writes the file to the path filename.

Parameters:
  • filename (str) - path where the file will be written
Returns: bool
True if file was written, else False