Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Rodrigo Santibáñez
    @glucksfall
    use
    from pysb.pathfinder import set_path
    set_path('bng', path_to_BNG2.pl)
    opurcell
    @opurcell
    Thanks, that fixed it. I'm curious tho - why is there the sympy package dependency? i.e. why does it work with 1.5.1, but not with 1.6.1?
    Rodrigo Santibáñez
    @glucksfall
    I'm just a pySB user...
    opurcell
    @opurcell
    I see. Well thanks for the fix. If anyone in the pySB dev community is able to shed any light on the dependency issue that would be great. Im using python 3.7 and pySB 1.11. BioNetGen 2-5-0.
    Alex Lubbock
    @alubbock
    sympy 1.6.1 was only recently released. We've added support for it in the PySB master branch on Github, which will be included in the next PySB release.
    If you install using an anaconda environment conda install -c alubbock pysb, the dependency versions should be pinned correctly (please let me know if not).
    opurcell
    @opurcell
    OK thanks for the explanation. Good to know.
    Rodrigo Santibáñez
    @glucksfall

    Hello everyone, I hope you're fine. I have a problem trying to export a model to stochkit. Do you still support the simulator? I tested the following

    from pysb.examples import robertson
    model = robertson.model
    
    from pysb.export import *
    export(model, 'stochkit')

    and the output is

    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-9-7b665249f49e> in <module>
          3 
          4 from pysb.export import *
    ----> 5 export(model, 'stochkit')
    
    /usr/local/lib/python3.8/dist-packages/pysb/export/__init__.py in export(model, format, docstring)
        174     export_class = getattr(export_module, formats[format])
        175     e = export_class(model, docstring)
    --> 176     return e.export()
        177 
        178 def pad(text, depth=0):
    
    /usr/local/lib/python3.8/dist-packages/pysb/export/stochkit.py in export(self, initials, param_values)
        250 
        251             # expand only expressions used in the rate eqn
    --> 252             for e in {sym for sym in rxn["rate"].atoms()
        253                       if isinstance(sym, Expression)}:
        254                 rate = re.sub(r'\b%s\b' % e.name,
    
    /usr/local/lib/python3.8/dist-packages/sympy/core/basic.py in atoms(self, *types)
        521             result = {node for node in nodes if isinstance(node, types)}
        522         else:
    --> 523             result = {node for node in nodes if not node.args}
        524         return result
        525 
    
    /usr/local/lib/python3.8/dist-packages/sympy/core/basic.py in <setcomp>(.0)
        521             result = {node for node in nodes if isinstance(node, types)}
        522         else:
    --> 523             result = {node for node in nodes if not node.args}
        524         return result
        525 
    
    AttributeError: 'str' object has no attribute 'args'
    am I doing something wrong?
    ABsintio
    @ABsintio

    Hello everyone. I'm a third year computer science student at the University "La Sapienza" in Rome and I have to use the interface PySB/cupSODA to simulate an sbml model on a GPU. I wrote a simple python script

    from pysb.importers.sbml import model_from_sbml
    from pysb.simulator.cupsoda import CupSodaSimulator
    
    filename="BIOMD0000000005_url.txt"
    model = model_from_sbml(filename=filename, cleanup=False)
    simulator = CupSodaSimulator(model=model)

    but I get this error

    AttributeError                            Traceback (most recent call last)
    <ipython-input-5-b1ba6e155a18> in <module>
    ----> 1 simulator = CupSodaSimulator(model=model)
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/simulator/cupsoda.py in __init__(self, model, tspan, initials, param_values, verbose, **kwargs)
        197 
        198         # generate the equations for the model
    --> 199         pysb.bng.generate_equations(self._model, self._cleanup, self.verbose)
        200 
        201         # build integrator options list from our defaults and any kwargs
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/bng.py in generate_equations(model, cleanup, verbose, **kwargs)
        729     if model.reactions:
        730         return
    --> 731     lines = iter(generate_network(model, cleanup=cleanup,
        732                                   verbose=verbose, **kwargs).split('\n'))
        733     _parse_netfile(model, lines)
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/bng.py in generate_network(model, cleanup, append_stdout, verbose, **kwargs)
        670         bngfile.action('generate_network', overwrite=True,
        671                        verbose=bng_action_debug, **kwargs)
    --> 672         bngfile.execute()
        673 
        674         output = bngfile.read_netfile()
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/bng.py in execute(self, reload_netfile, skip_file_actions)
        441             output = ''
        442             if self.model and not reload_netfile:
    --> 443                 output += self.generator.get_content()
        444             if reload_netfile:
        445                 filename = reload_netfile if \
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/generator/bng.py in get_content(self)
         24     def get_content(self):
         25         if self.__content == None:
    ---> 26             self.generate_content()
         27         return self.__content
         28 
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/generator/bng.py in generate_content(self)
         29     def generate_content(self):
         30         self.__content = "begin model\n"
    ---> 31         self.generate_parameters()
         32         self.generate_compartments()
         33         self.generate_molecule_types()
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/generator/bng.py in generate_parameters(self)
         40 
         41     def generate_parameters(self):
    ---> 42         exprs = self.model.expressions_constant()
         43         if not self.model.parameters and not exprs:
         44             return
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/core.py in expressions_constant(self)
       1974     def expressions_constant(self):
       1975         """Return a ComponentSet of constant expressions."""
    -> 1976         cset = ComponentSet(e for e in self.expressions
       1977                             if e.is_constant_expression())
       1978         return cset
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/core.py in __init__(self, iterable)
       2253         self._index_map = {}
       2254         if iterable is not None:
    -> 2255             for value in iterable:
       2256                 self.add(value)
       2257 
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/core.py in <genexpr>(.0)
       1975         """Return a ComponentSet of constant expressions."""
       1976         cset = ComponentSet(e for e in self.expressions
    -> 1977                             if e.is_constant_expression())
       1978         return cset
       1979 
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/core.py in is_constant_expression(self)
       1642                    (isinstance(a, Expression) and a.is_constant_expression()) or
       1643                    isinstance(a, sympy.Number)
    -> 16
    1644                    for a in self.expr.atoms())
       1645 
       1646     def get_value(self):
    
    ~/anaconda3/lib/python3.8/site-packages/sympy/core/basic.py in atoms(self, *types)
        521             result = {node for node in nodes if isinstance(node, types)}
        522         else:
    --> 523             result = {node for node in nodes if not node.args}
        524         return result
        525 
    
    ~/anaconda3/lib/python3.8/site-packages/sympy/core/basic.py in <setcomp>(.0)
        521             result = {node for node in nodes if isinstance(node, types)}
        522         else:
    --> 523             result = {node for node in nodes if not node.args}
        524         return result
        525 
    
    AttributeError: 'str' object has no attribute 'args'
    What do I have to do?
    Thanks to everyone
    Rodrigo Santibáñez
    @glucksfall
    Hi @ABsintio, could you try this:
    from pysb.examples import robertson
    model = robertson.model
    
    from pysb.simulator import CupSodaSimulator
    
    from pysb.pathfinder import set_path
    set_path('cupsoda', '/opt/git-repositories/cupSODA.aresio/')
    CupSodaSimulator(model, tspan = range(0,10)).run().dataframe
    image.png
    Please change the path to cupsoda.
    ABsintio
    @ABsintio

    @glucksfall Thanks a lot! Then I try this. Just another question. Where is the cupSODA path? Because i have a directory, let's suppose /A/B/C/, with an executable named cupSODA35. So I entered the command

    set_path("cupsoda", "/A/B/C")

    but it gave me the following erorr

    ValueError                                Traceback (most recent call last)
    <ipython-input-7-c68e23d371de> in <module>
    ----> 1 set_path("cupsoda", "/A/B/C/")
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/pathfinder.py in set_path(prog_name, full_path)
        234         raise ValueError('%s is not a known external executable' % prog_name)
        235 
    --> 236     _path_cache[prog_name] = _validate_path(prog_name, full_path)
        237 
        238 
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/pathfinder.py in _validate_path(prog_name, full_path)
        291 
        292         # It's a directory, try appending the executable name
    --> 293         return _validate_path(prog_name, os.path.join(full_path,
        294                                                       _get_executable(
        295                                                           prog_name)))
    
    ~/anaconda3/lib/python3.8/site-packages/pysb/pathfinder.py in _validate_path(prog_name, full_path)
        276 def _validate_path(prog_name, full_path):
        277     if not os.access(full_path, os.F_OK):
    --> 278         raise ValueError('Unable to access path %s. Check the file exists '
        279                          'and the current user has permission to access it.' %
        280                          full_path)
    
    ValueError: Unable to access path /A/B/C/cupSODA. Check the file exists and the current user has permission to access it.
    Do I have to rename cupSODA35 into cupSODA ?
    Rodrigo Santibáñez
    @glucksfall
    I would suggest compile cupsoda with the correct capability of your GPU. Mine is 61: nvcc kernel.cu cupSODA.cu input_reader.cpp stoc2det.cpp -gencode=arch=compute_61,code=compute_61 -O3 -o cupSODA --use_fast_math --cudart static
    ABsintio
    @ABsintio
    @glucksfall How can I see what's the correct capability ?
    Rodrigo Santibáñez
    @glucksfall
    Use nvidia-smi to know the model, and check here https://developer.nvidia.com/cuda-gpus
    ABsintio
    @ABsintio

    However i renamed the file cupSODA35 to cupSODA and it works, i.e. It create the object CupSodaSimulator, but when i try to start .run() method It gives me this error

    Traceback (most recent call last):
      File "main.py", line 8, in <module>
        result = simulator.run().dataframe
      File "/home/riccbrand/anaconda3/lib/python3.8/site-packages/pysb/simulator/cupsoda.py", line 376, in run
        tout, trajectories = self._run_chunk(
      File "/home/riccbrand/anaconda3/lib/python3.8/site-packages/pysb/simulator/cupsoda.py", line 293, in _run_chunk
        tout_run, trajectories_run = self._load_trajectories(
      File "/home/riccbrand/anaconda3/lib/python3.8/site-packages/pysb/simulator/cupsoda.py", line 624, in _load_trajectories
        (data, use_pandas) = self._test_pandas(filename)
      File "/home/riccbrand/anaconda3/lib/python3.8/site-packages/pysb/simulator/cupsoda.py", line 661, in _test_pandas
        self._load_with_pandas(filename)
      File "/home/riccbrand/anaconda3/lib/python3.8/site-packages/pysb/simulator/cupsoda.py", line 671, in _load_with_pandas
        data = pd.read_csv(filename, sep='\t', skiprows=None,
      File "/home/riccbrand/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py", line 5274, in __getattr__
        return object.__getattribute__(self, name)
    AttributeError: 'DataFrame' object has no attribute 'as_matrix'

    with the robertson example. It's impressive that since I have tried to so something with pysb It gaves me only error. But I don't know where I'm wrong

    Rodrigo Santibáñez
    @glucksfall
    Yeap. I wrote an issue about that. Change as_matrix to to_numpy() in cupsoda.py (as_matrix was deprecated from pandas)
    ABsintio
    @ABsintio
    Okay, thanks. Do you ever try to upload a model from sbml using model_from_sbml ?
    Rodrigo Santibáñez
    @glucksfall
    I was able to load from sbml and export to bng and kappa
    ABsintio
    @ABsintio
    When I was trying to load from sbml, pysb gave me an SimError of something "time". Did you ever got this type of error ?
    I'm trying to upload and simulate this model BIOMD0000000005.xml. I'm able to upload but when I try to simulate it through CupSodaSimulator it gives me the same error: "str object has no attribute args".
    Rodrigo Santibáñez
    @glucksfall
    May I suggest another simulator?
    import pandas
    import roadrunner
    import matplotlib.pyplot as plt
    
    # rr = roadrunner.RoadRunner('./BIOMD0000000012.xml')
    rr = roadrunner.RoadRunner('../Downloads/BIOMD0000000005_url.xml')
    
    rr.simulate(0, 200, 1000)
    rr.reset()
    rr.plot()
    
    plt.show()
    image.png
    Rodrigo Santibáñez
    @glucksfall
    I'm having the same problem: BnglImportError: Could not parse expression functionRate3: 200.0/6.022e23; Error: SympifyError: 'time'. I used the sbml import maybe one year ago, and never used it again. Seems it worth open an issue. @ABsintio @alubbock
    The setup.py don't state a specific version for sympy and maybe an update of that package (or others) broke the functionality of the sbml importer
    ABsintio
    @ABsintio
    I resolved this problem by deleting the code that raise the exception. “If expr.has(“time”): raise ... ” (I’m sorry I am writing from the cell). But I don’t know if it’s the better option.
    Rodrigo Santibáñez
    @glucksfall
    I don't know...
    ABsintio
    @ABsintio
    The problem is that I have to use pysb with cupSODA for a university project, so in someway Pysb has to work.
    Rodrigo Santibáñez
    @glucksfall
    Rodrigo Santibáñez
    @glucksfall

    The problem is that I have to use pysb with cupSODA for a university project, so in someway Pysb has to work.

    I hope you could find an useful workaround

    ABsintio
    @ABsintio
    I hope too. Maybe I’ll post more question on the “git issues”. Thanks a lot!
    Zelun Li
    @lzl0719
    Does anyone know how to make a trimer composed of a single monomer?
    Rule('Trimerisation', HSF1(b=None) + HSF1(b=1) % HSF1(b=1) | HSF1(b=2) % HSF1(b=1) % HSF1(b=1), k11, k13)
    When I tried to do something like this it throws me an error saying
    raise DanglingBondError('Dangling bond(s) {} in {}
    Rodrigo Santibáñez
    @glucksfall
    Hi @lzl0719, you need two sites per monomer, or at least, the monomer in the middle of the polymer need two sites. For instace, HSF1(a=None) + HSF1(a=None, b=1) % HSF1(b=1) | HSF1(a=2) % HSF1(a=2, b=1) % HSF1(b=1).
    You could consider also model a close-ring reaction, to avoid model a polymerization reaction (A + AA, A + AAA, A + AAAA, ...). For instance, HSF1(a=None, b=None) + HSF1(a=None, b=1) % HSF1(a=None, b=1) | HSF1(a=2, b=3) % HSF1(a=2, b=1) % HSF1(a=3, b=1)
    Zelun Li
    @lzl0719
    @glucksfall Thank you Rodrigo, right now I can make the trimer, however, I found some problem when trying to model the binding of this Transcription factor(this trimer) onto a DNA which is not part the HSF1 unit do I need to add an extra site on the HSF1 for DNA binding?
    Rodrigo Santibáñez
    @glucksfall
    Yes, that's what I do, a dedicated site to bind a monomer of the trimer to DNA. Other alternatives are: a rule like HSF1(a=2) % HSF1(a=2, b=1) % HSF1(a=None, b=1) + DNA(a) | HSF1(a=2) % HSF1(a=2, b=1) % HSF1(a=3, b=1) + DNA(a=3) or HSF1(a=None) + HSF1(a=None, b=1) % HSF1(b=1) | HSF1(a=2) % HSF1(a=2, b=1) % HSF1(b=1) + HSF1trimer(DNA) and use that new monomer to bind DNA.
    More in detail, i usually define monomers with sites named dna and prot, up and dw. I bind proteins to dna in the former sites, and proteins to proteins in the latter (similar to your a and b sites)
    Zelun Li
    @lzl0719
    Thank you so much @glucksfall, I have another question, in the model I want to have a few parameters that changes with the temperature following a customed relationship, it is possible to realize this with PySB?
    Rodrigo Santibáñez
    @glucksfall