Skip to content

Commit

Permalink
Dev to master pull request (v 0.9beta) (#158)
Browse files Browse the repository at this point in the history
* Removed Duplicate Reaction Warning

These are now used in many Mixtures, so the warning doesn't make sense

* global refactor "Michalis" --> "Michaelis"

* Minor SBML fixes  (#110)

* added model Id attribute and compartment name attribute when creating SBML models
* An optional `model_id` argument can be passed when creating SBML models.

* removing mutable default arguments

* change the travis congfig checks with flak8-mutable

This is a safeguard which helps to avoid defaults mutable arguments entering the codebase

* Adding import guards for bioscrape and libroadrunner (#116)

* refactor bioscape and libroadrunner import

Bioscrape and Libroadrunners are not hard dependencies, therefore we check put a safeguard around the import statement. Unit tests are included as well to test the expected behaviour.

* add another unit test for simulation results

* refactor the simulation interface in example notebooks

if bioscrape is not found the simulator returns None, all try-except blocks were removed, simulator return value is tested instead.

* xml clean up (#113)

* delete xml files that were generated by the BioCRNPlyer

* add xml files to gitignore

xml files are generated by this toolbox, but no need to be stored in the repo

* fixup: add end of line to gitignore

* removing mutable default arguments

* change the travis congfig checks with flak8-mutable

This is a safeguard which helps to avoid defaults mutable arguments entering the codebase

* Fixed Simulate with Bioscrape Functions & Tests

The tests now each have two cases: one without bioscrape and one with bioscrape.

* added "is not None" to a bunch of stuff (#118)

* try except for pandas, seaborn

* added somemore try blocks

* missed an if statement

* modify plotting text

* added "is not None" to a lot of stuff

* Fixed Simulate with Bioscrape Functions & Tests

The tests now each have two cases: one without bioscrape and one with bioscrape.

Co-authored-by: William Poole <[email protected]>

* Minor Fixes to Pass Tests

Old Examples now X.ipynb.old to avoid being tested and maintained. Should be removed permanently in next dev to master merge.

Added additional "Results is not None" statements in some examples which were missed before.

* bug fix two issues:  #115 and #92   (#119)

This commit fixes two issues reported on the issues page:

* #115 (fixing leak in Repressible and Activatable Promoter classes)
  Adding leak keyword in activatable and repressible promoters. Until now, the "leak" keyword did nothing in these promoters. It now toggles the leak reaction. This required changing the NegativeHillTranscription and PositiveHillTranscription Mechanisms to also use a leak keyword.

* #92 (fixing filter_dict issues in GlobalMechanisms).  A new keyword has been added to global mechanisms: recursive_species_filtering = True/False. This allows for filter_dict keywords to be searched recursively through the species inside ComplexSpecies or not. A new recursive method, get_species, was added to ComplexSpecies in order to do this. This functionality is tested in a new test file: test_global_mechanism.py. This functionality has also been documented in example notebook number 6.

Co-authored-by: William Poole <[email protected]>

* changing pytest config (#121)

* change pytest config

adding verbose test output (vv), colors (color=yes) and adding some ignores for warnings (filterwarnings)

* fixup: adding a new line at the EOF

* add new parameter classes (#124)

* New Parameter Classes

Parameters are now stored in a ParameterDatabase populated by ParameterEntries. These new objects have required changes to how Mixtures and Components find, store, and load parameters (and initial conditions).

* ParameterKeys are namedtuples

ParameterKeys in ParameterDatabase are namedtuples.

* Associated Tests for Parameter objects have been made and tests for Mixtures and Components have been updated.

* For now, Parameters are returned as numbers (instead of ParameterEntries) - this will need to be undone when new parameter classes are added with new reaction classes.

* add checks to string parsing in Parameter

Parameter object accepts parameters values from strings

* Changes to make ExpressionMixtures work

The issue is that ExpressionMixtures were replacing Species. In retrospect, this is not the rigth way for them to work. Now they can use Mechanisms normally by just setting all transcripts in DNA assembly to be None (if Protein is not None). The mechanisms now switch between Expression and Transcription in this case.

* Combinatorial Testing and Fixes

Added tests to tests combinations of Components and Mixtures.

* Added .replace_species unit tests

To get coverage in chemical_reaction_network.py back to where it was previously, I added unit tests for ChemicalReactionNetwork, Species, ComplexSpecies OrderedComplexSpecies and Reaction .replace_species(old_s, new_s) function. This is no longer used in the code, but could be useful I imagine.


Co-authored-by: William Poole <[email protected]>
Co-authored-by: zoltuz <[email protected]>

* new object based Propensities (#103)

* add object-oriented Propensity types

This introduces a new class structure that replaces the string based propensity type with a class-based system.

* replace the string based propensity checks

It leverages on the object-oriented Propensity type when a new reactions is created

* create new object-based propensities

* Refactored chemical reaction network: It is now in 3 files: species, reaction, propensities, and chemical_reaction_network

* Annotations & SBML writing work with tests

* add check and unit tests for WeightedSpecies and add float to int conversion in WeightedSpecies

* add compatibility handling for Reaction: with this commit there's a new interface for Reaction. To keep the backward compatibility the old interface is suppored to some extent (massaction kinetic is supported with Deprecation warnings, other kinetics throw a NotImplementedError)

* add propensity unittest for non-massaction types

* refactor create_rate_law

* propagating for_bioscrape keyword for annotation export

* example how to setup Propensity through the old_interface

* Create test_sbml.py

* force numerical values for parameters in MultiOccupancyTxTl_Demo and Cooperativity parameter via Component.get_parameter(... return_numerical = True/False) keyword.

* remove tests for reversible SBML reactions

* change simulate_with_bioscrape_via_sbml call to get a correct return value

* changed CRN.add_species and add_reactions

* changed printouts in example notebooks to be more/less verbose in different cases.

* Added details on viewing parameter keys to the parameter notebook.

Co-authored-by: William Poole <[email protected]>

* Ordered polymer species (#126)

* try except for pandas, seaborn

* OrderedPolymer, OrderedMonomer, OrderedPolymerSpecies class: OrderedMonomers are copied when inserted into an OrderedPolymer

* minor fixes to chemical complex

* attributes, name and material types as properties: name and material_types are now a properties for Species and all Subclasses.

* parent, direction, and position are now properties: created setters etc. Also OrderedPolymerSpecies.circular is now used as an attribute as well.

* Complex() function makes OrderedComplexSpecies as well as ComplexSpecies and replaced ComplexSpecies with Complex throughout the code. Also added a warning if ComplexSpecies or OrderedComplexSpecies is made not from Complex.

* added tests for polymer and complex

* no attrib inheritance for ComplexSpecies, circular.

* Changed the order of species file

* More combinatoric tests

*ComplexSpecies names now but the 2x (for duplicate species) at the end. This is an SBML compatability issue.

Co-authored-by: William Poole <[email protected]>

* fixed a typo - very surprised this wasn't caught via testing.

* added create_modifier for SpeciesModifier reference in SBML

* refactored annotations for bioscrape into kwargs

* moved or_bioscrape to kwargs everywhere and added species modifier refernece to SBML

* fixed typos in crn for comments

* no modifiers needed for massaction propensity reactions

* param keyword needed only for massaction while creating annotations

* changed propensity bioscrape_name to name attribute. modifiers working.

* added SBML validation code to SBML testing in BioCRNpyler test suite. need debugging...

* moved test_validate to sbmlutil.py

* minor bug fix

* fixed import statements in test_sbml.py

* renamed test_validate_sbml to validate_sbml, to prevent travis from revognizing that as a fixture for test function

* all sbml models validated/validation testing works. annotations not working

* refactor sbml modifier to avoid searching for nonexistent species

* bugfix key error in annotation_dict

* fixed stochastic massaction propensity to not have S-0 term

* fixed typo bug in stochastic massaction

* finally fixed the bug with propensity writing and annotation in SBML

* refactored test_sbml to separate out bioscrape testing. Added General propensity testing to SBML.

* fixed general propensity typo

* general propensities working but sbml models are invalid because parameters for general propensity models are not added to SBML

* add a general propensity class

GeneralPropesity accpets a propensity formula in str and also requires the list of species and parameters that are part if the propensity formula.

* clean up to make it pep8 compatible

* bugfix for propensity annotation writing

* minor comment add

* added sbml validation to other parts of automated testing

* fixed comments from PR review by zoltuz

* bioscrape annotations, simulations all working.

* added new SBML basics testing to test libsbml functions and other sbmlutil functions

* refactor and bugfix SBML writing (#131)

* Minor SBML writing bug fix (#109)

* Added model Id attribute and compartment name attribute when creating SBML models. 

* An optional argument can be passed when creating SBML models : `model_id` to give an ID to your SBML model. The SBML writing test was fixed accordingly.

* added create_modifier for SpeciesModifier reference in SBML

* refactored annotations for_bioscrape into kwargs and added species modifier reference to SBML

* no modifiers needed for massaction propensity reactions

* changed propensity bioscrape_name to name attribute. modifiers working.

* added SBML validation code to SBML testing in BioCRNpyler test suite

* moved test_validate to validate_sbml

* all sbml models validated/validation testing works.

* refactor sbml modifier to avoid searching for nonexistent species

* fixed stochastic massaction propensity to not have S-0 term

* fixed typo bug in stochastic massaction

* finally fixed the bug with propensity writing and annotation in SBML (#135 )

* refactored test_sbml to separate out bioscrape testing. Added General propensity testing to SBML.

* add a general propensity class: GeneralPropesity accepts a propensity formula in a string and also requires the list of species and parameters that are part of the propensity formula. (#132 )

* added sbml validation to other parts of automated testing

* added new SBML basics testing to test libsbml functions and other sbmlutil functions

Co-authored-by: zoltuz <[email protected]>

* Mechanisms and Components interface better with Mixtures (#134)

* Mechanisms and Components interface better with Mixtures

Many changes regarding how Mechanisms and Components interface with Mixtures:
* Component.mechanisms is now a property with a setter. Component.add_mechanism(s) are the best functions to add new mechanisms to Components. Mechanisms are copied when added to a Component.
* Mixture.mechanisms is now a property with a setter. Mixture.add_mechanism(s) are the best functions to add new mechanisms to Mixtures. Mechanisms are copied when added to a Mixture.
*Mixture and Component mechanism dictionaries are no longer design to be accessed directly. Instead use Component.get_mechanism(mechanism_type). This allows for the removal of "default_mechanisms", versus "custom_mechanisms" versus "mechanisms" in both Component and Mixture. Now each only has Mechanisms. First, the component mechanisms are searched, then the mixture mechanisms are searched.
* Mixture.components is now a property with a setter. Mixture.add_component(s) are the best functions for adding Components to a Mixture. Components are copied when added to a Mixture. Mixture.get_component will return a Component from inside the mixture using a couple of keywords.
* These new functions make subclassing mixtures and components easier. Now, in the construct of each, call super.__init__(...) then just add any mechanisms or components you want using add_mechanisms(...) or add_components(...), respectively. The example notebooks have been changed to reflect this.
* A number of bug were also fixed - including a bug in parameter defaulting!

* Fixed many errors in notebooks and added tests

* Fixed error in Global Mech ipynb

* Added tests for DNAassembly and GlobalMechanisms

Additionally propogated some of the changes into DNAassembly - importantly when overwriting Mechanisms, DNAassembly never overwrites the mechanisms of its promoter and rbs, these must be accessed individually.

* Fixed typo in Component.load_parameters & CRN.simulate_with_bioscrape_via_sbml

* fixed bug in global mechanism


Co-authored-by: William Poole <[email protected]>

* added contributing.md and updated version information

* add full compatibility with the old Reaction class interface (#141)

Reaction now workings with Propensity types, but for compatibility reasons the old (string based) is supported for now.

* add sphinx docs files

* modify setup.py for PyPi installation

* update the README.md (#143)

* update the README.md

* update the README.md

fixing typos

* update the README.md

fixing typos

* updated link for documentation on readthe docs (#145)

* add all argument to setup.py for optional dependencies. move plotting imports to plotting.py and remove from __init__

* try except blocks for all plotting libraries

* move matplotlib inline to try except in ipynbs

* add versioning information to README

* add new DNA construction (#102)

This commit adds a separate path to set up DNA assemblies where, for example, multiple binding sites are present on the DNA or other complicated biocircuits operations is needed (i.e. integrase in the future). This path is recommended when biocircuit is already built in the lab and a companion in silico model is needed. For exploratory biocircuits, DNAassembly class is still recommended.   

* DNAComplexSpecies

* DNA binding site and dna_to_bind

* OrderedPolymer new way to do DNA_construct

* rerunning update_species happens in dna_construct

* Added tests for DNA assembly and GlobalMechanisms

Additionally propagated some of the changes into DNAassembly - importantly when overwriting Mechanisms, DNAassembly never overwrites the mechanisms of its promoter and rbs, these must be accessed individually.



Co-authored-by: William Poole <[email protected]>

* merge from Dr3y/master (#153)

* change the import order and remove import

Co-authored-by: dr3y <[email protected]>
Co-authored-by: William Poole <[email protected]>

* Factor out Matplotlib, fixed tests requiring specific species (#149)

* bugfix changes, remove matplotlib

Co-authored-by: William Poole <[email protected]>
Co-authored-by: Zoltan Tuza <[email protected]>

* Bug Fixes & Global Mechanism Improvements (#144)

* Modified CRN compilation

Mixture.update_species & Mixture.update_reactions is removed. CRN.add_species and CRN.add_reactions is used instead to add species and reactions to the CRN, with the CRN doing the logic. Some tests have been changed accordingly.

Additionally, new checking fro component.get_initial_condition to make sure component.mixture is defined.

* Species.pretty_print now shows initial condition.

* RNA_degredation_mm is now a global mechanism

Note: this means mechanisms like Multi-tl work better because rna can be degraded, even when it is bound to ribosomes.

DNA assemblies no longer look for RNA degredation.

Also some changes to parameter naming in multi_tx and multi_tl to make things simpler

* Fixed error with found/search keys and printing ParameterDatabase

* recursive call in CRN.get_all_species_containing(species) & bugs in multi_tx multi_tl

works for embedded ComplexSpecies now.

index error in multi_tx and multi_tl causing bugs now fixed

* Created a Deg-tagged protein mechanism

* global mechanism name change

* Fixed a bug in RNAase Degredation global mechanism

Co-authored-by: William Poole <[email protected]>
Co-authored-by: Zoltan Tuza <[email protected]>

* add docstrings and some PEP8 formatting (#152)

it also bugfix some typos and the length setter in component.py

* factor out numpy dependency (#147)

* factor out numpy dependencies

* factor out numpy dependencies

* refactor Jupyter notebooks

all plotting related packages are now tested with try-except blocks

* fixing import error

* bugfix in DNA construct Example notebook

* Support old dnaplotlib (#157)

Co-authored-by: William Poole <[email protected]>
Co-authored-by: Zoltan Tuza <[email protected]>

* optimize package imports (#154)

* remov old code in chemical_reaction_network.py. fix sbml_warnings keyword in simulate function

Co-authored-by: William Poole <[email protected]>
Co-authored-by: Eldad Afik <[email protected]>
Co-authored-by: Zoltan Tuza <[email protected]>
Co-authored-by: dr3y <[email protected]>
Co-authored-by: William Poole <[email protected]>
  • Loading branch information
6 people authored Aug 2, 2020
1 parent 814d514 commit 2a66ce0
Show file tree
Hide file tree
Showing 88 changed files with 12,576 additions and 8,118 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ docs/_build/
# Ignore all local history of files
**/.history
.vscode/settings.json

### BioCRNPlyer
# Ignore xml files generated by this toolbox
*.xml
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ install:
- pip install pytest-runner
- pip install pytest-cov
- pip install nbval
- pip install flake8-mutable
- pip install flake8

# command to run tests
# 1, pytest
# 2, flake8 checks for default mutable argument
script:
- "python setup.py test"
- flake8 --select M biocrnpyler
- if [[ `flake8 --select M biocrnpyler` ]]; then >&2 echo "default mutable argument detected"; exit 1 ; fi


# Push the results back to codecov
after_success:
Expand Down
80 changes: 0 additions & 80 deletions CRN.xml

This file was deleted.

20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
76 changes: 75 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,79 @@
# BioCRNPyler -- Biomolecular Chemical Reaction Network Compiler
## Python toolbox to create CRN models in SBML for biomolecular mechanisms
## Python toolbox to create CRN models in SBML for biomolecular mechanisms

[![Build Status](https://travis-ci.com/BuildACell/BioCRNPyler.svg?branch=master)](https://travis-ci.com/BuildACell/BioCRNPyler)
[![codecov](https://codecov.io/gh/BuildACell/BioCRNPyler/branch/master/graph/badge.svg)](https://codecov.io/gh/BuildACell/BioCRNPyler)
[![PyPI version](https://badge.fury.io/py/biocrnpyler.svg)](https://badge.fury.io/py/biocrnpyler)


BioCRNPyler is a Python package for the creation, manipulation,
and study of the structure, dynamics, and functions
of complex networks.

- **Website:** https://github.com/BuildACell/BioCRNPyler
- **Mailing list:** TBA
- **Source:** https://github.com/BuildACell/BioCRNPyler
- **Bug reports:** https://github.com/BuildACell/BioCRNPyler/issues
- **Documentation** [biocrnpyler.readthedocs.io](https://readthedocs.org/projects/biocrnpyler/)

# Simple example

Building a simple reaction network

```python
from biocrnpyler import *
# let's build the following CRN
# A -->[k1] 2B
# B -->[k2] B+D
# Species
A = Species("A")
B = Species("B")
C = Species("C")
D = Species("D")

#Reaction Rates
k1 = 3.
k2 = 1.4

#Reaciton Objects
R1 = Reaction.from_massaction([A], [B, B], k_forward = k1)
R2 = Reaction.from_massaction([B], [C, D], k_forward = k2)

#Make a CRN
CRN = ChemicalReactionNetwork(species = [A, B, C, D], reactions = [R1, R2])
print(CRN)
```
More advanced examples can be found in the [example](https://github.com/BuildACell/BioCRNPyler/tree/master/examples) folder,
here's the first file in the Tutorial series: [Building CRNs](https://github.com/BuildACell/BioCRNPyler/blob/master/examples/1.%20Building%20CRNs%20Directly.ipynb)

# Installation


Install the latest version of BioCRNPyler::

$ pip install biocrnpyler

Install with all optional dependencies::

$ pip install biocrnpyler[all]

Further details about the installation process can be found in the [BioCRNPyler wiki](https://github.com/BuildACell/BioCRNPyler/wiki#installation).
# Bugs
Please report any bugs that you find [here](https://github.com/BuildACell/BioCRNPyler/issues).
Or, even better, fork the repository on [GitHub](https://github.com/BuildACell/BioCRNPyler),
and create a pull request (PR). We welcome all changes, big or small, and we
will help you make the PR if you are new to `git` (just ask on the issue and/or
see `docs/CONTRIBUTING.md`).

# Versions

BioCRNpyler versions:

* 1.0.0 (latest stable release): To install run `pip install biocrnpyler`
* 0.2.1 (alpha release): To install run `pip install biocrnpyler==0.2.1`

# License
Released under the BSD 3-Clause License (see `LICENSE`)

Copyright (c) 2020, Build-A-Cell. All rights reserved.

Loading

0 comments on commit 2a66ce0

Please sign in to comment.