Skip to content

Commit

Permalink
Sensitivity Analysis Added
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaikAsifullah committed Jul 1, 2017
1 parent ee66854 commit 46d73ca
Show file tree
Hide file tree
Showing 174 changed files with 205 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tellurium/__init__.py
Expand Up @@ -86,12 +86,13 @@
# Distributed computing
from .analysis.stochasticmodel import StochasticSimulationModel
from .analysis.parameterestimation import ParameterEstimation
from .analysis.sensitivityanalysis import SensitivityAnalysis

from .tellurium import (
# distrib. parameter scan
distributed_parameter_scanning, sample_plot, plotImage,
# distrib. stochastic sims & fitting
distributed_stochastic_simulation, plot_distributed_stochastic, plot_stochastic_result
distributed_stochastic_simulation, plot_distributed_stochastic, plot_stochastic_result, distributed_sensitivity_analysis
)

# Bifurcations
Expand Down
89 changes: 89 additions & 0 deletions tellurium/analysis/sensitivityanalysis.py
@@ -0,0 +1,89 @@
class SensitivityAnalysis(object):
def __init__(self,model=None,sbml=False,conservedMoietyAnalysis=True):
self._model = model
self._sbml = sbml
self._conservedMoietyAnalysis = conservedMoietyAnalysis
self._preprocessingFunc = None
self._bounds = None
self._args = None


@property
def model(self):
return self._model

@model.setter
def model(self, value):
self._model = value

@model.deleter
def model(self):
del self._model

@property
def sbml(self):
return self._sbml

@sbml.setter
def sbml(self, value):
self._sbml = value

@sbml.deleter
def sbml(self):
del self._sbml

@property
def conservedMoietyAnalysis(self):
return self._conservedMoietyAnalysis

@conservedMoietyAnalysis.setter
def conservedMoietyAnalysis(self, value):
self._conservedMoietyAnalysis = value

@conservedMoietyAnalysis.deleter
def conservedMoietyAnalysis(self):
del self._conservedMoietyAnalysis


@property
def preprocessingFunc(self):
return self._preprocessingFunc

@preprocessingFunc.setter
def preprocessingFunc(self, value):
self._preprocessingFunc = value

@preprocessingFunc.deleter
def preprocessingFunc(self):
del self._preprocessingFunc


@property
def bounds(self):
return self._bounds

@bounds.setter
def bounds(self, value):
self._bounds = value

@bounds.deleter
def bounds(self):
del self._bounds

@property
def args(self):
return self._args

@args.setter
def args(self, value):
self._args = value

@args.deleter
def args(self):
del self._args


def setPreProcessingFunction(self,func,*args):
self._preprocessingFunc = func
self._args = args

9 changes: 9 additions & 0 deletions tellurium/metastore_db/README_DO_NOT_TOUCH_FILES.txt
@@ -0,0 +1,9 @@

# *************************************************************************
# *** DO NOT TOUCH FILES IN THIS DIRECTORY! ***
# *** FILES IN THIS DIRECTORY AND SUBDIRECTORIES CONSTITUTE A DERBY ***
# *** DATABASE, WHICH INCLUDES THE DATA (USER AND SYSTEM) AND THE ***
# *** FILES NECESSARY FOR DATABASE RECOVERY. ***
# *** EDITING, ADDING, OR DELETING ANY OF THESE FILES MAY CAUSE DATA ***
# *** CORRUPTION AND LEAVE THE DATABASE IN A NON-RECOVERABLE STATE. ***
# *************************************************************************
Binary file added tellurium/metastore_db/db.lck
Binary file not shown.
Binary file added tellurium/metastore_db/dbex.lck
Binary file not shown.
8 changes: 8 additions & 0 deletions tellurium/metastore_db/log/README_DO_NOT_TOUCH_FILES.txt
@@ -0,0 +1,8 @@

# *************************************************************************
# *** DO NOT TOUCH FILES IN THIS DIRECTORY! ***
# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE RECOVERY ***
# *** SYSTEM. EDITING, ADDING, OR DELETING FILES IN THIS DIRECTORY ***
# *** WILL CAUSE THE DERBY RECOVERY SYSTEM TO FAIL, LEADING TO ***
# *** NON-RECOVERABLE CORRUPT DATABASES. ***
# *************************************************************************
Binary file added tellurium/metastore_db/log/log.ctrl
Binary file not shown.
Binary file added tellurium/metastore_db/log/log1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/log/logmirror.ctrl
Binary file not shown.
8 changes: 8 additions & 0 deletions tellurium/metastore_db/seg0/README_DO_NOT_TOUCH_FILES.txt
@@ -0,0 +1,8 @@

# *************************************************************************
# *** DO NOT TOUCH FILES IN THIS DIRECTORY! ***
# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE TO STORE ***
# *** USER AND SYSTEM DATA. EDITING, ADDING, OR DELETING FILES IN THIS ***
# *** DIRECTORY WILL CORRUPT THE ASSOCIATED DERBY DATABASE AND MAKE ***
# *** IT NON-RECOVERABLE. ***
# *************************************************************************
Binary file added tellurium/metastore_db/seg0/c10.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c101.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c111.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c121.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c130.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c141.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c150.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c161.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c171.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c180.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c191.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c1a1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c1b1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c1c0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c1d1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c1e0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c1f1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c20.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c200.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c211.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c221.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c230.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c241.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c251.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c260.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c271.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c281.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c290.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c2a1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c2b1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c2c1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c2d0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c2e1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c2f0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c300.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c31.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c311.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c321.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c331.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c340.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c351.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c361.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c371.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c380.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c391.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c3a1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c3b1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c3c0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c3d1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c3e1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c3f1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c400.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c41.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c411.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c421.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c430.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c441.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c451.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c461.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c470.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c481.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c490.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c4a1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c4b0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c4c1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c4d1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c4e1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c4f0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c501.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c51.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c510.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c521.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c530.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c541.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c550.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c561.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c570.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c581.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c590.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c5a1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c5b0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c5c1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c5d0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c5e1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c5f0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c60.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c601.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c610.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c621.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c630.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c641.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c650.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c661.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c670.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c681.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c690.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c6a1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c6b0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c6c1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c6d0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c6e1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c6f0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c701.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c71.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c711.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c721.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c731.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c741.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c751.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c761.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c771.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c781.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c791.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c7a1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c7b1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c7c1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c7d1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c7e1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c7f1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c801.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c81.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c811.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c821.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c831.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c840.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c851.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c860.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c871.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c880.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c891.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c8a0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c8b1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c8c1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c8d1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c8e1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c8f1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c90.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c901.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c911.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c920.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c931.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c940.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c951.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c960.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c971.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c981.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c990.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c9a1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c9b1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c9c0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c9d1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c9e0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/c9f1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/ca01.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/ca1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/ca11.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/ca21.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/cb1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/cc0.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/cd1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/ce1.dat
Binary file not shown.
Binary file added tellurium/metastore_db/seg0/cf0.dat
Binary file not shown.
23 changes: 23 additions & 0 deletions tellurium/metastore_db/service.properties
@@ -0,0 +1,23 @@
#/home/shaik/gsoc/tellurium/tellurium/metastore_db
# ********************************************************************
# *** Please do NOT edit this file. ***
# *** CHANGING THE CONTENT OF THIS FILE MAY CAUSE DATA CORRUPTION. ***
# ********************************************************************
#Wed Jun 28 09:27:25 PDT 2017
SysschemasIndex2Identifier=225
SyscolumnsIdentifier=144
SysconglomeratesIndex1Identifier=49
SysconglomeratesIdentifier=32
SyscolumnsIndex2Identifier=177
SysschemasIndex1Identifier=209
SysconglomeratesIndex3Identifier=81
SystablesIndex2Identifier=129
SyscolumnsIndex1Identifier=161
derby.serviceProtocol=org.apache.derby.database.Database
SysschemasIdentifier=192
derby.storage.propertiesId=16
SysconglomeratesIndex2Identifier=65
derby.serviceLocale=en_US
SystablesIdentifier=96
SystablesIndex1Identifier=113
#--- last line, don't put anything after this line ---
66 changes: 66 additions & 0 deletions tellurium/tellurium.py
Expand Up @@ -354,6 +354,72 @@ def spark_work(model_with_parameters):

return(sc.parallelize(list_of_models,len(list_of_models)).map(spark_work).collect())

def distributed_sensitivity_analysis(sc,senitivity_analysis_model):
def spark_sensitivity_analysis(model_with_parameters):
import tellurium as te

sa_model = model_with_parameters[0]
parameters = model_with_parameters[1]

if(sa_model.sbml):
model_roadrunner = te.loadAntimonyModel(te.sbmlToAntimony(sa_model.model))
else:
model_roadrunner = te.loadAntimonyModel(sa_model.model)

model_roadrunner.conservedMoietyAnalysis = sa_model.conservedMoietyAnalysis

#Performing PreSimulation
if(sa_model.preprocessingFunc is None):
pre_simulator = getattr(model_roadrunner, "simulate")
else:
pre_simulator = getattr(model_roadrunner, sa_model.preprocessingFunc)

pre_simulator(*sa_model.args)
ANALYSIS = ""
#Setting the Parameter Variables
for i_param,param_names in enumerate(sa_model.bounds.keys()):
ANALYSIS += ("\nSetting Value of {0} as {1}".format(param_names,parameters[i_param]))
setattr(model_roadrunner, param_names, parameters[i_param])


fig1a_local = model_roadrunner.getCC('PP_K', 'r1b_k2')
ANALYSIS += ('\nFigure 1A: local value = {}'.format(fig1a_local))


fig1b_local = model_roadrunner.getCC('PP_K', 'r8a_a8')
ANALYSIS += ('\nFigure 1B: local value = {}'.format(fig1b_local))


fig1c_local = model_roadrunner.getCC('PP_K', 'r10a_a10')
ANALYSIS += ('\nFigure 1C: local value = {}'.format(fig1c_local))
return(ANALYSIS)


if(senitivity_analysis_model.bounds is None):
print("Bounds are Undefined.")
return

params = []
for bound_values in senitivity_analysis_model.bounds.values():
if(len(bound_values) > 2):
params.append(np.linspace(bound_values[0], bound_values[1], bound_values[2]))
elif(len(bound_values == 2)):
params.append(np.linspace(bound_values[0], bound_values[1], 3))
else:
print("Improper Boundaries Defined")
return;
samples = perform_sampling(np.meshgrid(*params))
samples = zip([senitivity_analysis_model]*len(samples),samples)
return(sc.parallelize(samples,len(samples)).map(spark_sensitivity_analysis).collect())

def perform_sampling(mesh):
samples = []
mesh = [items.flatten() for items in mesh]
for i in range(len(mesh[0])):
samples.append([items[i] for items in mesh])
return(samples)


def loada(ant):
"""Load model from Antimony string.
Expand Down

0 comments on commit 46d73ca

Please sign in to comment.