No project description provided
Project description
BANG - BooleAn Networks on the GPU
BANG is a Python package dedicated to analysis, simulation, and control of Boolean networks with the help of CUDA.
Table of Contents
Features
- High-performance simulation: GPU-accelerated computations for Boolean network simulations.
- Effective block-based attractor detection (PBN): Efficiently find attractors in large networks.
- Visualization: Built-in support for visualizing network dynamics.
- Parsing: Easy-to-use parsing of PBNs from ASSA-PBN and SBML formats.
Installation
BANG is available on PyPI and can be installed using pip. Ensure you have Python 3.10 or higher.
pip install bang-gpu
For the latest development version, you can clone the repository and install it manually. First you need to clone the repository:
git clone https://github.com/zpp20/bang.git
cd bang
Now, you can install the package:
pip install .
Usage
1. Creating a Boolean Network
You can define a Boolean network using a set of parameters of a Probabilistic Boolean Network. For example:
from bang import PBN
pbn = PBN(
# number of nodes
3,
# number of functions
[1, 1, 1],
# number of parents in functions
[2, 2, 1],
# functions
[[True, True, True, False], [False, True, False, False], [True, False]],
# indexes of the parents in the functions
[[0, 1], [0, 1], [1]],
# probabilities that the functions are chosen
[[1.0], [1.0], [1.0]],
# probability of a random perturbation at any step
0.0,
# initial state
[3],
)
2. Simulating how the network evolves
Run a simulation for a specified number of steps:
# Set the initial state (otherwise the default is all False)
pbn.set_initial_state([[True, False, True]])
# Simulate the network for 10 steps
pbn.simple_steps(10)
# Access the simulation history
print("Trajectory history:", pbn.history)
# Access the final state
print("Last state:", pbn.last_state)
3. Using CPU-Based simulation
If you want to run the simulation on the CPU instead of the GPU:
# Simulate the network on the CPU for 10 steps
pbn.simple_steps(n_steps=10, device="cpu")
4. Detecting attractors
To detect attractors in the network, you can use the attractor_detection method:
# Detect attractors in the network using the block-based method
attractors = pbn.blocks_detect_attractors()
print("Attractors found:", attractors)
5. Visualization
You can visualize the state transitions of the network:
# Plot the evolution of the trajectory simulated in the 1st thread
pbn.trajectory_graph(1)
Development
Setup
The easiest way to set up all the necessary development dependencies is to use pip with the dev extras:
pip install -e ".[dev]"
Code quality
BANG uses black for code formatting and isort for import sorting. It also uses ruff To ensure code quality, you can run the following commands:
# Format the code
black .
isort .
Testing
BANG uses pytest for testing. To run the tests, you can use the following command:
pytest tests/
Linting
BANG uses ruff for linting. To run the linter, you can use the following command:
ruff check .
Release process
In order to release a new version of BANG, you need to follow these steps:
-
Update the version in
pyproject.toml. -
Commit the changes with a message like "Bump version to X.Y.Z".
-
Tag the commit with the new version number:
git tag vX.Y.Z. Beware that the tag must be in the formatvX.Y.Z[-prerelease](e.g.,v1.0.0). -
Push the changes and the tag to the remote repository:
git push origin main --tags.
-
If the tag indicates a pre-release version and is not on the main branch, CD will deploy the package to TestPyPI.
-
If the commit is on main and the tag does not contain a prerelease version, it will be deployed to PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bang_gpu-0.4.4.tar.gz.
File metadata
- Download URL: bang_gpu-0.4.4.tar.gz
- Upload date:
- Size: 45.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42c26c3fadae7e79375814be4e19df2be59dca25e48ce4bc432b9b89cea9a24d
|
|
| MD5 |
5d8f6a162423f1b52b857201ec7762b3
|
|
| BLAKE2b-256 |
7b703fd691fbbe1e4c938d9a0fda175d41ab6247f2d56ae4d8599d8a4adbf862
|
Provenance
The following attestation bundles were made for bang_gpu-0.4.4.tar.gz:
Publisher:
main.yml on zpp20/bang
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bang_gpu-0.4.4.tar.gz -
Subject digest:
42c26c3fadae7e79375814be4e19df2be59dca25e48ce4bc432b9b89cea9a24d - Sigstore transparency entry: 728314397
- Sigstore integration time:
-
Permalink:
zpp20/bang@906a87ee2609c66865ad3e9182812a5b2fce9263 -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/zpp20
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@906a87ee2609c66865ad3e9182812a5b2fce9263 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bang_gpu-0.4.4-py3-none-any.whl.
File metadata
- Download URL: bang_gpu-0.4.4-py3-none-any.whl
- Upload date:
- Size: 53.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a64ab48952ba0ed3635e56305e92d89b86163bbbf494d062e1ec3def5b5a852a
|
|
| MD5 |
1658292ba3e595228d259de252fd8b51
|
|
| BLAKE2b-256 |
4d23ade9c44f90ded9b0ec1125273f681b0a651832bf41d4044dc019adef3fcb
|
Provenance
The following attestation bundles were made for bang_gpu-0.4.4-py3-none-any.whl:
Publisher:
main.yml on zpp20/bang
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bang_gpu-0.4.4-py3-none-any.whl -
Subject digest:
a64ab48952ba0ed3635e56305e92d89b86163bbbf494d062e1ec3def5b5a852a - Sigstore transparency entry: 728314406
- Sigstore integration time:
-
Permalink:
zpp20/bang@906a87ee2609c66865ad3e9182812a5b2fce9263 -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/zpp20
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@906a87ee2609c66865ad3e9182812a5b2fce9263 -
Trigger Event:
push
-
Statement type: