Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Princeofthebow
    @Princeofthebow

    Hi sorry it is me again, I ahve some trouble in understading how the rule definitions work(I'm an engineer and I'm not too familiar with some concepts)

    I would need to model this reaction

    image.png
    where R(A) is a function that depdends non linearly on A
    does anybody know how to do it in pysb?
    Rodrigo Santibáñez
    @glucksfall
    Princeofthebow
    @Princeofthebow
    ow wow thanks I had not spotted that
    Rodrigo Santibáñez
    @glucksfall
    no problem ;)
    Princeofthebow
    @Princeofthebow

    Hi I tried it but it results on an error

    from pysb import *
    from pysb.pathfinder import set_path
    from pysb.simulator import ScipyOdeSimulator
    set_path('bng', 'C:\Program Files\BNG')
    
    Model()
    Monomer('A',['a'])
    Observable('A_total', A())
    Parameter('Hcoeff',1.0)
    Expression('kf_A', A_total*Hcoeff)
    Rule('bindA', A(a=None) + A(a=None) >> A(a=1) % A(a=1), kf_A)
    Parameter('A0',20)
    Initial(A(a=None),A0)
    
    simres = ScipyOdeSimulator(model, tspan=[0,20]).run()

    This is the error I get:

    AttributeError: 'str' object has no attribute 'args'

    Is there some problem with my code?

    Rodrigo Santibáñez
    @glucksfall
    Oh... right. Sorry, I forgot to mention. Last week, another user asked the same about Expression. It seems there is a problem when converting the model into ODEs. The solution, if you could read the conversation history, was export the model into kappa, edit by hand because the observable must be before the parameter that use the observable, and simulate the model using the command line (KaSim).
    Princeofthebow
    @Princeofthebow
    ok that looks tough as I am totally new to this. I simply submitted an issue on the github. Lets see where it gets
    rAntonioH
    @rAntonioh
    hi, i'm trying to set the max_stoich option in BioNetGen using pysb, however generate_network(Model, cleanup=False, **{'max_stoich':3}) results in the following error:
    AttributeError: type object 'Model' has no attribute 'rules'
    this is of course not 'True' because i have written rules, any advice on how to address this?
    lu-250
    @lu-250
    Hi, everyone, I am new to pysb and have some questions about update monomer state in a list of complex, would anyone help me ? Thanks a lot ! I have a list of complex including(binding to) a common monomer. I create the list by SpeciesPatternMatcher. I would like to update the state of the particular monomer from 'u' to 'p' and create a corresponding list of complex, I am wondering if there is any easy way such as a function in library ? Thanks a lot !
    Alex Lubbock
    @alubbock
    @rAntonioh Apologies for the delayed response, but it looks like you need to use the lower case model rather than Model. In Python terms, Model is the model class, model is the model object (instance) that contains your rules etc.
    Alex Lubbock
    @alubbock
    @lu-250 Is this part of a rule or reaction in a model? Or are you trying to modify a model "statically" for some reason (without running a simulation)?
    lu-250
    @lu-250
    Yes, this will be part of a rule in a model. @alubbock Thanks a lot for the quick reply.
    lu-250
    @lu-250
    the rule I was trying to create basically states all complex with the monomer will self phosphorylated from 'u' to 'p'
    Alex Lubbock
    @alubbock
    @lu-250 The general pattern for this, with a monomer A, binding site b, and phosphorylation site s, is Rule('r1', A(s='u') >> A(s='p'), kf). The left hand side of the rule, A(s='u'), determines what's matched by the rule. Note that no binding site is included in that rule, so the phosphorylation will apply regardless if A is bound or not. If you want the phosphorylation reaction to only apply to A units which are in complex, but you don't care what the binding partner is, you can use the ANY keyword to specify "any bond, but not unbound", i.e. Rule('r2', A(b=ANY, s='u') >> A(b=ANY, s='p'), kf). For a worked example including the ANY keyword, see the egfr_simple model: https://github.com/pysb/pysb/blob/master/pysb/examples/bngwiki_egfr_simple.py
    lu-250
    @lu-250
    Got it. Thank you so much ! much simpler than what i have in mind. @alubbock
    lu-250
    @lu-250
    just to make sure I understand it right, for your r1 example, if the rule only apply to monomer, not in complex, then the binding site need to be explicitly stated in rule as rule('r1', A(s = 'u', b = None) >> A (s = 'p', b = None), kf) , even though the binding site is not directly involved or changed in the reaction. Am I right ?
    lu-250
    @lu-250
    and basically A(s = 'u') is the same as A(s = 'u', b = WILD), right ?
    Thank you so much !
    lu-250
    @lu-250
    thus Rule('r1', A(s = 'u') >> A(s = 'p'), kf) is equivalent to Rule('r1', A(s = 'u', b = WILD) >> A(s = 'p', b = WILD), kf)
    davemasnou
    @davemasnou
    image.png
    Hello everyone, I have created a model using PySB for the first time, and following the example detailed on the docs. When I try to run the model in IPython, the error mesasge of the image I have uploaded above appears, and I can't find any information about what it means. I would appreciate a lot if you could help me handle this error, thanks a lot!
    Rodrigo Santibáñez
    @glucksfall
    Hello @davemasnou, could you share your code with us?
    Eric Fernandez
    @zebulon2
    Hello, I am using PySB through the indra project. The installation document say PySB requires BioNetGen to export models to SBML. Strangely, I am able to generate SBML files without BioNetGen installed, only python-libsbml. Am I missing something? Or do I misunderstand the BioNetGen requirements? Thanks a lot in advance!
    Rodrigo Santibáñez
    @glucksfall
    I think you only need BioNetGen to simulate a BNGL model using ODE, SSA, NF, PLA
    Eric Fernandez
    @zebulon2
    Hi Rodrigo, many thanks for your answer. However using ScipyOdeSimulator from pysb does not require BNGL as far as I could test.
    Eric Fernandez
    @zebulon2
    I find out I can run this code: bngl_model = export(model, 'bngl') and produce a BNGL model. However I understand that without BNGL installed, I cannot simulate it. But I can simulate with pysb.simulator any other compatible format?
    Eric Fernandez
    @zebulon2
    I think I now understand the requirements: BNGL is only required by BngSimulator but other simulators such as ScipyOdeSimulator can be used (here the reuqirement being Scipy). Am I correct, or are there other requirements?
    Leonard Harris
    @lh64
    @zebulon2 BioNetGen is used by PySB to generate the reaction network from the rules defined in the model. So, even when using ScipyOdeSimulator to run simulations, PySB must first pass the model through BioNetGen to generate the equations that then get passed to scipy and integrated.
    pysb_workflow.jpeg
    You can see the relationship between PySB and BioNetGen in the above workflow, which is from the original PySB paper (https://doi.org/10.1038/msb.2013.1)
    Leonard Harris
    @lh64
    For SBML export, it's true that PySB can export to SBML directly but SBML is a "flat" language, which means that the rules in PySB (composed of structured "patterns") must first be converted into reactions (composed of structureless "species"). This is done by BioNetGen in the network generation step described above and is why BioNetGen is a requirement.
    I hope this makes sense. If you have any other questions, please let us know.
    @davemasnou That error is coming from BioNetGen and means it wasn't able to create a reaction network from the rules defined in the PySB model. That could be because you didn't define any Initial species concentrations. Or there may be an error in how your rules are defined. Check the Initial declarations first and if that isn't the problem post your code here and we should be able to hunt down the problem.
    Leonard Harris
    @lh64
    @lu-250 To answer your last few questions, yes, if the state change s='u' >> s='p' can only happen if the b site is unbound, then b=None must be explicitly included in the rule even though it's not changed in the rule. We refer to conditions like this as "reaction context". The part of a rule that gets changed is called the "reaction center".
    Leonard Harris
    @lh64
    And yes, A(s='u', b=WILD) is equivalent to A(s='u'). The reason this syntax exists even though it's redundant is that components can, in principle, carry both states and bonds at the same time. For example, A(s='u', b=('x', 1)) specifies an A molecule with an s component in the 'u' state and a b component in the x state that is bound to something with a bond number 1. If one wants to write a rule that says b must be in the x state but it doesn't matter whether it's bound or not, the correct syntax would be A(s='u', b=('x', WILD)). There's no other way to express this since A(s='u', b='x')explicitly means b is unbound and A(s='u') says b can be in any state, even though excluding it from the rule means it can be bound or unbound. Hope this helps.
    Alex Lubbock
    @alubbock
    Thanks for chiming in @lh64 - I seem to not always get notified when there are new gitter messages - I'll look into that.
    PySB v1.12 was released yesterday, see the release notes for details. To upgrade:
    • pip users: pip install --upgrade pysb
    • conda users: conda upgrade -c alubbock pysb
    Eric Fernandez
    @zebulon2
    @lh64 Thanks a lot.
    Eric Fernandez
    @zebulon2

    Hello, a quick question regarding the way PySB finds BNG2.pl. I have a testing machine with 2 testing environments for PySB (using Jupyter): one using pip and the other one using conda. Under the conda one I installed BioNetGen (from alubbock) but under the pip one I have not installed bionetgen. Still, under the pip environment, it finds the BNG2.pl executable installed under ~/miniconda3/bin. I checked using PySB.pathfinder.get_path('bng'). Is it expected behaviour? I looked at the code of the pathfinder module: does it "scan" the user home for a conda environment to locate the BNG2.pl file? Thanks a lot in advance.

    EDIT: Forget it - I found the answer. When opening a Jupyter notebook, it sources my ~/.bashrc file, which was modified by 'conda init' to add 'miniconda3/bin' in my PATH. When installing BioNetGen under conda, it puts the executable under miniconda3/bin and therefore is used also in the pip environment.

    Eric Fernandez
    @zebulon2
    A good way to be in control I suppose is to set the BNG path using pysb.pathfinder. Curiously the documentation for pysb does not mention this, only the pysb-alubbock documentation. Is it supposed to be that way (not a criticism there!)
    Eric Fernandez
    @zebulon2
    Note there is now a bionetgen package under pip: https://pypi.org/project/bionetgen/ so for those who cannot install conda (such as restricted/professional environments). However contrary to the bionetgen-alubbock package, one has to set the path for pysb to work, this not not automatically detected. It is installed in the <env_name>/lib/python3.8/site-packages/bionetgen/bng-linux/ folder along with the package.
    jscov
    @jscov
    Dear all,

    im using pysb to setup a polymerisation reactions including this molecule at the start (bngl notation):

    PG(oh,oh)

    and this seed definition:

    PG(oh,oh) 10

    In python I write:

    Monomer('PG', ['oh', 'oh'])

    and:

    Initial(PG(oh=None, oh=None), 10)

    This causes an error, because the 'oh' parameter is used twice in the 'Initial' function. What is the intended way to write this 'Initial' function?

    jscov
    @jscov

    I found the solution by taking a look into the source code:

    Monomer('PG', ['oh', 'oh'])
    Initial(PG(oh=MultiState(None, None)), 10)