本文整理汇总了Python中pysces.model函数的典型用法代码示例。如果您正苦于以下问题:Python model函数的具体用法?Python model怎么用?Python model使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了model函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, psc_file, variable_names, v_name, ranges, psc_string=None):
self.psc_file = psc_file
self.psc_string = psc_string
self.variable_names = variable_names
self.v_name = 'J_{0}'.format(v_name) if v_name[0:2] != 'J_' else v_name
self.ranges = ranges
import pysces
if self.psc_string is None:
self.mod = pysces.model(self.psc_file)
else:
self.mod = pysces.model(self.psc_file, loader='string', fString=self.psc_string)
self.mod.SetQuiet()
self.variables = None
self.v = numpy.array([])
self.scanner = pysces.Scanner(self.mod)
for n, r in zip(self.variable_names, self.ranges):
self.scanner.addScanParameter(n, r[0], r[1], r[2])
self.scanner.addUserOutput(self.v_name)
self.scanner.Run()
results = self.scanner.getResultMatrix()
self.variables = results[:, 0:-1]
self.v = results[:, -1]
# self.v = self.v.reshape(len(self.v), 1)
示例2: _init
def _init(self, parameters):
import pysces
if self.psc_string is None:
self.mod = pysces.model(self.psc_file)
else:
self.mod = pysces.model(self.psc_file, loader='string', fString=self.psc_string)
self.mod.SetQuiet()
self.parameter_names = [i.name for i in parameters]
示例3: test_statemetab_linear1
def test_statemetab_linear1(self):
lin = pysces.model('pysces_test_linear1.psc', self.model_dir)
lin.doLoad()
lin.hybrd_mesg = 0
lin.State()
linmet = array([23.1025641, 38.61538462, 38.94871795],'d')
assert_array_almost_equal(lin.state_species,linmet)
示例4: test_statemetab_branch1
def test_statemetab_branch1(self):
bra = pysces.model('pysces_test_branch1.psc', self.model_dir)
bra.doLoad()
bra.hybrd_mesg = 0
bra.State()
bramet = array([4.8583996,1.88547254,1.49124431,1.49124431],'d')
assert_array_almost_equal(bra.state_species,bramet)
示例5: test_statemetab_moiety1
def test_statemetab_moiety1(self):
moi = pysces.model('pysces_test_moiety1.psc', self.model_dir)
moi.doLoad()
moi.hybrd_mesg = 0
moi.State()
moimet = array([3.6886875,16.25569882,7.3113125,4.39229787,41.02504596,2.60770213,0.42718994,2.57281006,2.44791155,17.0012171],'d')
assert_array_almost_equal(moi.state_species,moimet)
示例6: test_stateflux_linear1
def test_stateflux_linear1(self):
lin = pysces.model('pysces_test_linear1.psc', self.model_dir)
lin.doLoad()
lin.hybrd_mesg = 0
lin.State()
linflux = array([76.8974359, 76.8974359, 76.8974359, 76.8974359],'d')
assert_array_almost_equal(lin.state_flux,linflux)
示例7: test_stateflux_branch1
def test_stateflux_branch1(self):
bra = pysces.model('pysces_test_branch1.psc', self.model_dir)
bra.doLoad()
bra.hybrd_mesg = 0
bra.State()
braflux = array([2.42139889,2.42139889,1.21069945,1.21069945,1.21069945,1.21069945],'d')
assert_array_almost_equal(bra.state_flux,braflux)
示例8: test_stateflux_moiety1
def test_stateflux_moiety1(self):
moi = pysces.model('pysces_test_moiety1.psc', self.model_dir)
moi.doLoad()
moi.hybrd_mesg = 0
moi.State()
moiflux = array([250.01825652,250.01825652,250.01825652,250.01825652,250.01825652,250.01825652,250.01825652],'d')
assert_array_almost_equal(moi.state_flux,moiflux)
示例9: fitness
def fitness(self, verbose=True):
time = 1000
if not self.cached_fitness is None:
return self.cached_fitness
with open("/home/calebsimmons/Hungry_Monsters/hungry_monsters/template.psc") as f:
template = "".join(f.readlines())
model = (
(template % tuple(self.genotype))
.replace("alpha", str(Chromosome.mrna_cost))
.replace("beta", str(Chromosome.protein_cost))
.replace("gamma", str(Chromosome.sugar_benefit))
.replace("delta", str(Chromosome.enzyme_mrna_cost))
.replace("zeta", str(Chromosome.enzyme_cost))
)
filename = "/home/calebsimmons/Hungry_Monsters/hungry_monsters/model%s.psc" % self.serial_no
with open(filename, "w") as f:
f.write(model)
mod = stochpy.SSA(Method="TauLeaping", File=filename, dir=".")
mod.DoStochSim(epsilon=1, mode="steps", end=time)
mod.PlotTimeSim(species2plot=["ATP"])
atp_label = mod.data_stochsim.species_labels.index("ATP")
self.cached_fitness = mod.data_stochsim.species[-1][atp_label]
# mod2 = Parser(filename)
# atp_label2 = getATP(stochsimm(mod2.parse()))
# self.cached_fitness2 = atp_label2[-1]
mod3 = pysces.model(filename, dir="/home/calebsimmons/Hungry_Monsters/hungry_monsters")
mod3.doSim(end=60, points=3000)
mod3.SimPlot(plot=["ATP"])
self.cached_fitness = mod3.data_sim.getSimData("ATP")[-1][1]
if verbose:
print self.cached_fitness
return self.cached_fitness
示例10: fix_metabolite
def fix_metabolite(mod, fix, model_name=None):
"""
Fix a metabolite in a model and return a new model with the fixed
metabolite.
Parameters
----------
mod : PysMod
The original model.
fix : str
The metabolite to fix.
model_name : str, optional (Default : none)
The file name to use when saving the model (in psc/orca).
If None it defaults to original_model_name_fix.
Returns
-------
PysMod
A new model instance with an additional fixed species.
"""
assert fix in mod.species, "\nInvalid fixed species."
if model_name is None:
model_name = get_model_name(mod) + '_' + fix
mod_str = mod_to_str(mod)
fix_head, mod_str_sans_fix = strip_fixed(mod_str)
new_fix_head = augment_fix_sting(fix_head, fix)
new_mod = model(model_name, loader="string", fString=new_fix_head
+ '\n' + mod_str_sans_fix)
return new_mod
示例11: test_cc_branch1
def test_cc_branch1(self):
bra = pysces.model('pysces_test_branch1.psc', self.model_dir)
bra.doLoad()
bra.hybrd_mesg = 0
bra.State()
bra.EvalEvar()
bra.EvalCC()
bracc=[0.25338970963029361000,-0.13797075277724413000,\
-0.21457061516904127000,0.32372624345386269000,0.39406892242342095000,0.38135649243870806000,\
-0.13797075277724413000,0.25338970963029356000,0.39406892242342095000,0.32372624345386258000,\
-0.21457061516904130000,0.38135649243870812000,-0.13797075277724413000,0.25338970963029356000,\
0.39406892242342095000,0.32372624345386258000,-0.21457061516904130000,0.38135649243870812000,\
0.05770947842652475500,0.05770947842652472700,0.08974915362718985400,0.32372624345386269000,\
0.08974915362718984000,0.38135649243870817000,0.25338970963029361000,-0.13797075277724413000,\
-0.21457061516904127000,0.32372624345386269000,0.39406892242342095000,0.38135649243870806000,\
0.05770947842652474100,0.05770947842652471300,0.08974915362718984000,0.32372624345386264000,\
0.08974915362718982600,0.38135649243870806000,-0.23751396180748979000,-0.23751396180748979000,\
-0.36937913195668803000,0.55728841856739109000,-0.36937913195668803000,0.65649776896096446000,\
-0.08622262758262820600,-0.08622262758262820600,-0.13409249329650016000,-0.48367318660804903000,\
-0.13409249329650016000,0.92430342836630586000,-0.79249085140642661000,-0.14644930661681688000,\
-0.22775636995026044000,0.34361981023636490000,0.41828517483934929000,0.40479154289778968000,\
-0.14644930661681685000,-0.79249085140642661000,0.41828517483934929000,0.34361981023636484000,\
-0.22775636995026050000,0.40479154289778979000]
bracc_new = []
for x in range(bra.cc_all.shape[0]):
for y in range(bra.cc_all.shape[1]):
bracc_new.append(round(bra.cc_all[x,y],2))
for x in range(len(bracc)):
bracc[x] = round(bracc[x],2)
#os.sys.stderr.write(str(bracc[x]) + ' --> ' + str(bracc_new[x])+'\n')
assert_array_almost_equal(bracc,bracc_new)
示例12: sbml2pysces
def sbml2pysces(self,model_xml):
'''
Use pysces to read the SBML file
'''
current_dir=os.getcwd()
pysces_filename=os.path.join(current_dir,model_xml[-4]+'.psc')
pysces.interface.convertSBML2PSC(model_xml,pscfile=pysces_filename)
return pysces.model(pysces_filename)
示例13: test_elas_linear1
def test_elas_linear1(self):
lin = pysces.model('pysces_test_linear1.psc', self.model_dir)
lin.doLoad()
lin.hybrd_mesg = 0
lin.State()
lin.EvalEvar()
line = [-0.30043348,0.,0., 1.50216739,-0.50216739,0., 0.,1.50650217,-0.50650217, 0.,0.,1.01300433]
line_new = []
for x in range(lin.elas_var.shape[0]):
for y in range(lin.elas_var.shape[1]):
line_new.append(round(lin.elas_var[x,y],2))
for x in range(len(line)):
line[x] = round(line[x],2)
assert_array_almost_equal(line,line_new)
示例14: get_pysces_model
def get_pysces_model(filename, target='Vode'):
path, fname = os.path.split(filename)
m = pysces.model(fname, dir=path)
max_t = np.Inf
parlist = m.__fixed_species__ + m.__parameters__
pardict = dict([(pname, p['initial']) for pname, p in m.__pDict__.items()])
varlist = m.__species__ # list ['s0', 's1', 's2']
icdict = dict([(vname, v['initial']) for vname, v in m.__sDict__.items() if not v['fixed']])
fixed_species = dict([(pname, p['initial']) for pname, p in m.__sDict__.items() if p['fixed']])
pardict.update(fixed_species)
fnspecs = {}
for R in m.__reactions__: # list ['R1', 'R2', 'R3', 'R4']
R_info = m.__nDict__[R]
#assert R_info['Modifiers'] == []
assert R_info['Type'] == 'Rever'
arglist = []
for reagent in R_info['Reagents']:
r = reagent.replace('self.','')
if r in varlist:
arglist.append(r)
arglist.sort()
fnspecs[R] = (arglist, R_info['RateEq'].replace('self.',''))
varspecs = make_varspecs(m, fnspecs)
for fname, fspec in m.__userfuncs__.items():
# Don't know how these are implemented yet
fnspec[fname] = fspec
dsargs = args(name=fname[:-3],
varspecs=varspecs,
fnspecs=fnspecs,
pars=pardict,
ics=icdict,
tdata=[0, max_t])
genclassname = target + '_ODEsystem'
try:
genclass = getattr(Generator, genclassname)
except AttributeError:
raise TypeError("Invalid ODE solver type")
return genclass(dsargs)
示例15: test_cc_moiety1
def test_cc_moiety1(self):
moi = pysces.model('pysces_test_moiety1.psc', self.model_dir)
moi.doLoad()
moi.hybrd_mesg = 0
moi.State()
moi.EvalEvar()
moi.EvalCC()
moicc = moicc=[0.01114694087227875000,0.07381787576415140000,\
0.18139104475836643000,0.04685617079784056700,0.25208717198140801000,0.04329618737852313600,\
0.39140460844743269000,0.01114694087227862500,0.07381787576415056700,0.18139104475836440000,\
0.04685617079784004000,0.25208717198140518000,0.04329618737852265100,0.39140460844742830000,\
0.01114694087227874000,0.07381787576415133100,0.18139104475836623000,0.04685617079784051800,\
0.25208717198140773000,0.04329618737852309500,0.39140460844743230000,0.01114694087227875000,\
0.07381787576415140000,0.18139104475836643000,0.04685617079784056700,0.25208717198140801000,\
0.04329618737852313600,0.39140460844743269000,0.01114694087227875000,0.07381787576415140000,\
0.18139104475836643000,0.04685617079784056700,0.25208717198140801000,0.04329618737852313600,\
0.39140460844743269000,0.01114694087227876100,0.07381787576415146900,0.18139104475836659000,\
0.04685617079784060900,0.25208717198140823000,0.04329618737852317800,0.39140460844743302000,\
0.01114694087227875200,0.07381787576415141400,0.18139104475836645000,0.04685617079784057400,\
0.25208717198140806000,0.04329618737852314300,0.39140460844743280000,-0.96946517151898726000,\
0.07237057005414701500,0.17783461222620814000,0.04593748812318156800,0.24714464011293155000,\
0.04244730330314599300,0.38373055769937375000,-0.00493043463469603270,-0.03265059135931840800,\
-0.08023158100034956400,0.14913606725290945000,\
0.02650472034900546900,0.11529508789995771000,-0.17312326850750914000,-0.00258941341724495350,\
-0.01714775382110165000,-0.04213679882643606200,0.25950964810000904000,-0.07785637143685617000,\
-0.02885675558547331700,-0.09092255501289707400,-0.00651179467430067560,-0.04312275948862360300,\
-0.10596460973080281000,-0.02003169777867189200,0.40783108111031047000,-0.00355036168876400080,\
-0.22864985774914801000,-0.07520202175595115700,-0.49800690277268156000,1.11329060303376930000,\
0.28758054022385904000,1.54718927875470390000,0.26573108181778565000,-2.64058257930148920000,\
0.08511194652599511600,-0.37976718223865702000,-0.93319355560031703000,-0.24105862936563618000,\
-1.29690043219020780000,-0.22274375836758617000,2.98855161123640300000,-0.01413200623441426100,\
0.06305662607990611400,0.15494766227242857000,0.04002542759392844300,0.21533763168639128000,\
0.03698442240380646300,-0.49621976380204558000,0.01332315621836589900,0.08822932693215754200,\
0.21680398717628285000,-0.25121007495788511000,0.32322678367369212000,-0.85819164176559659000,\
0.46781846272298522000,0.01096817827331699600,0.07263406439629339900,0.17848209108569948000,\
0.03374050370795465800,-0.68693259335574453000,0.00598007183654026410,0.38512768405594056000,\
0.00513245176028354240,0.03398840011328187900,0.08351894906745090100,-0.51437161070192172000,\
0.15431837495286327000,0.05719670138973560700,0.18021673341830685000]
moicc_new = []
for x in range(moi.cc_all.shape[0]):
for y in range(moi.cc_all.shape[1]):
moicc_new.append(round(moi.cc_all[x,y],2))
for x in range(len(moicc)):
moicc[x] = round(moicc[x],2)
#os.sys.stderr.write(str(moicc[x]) + ' --> ' + str(moicc_new[x])+'\n')
assert_array_almost_equal(moicc,moicc_new)