Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Oscar Ortega
    @ortega2247
    it fixes the reporting of acceptance rates when one restarts a pydream run. Before this fix, we observed that the acceptance rates were dropping when restarting because the number of accepted points where reset to zero instead of keeping the history of the number of accepted points in the previous run
    saubhagya-gatech
    @saubhagya-gatech
    That makes sense. Thank you. Here is a reproducible example. After running the mcmc_run.py, you can run reading_results.py to print the first step that chains actually took. This is coming out to be different from the first step defined in "start" which is also printed in the python outputs. I could not think of any reason for this. Any help would be appreciated.
    ^ it might not be related to versions and might not even be an "issue". I am just trying to understand what is happening.
    opurcell
    @opurcell

    Hi, I am having some ongoing trouble with the SBML exporter. Specifically the line 'sbml_output = export(model, 'sbml'). I never had problems before and had been using PySB to build and then export my models for some time, but after starting a new venv (under PyCharm) and I assume then using the latest package versions I started having issues. I solved these by just returning to the exact package versions for everything that I had, which fixed it. However now I am moving from a local instance to AWS, I am seeing the same issues and so far have not been able to solve them with package versions. The initial error is:

    Traceback (most recent call last):
    File "predict_KOs.py", line 605, in <module>
    main()
    File "predict_KOs.py", line 591, in main
    mode_1_results = run_mode_1()
    File "predict_KOs.py", line 375, in run_mode_1
    model = build.build_model(networks[network])
    File "/home/ubuntu/build.py", line 1177, in build_model
    sbml_output = export(model, 'sbml')
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/export/init.py", line 176, in export
    return e.export()
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/export/sbml.py", line 315, in export
    return libsbml.writeSBMLToString(self.convert(level=level))
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/export/sbml.py", line 125, in convert
    pysb.bng.generate_equations(self.model)
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/bng.py", line 732, in generate_equations
    verbose=verbose, **kwargs).split('\n'))
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/bng.py", line 672, in generate_network
    bngfile.execute()
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/bng.py", line 443, in execute
    output += self.generator.get_content()
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/generator/bng.py", line 26, in get_content
    self.generate_content()
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/generator/bng.py", line 31, in generate_content
    self.generate_parameters()
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/generator/bng.py", line 42, in generate_parameters
    exprs = self.model.expressions_constant()
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/core.py", line 1976, in expressions_constant
    cset = ComponentSet(e for e in self.expressions
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/core.py", line 2255, in init
    for value in iterable:
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/core.py", line 1977, in <genexpr>
    if e.is_constant_expression())
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/core.py", line 1644, in is_constant_expression
    for a in self.expr.atoms())
    File "/home/ubuntu/.local/lib/python3.7/site-packages/sympy/core/basic.py", line 523, in atoms
    result = {node for node in nodes if not node.args}
    File "/home/ubuntu/.local/lib/python3.7/site-packages/sympy/core/basic.py", line 523, in <setcomp>
    result = {node for node in nodes if not node.args}
    AttributeError: 'str' object has no attribute 'args'

    which is obtained using sympy==1.6.1. If I instead use sympy 1.5.1 (which is the version I had it working locally with), I get a an error about the BNG2.pl file, which I have confirmed is where it should be:

    Traceback (most recent call last):
    File "predict_KOs.py", line 605, in <module>
    main()
    File "predict_KOs.py", line 591, in main
    mode_1_results = run_mode_1()
    File "predict_KOs.py", line 375, in run_mode_1
    model = build.build_model(networks[network])
    File "/home/ubuntu/build.py", line 1177, in build_model
    sbml_output = export(model, 'sbml')
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/export/init.py", line 176, in export
    return e.export()
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/export/sbml.py", line 315, in export
    return libsbml.writeSBMLToString(self.convert(level=level))
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/export/sbml.

    the end of the second error was missed off:

    Traceback (most recent call last):
    File "predict_KOs.py", line 605, in <module>
    main()
    File "predict_KOs.py", line 591, in main
    mode_1_results = run_mode_1()
    File "predict_KOs.py", line 375, in run_mode_1
    model = build.build_model(networks[network])
    File "/home/ubuntu/build.py", line 1177, in build_model
    sbml_output = export(model, 'sbml')
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/export/init.py", line 176, in export
    return e.export()
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/export/sbml.py", line 315, in export
    return libsbml.writeSBMLToString(self.convert(level=level))
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/export/sbml.py", line 125, in convert
    pysb.bng.generate_equations(self.model)
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/bng.py", line 732, in generate_equations
    verbose=verbose, **kwargs).split('\n'))
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/bng.py", line 672, in generate_network
    bngfile.execute()
    File "/home/ubuntu/.local/lib/python3.7/site-packages/pysb/bng.py", line 487, in execute
    p_err.rstrip())
    pysb.bng.BngInterfaceError:
    Can't open perl script "BioNetGen-2.5.0/BNG2.pl": No such file or directory

    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 {}