Wednesday, April 1, 2015

parameter fitting and opitimisation with PySCeS: hack for allowing integration at specific time points

PySCes is a really awesome modeling environment for kinetic models of biochemical networks. Scripting it is a heck of a lot easier to pick up and learn than the COPASI python bindings.




I only installed it on Linux, which was fairly painless.

Things to remember when installing:
PySUNDIALS versions correspond to SUNDIALS versions, so if you're installing PySUNDIALS 2.3, the dependency is SUNDIALS 2.3.
"sudo" is not transitive over &&, so to do the command "make && make install"
as administrator, you need to do "sudo make && sudo make install".

Libsbml is easy to get with "sudo pip install python-libsbml"


I made one change to the PySCeS source code. I want to solve models at specific time points (time points for which I have data). PySCeS does not usually allow integration at specific points, but forces the user to specify a start and an end, and a number of points, and then generates a set of linearly spaced time points to integrate over. That behavior is not good for data fitting.
An easy fix is to modify line 4049 of PyscesModel.py :
            if self.__settings__['time_points_override']:
                self.sim_time = numpy.array(self.sim_time) ####SJ added 20141031
            else:
                self.sim_time = numpy.linspace(self.sim_start, self.sim_end, self.sim_points, endpoint=1, retstep=0) ### SJ Changed 20141031

and add time_points_override to the model settings dict in the constructor class PysMod, function __init__, add:
        self.__settings__['time_points_override'] = False

Then all of the tests still pass, but I can override it if I want, and integrate at specific time points for data fitting.



No comments:

Post a Comment