• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pysces.model函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pysces.model函数的典型用法代码示例。如果您正苦于以下问题:Python model函数的具体用法?Python model怎么用?Python model使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了model函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:palm86,项目名称:pod,代码行数:26,代码来源:datasource.py


示例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]
开发者ID:palm86,项目名称:pod,代码行数:9,代码来源:model.py


示例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)
开发者ID:PySCeS,项目名称:pysces,代码行数:7,代码来源:PyscesTest.py


示例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)
开发者ID:PySCeS,项目名称:pysces,代码行数:7,代码来源:PyscesTest.py


示例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)
开发者ID:PySCeS,项目名称:pysces,代码行数:7,代码来源:PyscesTest.py


示例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)
开发者ID:PySCeS,项目名称:pysces,代码行数:7,代码来源:PyscesTest.py


示例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)
开发者ID:PySCeS,项目名称:pysces,代码行数:7,代码来源:PyscesTest.py


示例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)
开发者ID:PySCeS,项目名称:pysces,代码行数:7,代码来源:PyscesTest.py


示例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
开发者ID:simm2,项目名称:hungry_monsters,代码行数:32,代码来源:chromosome.py


示例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
开发者ID:PySCeS,项目名称:PyscesToolbox,代码行数:31,代码来源:_pscmanipulate.py


示例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)
开发者ID:PySCeS,项目名称:pysces,代码行数:31,代码来源:PyscesTest.py


示例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)
开发者ID:CiaranWelsh,项目名称:Miscellaneous,代码行数:8,代码来源:prep_IQM.py


示例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)
开发者ID:PySCeS,项目名称:pysces,代码行数:15,代码来源:PyscesTest.py


示例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)
开发者ID:F-A,项目名称:pydstool,代码行数:46,代码来源:PySCes_SBML.py


示例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)
开发者ID:PySCeS,项目名称:pysces,代码行数:46,代码来源:PyscesTest.py


示例16: load_model

def load_model(fpath):
    cdir = os.getcwd()

    d, fname =  os.path.split(fpath)
    mod = pysces.model(fname, d)
    mod.Simulate()
    S = np.copy(mod.Nmatrix.array)
    pre = np.copy(S)
    pre[pre == 1] = 0
    pre[pre == -1] = 1

    places, transitions = mod.Nmatrix.getLabels()
    init = list(getattr(mod, place+"_init") for place in places)
    rate_getter = attrgetter("rate")
    rates = list(rate_getter(getattr(mod, transition)) for transition in transitions)
    os.chdir(cdir)
    return StochasticPetriNet._make([pre, np.array(init), S, np.array(rates),
                                    places, transitions])
开发者ID:azardilis,项目名称:fa_metabolism,代码行数:18,代码来源:fa.py


示例17: test_elas_branch1

    def test_elas_branch1(self):
        bra = pysces.model('pysces_test_branch1.psc', self.model_dir)
        bra.doLoad()
        bra.hybrd_mesg = 0
        bra.State()
        bra.EvalEvar()
        brae = [-0.66930781448548349, 0.0, 0.0, 0.0, 0.78845903183743249,\
-0.52920041809870422, 0.0, 0.0, 0.0, 0.95441603882382564,\
-0.60578219088834051, 0.0, 0.0, 0.95441603882382564, 0.0,\
-0.60578219088834051, 0.0, 0.0, 0.9421058792599355, 0.0, 0.0,\
0.0, 0.0, 0.9421058792599355]
        brae_new = []
        for x in range(bra.elas_var.shape[0]):
            for y in range(bra.elas_var.shape[1]):
                brae_new.append(round(bra.elas_var[x,y],2))
        for x in range(len(brae)):
            brae[x] = round(brae[x],2)
        assert_array_almost_equal(brae,brae_new)
开发者ID:PySCeS,项目名称:pysces,代码行数:18,代码来源:PyscesTest.py


示例18: test_cc_linear1

 def test_cc_linear1(self):
     lin = pysces.model("pysces_test_linear1.psc", self.model_dir)
     lin.doLoad()
     lin.hybrd_mesg = 0
     lin.State()
     lin.EvalEvar()
     lin.EvalCC()
     lincc = [
         0.02564102564102570300,
         0.05128205128205126600,
         0.15384615384615383000,
         0.76923076923076916000,
         0.02564102564102571000,
         0.05128205128205128000,
         0.15384615384615385000,
         0.76923076923076938000,
         0.02564102564102571000,
         0.05128205128205128000,
         0.15384615384615385000,
         0.76923076923076938000,
         0.02564102564102570300,
         0.05128205128205126600,
         0.15384615384615383000,
         0.76923076923076916000,
         -0.30636428644396779000,
         -0.61272857288793536000,
         0.15318214322198387000,
         0.76591071610991934000,
         -0.08534676570192656400,
         -0.17069353140385327000,
         -0.51208059421155983000,
         0.76812089131733974000,
         -0.96185074526088343000,
         0.05062372343478333000,
         0.15187117030435002000,
         0.75935585152175000000,
     ]
     lincc_new = []
     for x in range(lin.cc_all.shape[0]):
         for y in range(lin.cc_all.shape[1]):
             lincc_new.append(round(lin.cc_all[x, y], 2))
     for x in range(len(lincc)):
         lincc[x] = round(lincc[x], 2)
     assert_array_almost_equal(lincc, lincc_new)
开发者ID:jmrohwer,项目名称:pysces,代码行数:44,代码来源:PyscesTest.py


示例19: P_INIT

 def P_INIT(self, *args):
     args = args[0]
     print 'Args', args
     self.RESULT = None
     self.setStatus('INITIALISING')
     client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     client.connect((self.client_address[0], CFSERVE_PORT))
     client.send('GET')
     GO = True
     model = ''
     while GO:
         data = client.recv(self.block_size)
         model += data
         if data == '':
             GO = False
     self.model_name = args[0]
     self.model = pysces.model(self.model_name, loader="string", fString=model)
     if self.debug: print 'P_INIT ... ok.'
     self.setStatus('DONE_INITIALISE')
     return True
开发者ID:jsnel,项目名称:pysces,代码行数:20,代码来源:KrakenServer.py


示例20: main

def main ():

    # Check for file
    if len (sys.argv) < 2:
        s.write ("Error! Please supply a filename.\n")
        sys.exit (1)

    # Load model and convert to SBML
    m = pysces.model (sys.argv [1], dir=CWD)
    m.doLoad()
    sbml = pysces.interface.writeMod2SBML (m, getstrbuf=True).getvalue()

    # Output to 'model_' + current time + '.sbml'
    name = CWD + "/model_" + time.strftime ("%m%d%H%M%S") + ".sbml"
    out = open (name, 'w')
    out.write (sbml)
    out.flush ()
    out.close ()
    
    # Finished
    s.write ("Success! {} printed.\n".format (name))
开发者ID:simm2,项目名称:hungry_monsters,代码行数:21,代码来源:psc2SBML.py



注:本文中的pysces.model函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ao2mo.kernel函数代码示例发布时间:2022-05-27
下一篇:
Python util.alias_model_components函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap