Best match graph editing
Implemention of various heuristics and ILP formulations for best match graph (BMG) editing.
Best match graphs (BMGs) are a class of colored digraphs that naturally appear in mathematical phylogenetics as a representation of the pairwise most closely related genes among multiple species. An arc connects a gene x with a gene y from another species (encoded as the color of the nodes) Y whenever it is one of the phylogenetically closest relatives of x. This package contains various methods to edit an arbitrary vertex-colored digraph to a valid BMG, i.e., a graph that has a certain representation as (leaf-colored) tree.
Installation and Dependencies
bmg-edt requires Python 3.7 or higher. It has the following dependencies:
In order to use the ILP versions for BMG editing, an installation of Gurobi Optimizer (9.0 or higher) or IBM ILOG CPLEX Optimization Studio (12.10 or higher) is required.
Moreover, the corresponding Python packages gurobipy or docplex, respectively, must be installed.
Usage
The functions in bmg-edit require a NetworkX DiGraph as input.
Moreover, all nodes must have an attribute 'color'.
ILP
The following classes for optimal BMG editing are available in the module ilp.GurobiBMG (requires an installation of Gurobi Optimzizer):
- BMGEditor edits the input graph with an arbitrary number of colors to the closest BMG.
- BinaryBMGEditor edits the input graph with an arbitrary number of colors to the closest BMG that can be explained by a binary tree.
- TwoBMGEditor edits the input graph with at most two distinct colors to the closest (2-)BMG.
Example usage: (Click to expand)
solver = BMGEditor(input_graph)
solver.build_model()
# run the optimization with an optional time limit in seconds
solver.optimize(time_limit=None)
optimal_editing_cost, solution_graph = solver.get_solution()
The following classes for optimal BMG editing are available in the module ilp.CplexBMG (requires an installation of IBM ILOG CPLEX Optimization Studio):
- BMGEditor edits the input graph with an arbitrary number of colors to the closest BMG.
Example usage: (Click to expand)
solver = BMGEditor(input_graph)
solver.build_model()
# run the optimization with an optional time limit in seconds
solver.optimize(time_limit=3)
solver.get_solution()
optimal_editing_cost, solution_graph = solver.get_solution()
Heuristics Algorithms
The package also implements various heuristic approaches for BMG editing. Some of these methods are based on the unsatisfiable relation (UR) which are insertions or deletions of arcs that are associated with a certain inner node of the tree that explains the editing results. More precisely, the heuristics construct this tree in a top-down manner (i.e., starting with the root) and attempt, in each step, to minimize the UR (see refrenced paper below for details).
The class BMGEditor in the module BMGEditor manages the editing:
editor = BMGEditor(disturbed, binary=True)
editor.build('Mincut', objective='cost')
solution_graph = editor.get_bmg(extract_triples_first=False)
The following methods are available (first parameter of the `build` method): (Click to expand)
- 'Mincut'
- 'BPMF'
- 'Karger'
- 'Greedy'
- 'Gradient_Walk'
- 'Louvain'
- 'Louvain_Obj'
See the paper for an explanation of these methods.
Citation and References
If you use bmg-edit in your project or code from it, please consider citing:
- Schaller, D., Geiß, M., Hellmuth, M., Stadler, P. F. (2021) Heuristic Algorithms for Best Match Graph Editing. Algorithms for Molecular Biology (in press). arXiv:2103.07280 [math.CO].
Metadata
Release files for bmgedit 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bmgedit-0.0.7.tar.gz | 61.6 kB | Without provenance | Details for bmgedit-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bmgedit-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for bmgedit-0.0.7-py3-none-any.whl |
Total release size: 136.5 kB
Release files / bmgedit-0.0.7.tar.gz
| Download URL | bmgedit-0.0.7.tar.gz |
|---|---|
| Size | 61.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
985427f5b260e0ef6119b78cccb9d806ff22d743812dfedef26ee3507b34f51f
|
|
BLAKE2b-256 checksum How to use checksums |
ec32b0150475ee17712f781f0de9191ef9bb66c9d4f83571d8681c7c7f343c79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / bmgedit-0.0.7-py3-none-any.whl
| Download URL | bmgedit-0.0.7-py3-none-any.whl |
|---|---|
| Size | 74.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
00c423f6413497ee11db0cee85ad0994d6bfdeee3fafc3a4d434461301138df1
|
|
BLAKE2b-256 checksum How to use checksums |
cb02ea97866b369a9e500512958d789b3c4af1185789ed3cac7fc55bcb14530a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for bmgedit 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.