Skip to main content

Model Revision tool for computing Boolean network repair operations.

Project description

pymodrev: A python Model Revision tool for Boolean logical models

pymodrev is a Python-based reimplementation of ModRev, a tool for automated consistency checking and repair of Boolean network models using Answer Set Programming (ASP). Given a Boolean model and a set of experimental observations (steady-state or time-series), pymodrev determines whether the model explains the data. If inconsistencies are found, it identifies minimal repair operations to fix the model.

Built on top of the Clingo ASP solver and the pyfunctionhood library, pymodrev brings modern usability and extensibility to the model revision process by offering:

  • Full parity with ModRev's core logic, using the same ASP encodings
  • Modular architecture with pluggable update policies (synchronous, asynchronous, complete, steady-state)
  • Pure Python interface, ideal for integration with scientific workflows
  • In-memory model and observation management, enabling multiple consistency checks without reloading
  • Command-line interface for batch processing and reproducibility

Install

You can install pymodrev directly from source or via PyPI.

To install from source (when you are inside the pymodrev directory):

$ pip install .

To install from PyPI:

$ pip install pymodrev

This will automatically install dependencies like bitarray, pyfunctionhood, and clingo.


Getting Started

Boolean models can be specified using the following formats:

  • .lp - using original ModRev ASP encoding
  • .bnet - using the BoolNet format (only boolean rules)
  • .ginml / .zginml - using the widely used GINsim format (conserving the model layout information)

To run pymodrev, use the following command structure:

$ pymodrev -h
usage: pymodrev [-h] -m MODEL -obs OBS [UPDATER ...] -t {c,r,m} [--exhaustive-search] [--sub-opt] [--all-opt]
               [-v {0,1,2}] [-d]

options:
  -h, --help            show this help message and exit
  -m, --model MODEL     Input model file.
  -obs, --observations OBS [UPDATER ...]
                        List of observation files and updater pairs.
                        Each observation must be followed by its updater type. 
                        Example: -obs obs1.lp asyncupdater obs2.lp syncupdater
  -t, --task {c,r,m}    Specify the task to perform (default=r):
                           c - check for consistency
                           r - get repairs
                           m - get repaired models
  --exhaustive-search   Force exhaustive search of function repair operations (default=false).
  --sub-opt             Show sub-optimal solutions found (default=false).
  --all-opt             Computes all optimal solutions (default=true).
                        Stops at first optimal solution if false.
  -v, --verbose {0,1,2}
                        Specify output verbose level (default=2):
                            0 - compact format
                            1 - json format
                            2 - human-readable format
  -d, --debug           Enable debug mode.

Observation Formats

Experimental observations can be provided in .lp (ASP facts), .csv, .xls, or .xlsx formats.

Excel (or CSV) Formats

The tool automatically detects steady-state vs. time-series formats based on the header structure:

  • Steady-state: The header has one empty first field. The first column contains profile names, followed by node values.
    ,node1,node2,node3
    p1,0,1,0
    p2,1,1,1
    
  • Time-series: The header has two empty first fields. The first column contains profile names, the second column contains time steps, followed by node values.
    ,,node1,node2,node3
    p1,0,0,1,1
    p1,1,1,1,0
    p1,2,*,0,0
    

    [!TIP] Missing values (empty fields, *, N/A, NaN, -) are automatically skipped, ensuring no inconsistent constraints are generated for those variables at those time points.


Example: check consistency

Using option -t c, pymodrev will report the minimal set of nodes that need to be repaired in order to make the model consistent with the given observations.

$ pymodrev -m examples/boolean_cell_cycle/03/model.bnet -obs examples/boolean_cell_cycle/03/steadystate.lp steadystateupdater -t c
This network is inconsistent!
  node(s) needing repair: "p27", "rb", "cdc20", "cycd"
  present in profile(s): "p1"

Example: get repairs

Using option -t r, pymodrev will report the minimal set of repair operations for the model to be consistent with the given observations.

$ pymodrev -m examples/boolean_cell_cycle/03/model.bnet -obs examples/boolean_cell_cycle/03/steadystate.lp steadystateupdater -t r
### Found solution with 4 repair operations.
	Inconsistent node p27.
		Repair #1:
			Change function of p27 to: (cyca && !cycb && cycd && !p27) || (!cycb && !cyce)
	Inconsistent node rb.
		Repair #1:
			Change function of rb to: (!cycb && cycd && !p27) || (!cycb && cycd && cyce) || (!cycb && !cyca)
	Inconsistent node cdc20.
		Repair #1:
			Flip sign of edge (cycb,cdc20) to: positive
	Inconsistent node cycd.
		Repair #1:
			Flip sign of edge (cycd,cycd) to: positive

Example: get repaired models

Using option -t m, pymodrev will apply the repairs to the model and write to disk the repaired models consistent with the given observations.

$ pymodrev -m examples/boolean_cell_cycle/03/model.bnet -obs examples/boolean_cell_cycle/03/steadystate.lp steadystateupdater -t m

Repaired models keep the original name followed by a number, representing the number of minimal alternative repairs. For example, one could have:

  • model_1.bnet ... model_2.bnet, if there were only two possible minimal repaired models.
  • model_01.bnet ... model_18.bnet, if there were eighteen possible minimal repaired models.

Contributors

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

pymodrev-0.2.0.tar.gz (92.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymodrev-0.2.0-py3-none-any.whl (62.8 kB view details)

Uploaded Python 3

File details

Details for the file pymodrev-0.2.0.tar.gz.

File metadata

  • Download URL: pymodrev-0.2.0.tar.gz
  • Upload date:
  • Size: 92.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymodrev-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6a214b67e0d2bbbe306b008350fe46efa4bcb7f3897a9cc88f1796b682f2bbd5
MD5 4f216bb8cbc5f2eb09d1f4d58e06cb2b
BLAKE2b-256 e666b98e75afc9f2c3773e7787f56c91a7342ee684c795d487d7842d6b956fd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymodrev-0.2.0.tar.gz:

Publisher: python-publish.yml on ptgm/pymodrev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymodrev-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pymodrev-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 62.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymodrev-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7ce6d8b9f96117a8df30af99de34e6322500f6a342b2149a4708d45e739f08f
MD5 675062f3fcb9be1f7555b6c0f633d1d3
BLAKE2b-256 e9a3f9156d4f73f4b6f88360cca5a3747c0eadb21fa2e1aff2a0bf8da26840fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymodrev-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on ptgm/pymodrev

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page