Skip to main content

A Python package to analyze topological properties of sets of words when their main source of variation are insertions and deletions, using the Insertion Chain Complex framework.

Project description

InDelsTopo

A Python package to analyze topological properties of sets of words when their main source of variation are insertions and deletions, using the Insertion Chain Complex framework.

Introduction

InDelsTopo implements the Insertion Chain Complex framework (Jonoska, Martinez-Figueroa, and Saito, arXiv:2509.12607), originally developed to analyze variation in collections of DNA sequences following double-strand break repair.

The package enables general analysis of word sets where insertions and deletions are the primary source of variation, using topological tools such as persistent homology and Euler characteristic curves.


Features

  • Define and generate Insertion Chain Complexes and Filtrations based on sets of words, over any finite alphabet.
  • Support for computing homology using either:
    • Pure Python/NumPy backend (with coefficients in $\mathbb{Z}_2$).
    • SageMath for symbolic computation with coefficients in any supported ring (including $\mathbb{Z}$).
  • Computation of persistent homology barcodes for Filtrations.
  • Computation of Euler Characteristic Curves for Filtrations.
  • Graphic representation of Complexes (mostly useful for small and simple complexes).
  • Functions and classes to create and manipulate Blocks.

Requirements

  • Python 3.8+
  • NumPy
  • Networkx
  • Simpy
  • Scipy

Optional (for extended functionality):

  • SageMath (for symbolic homology computation)

Installation

pip install InDelsTopo
# Required dependencies (if not already installed):
# pip install sympy numpy matplotlib networkx scipy

Quick Example

from InDelsTopo import Complex

# Define a set of words
W = ['abbc', 'ab^2c^2', 'abc', 'abc**2', 'abc**2d']

# Create a complex
K = Complex()
K.compute_d_skeleton(W)

# Inspect
print(K)
print("2-blocks:", K[2])

# Visualize (uncomment for interactive plot)
# %matplotlib widget
K.get_graph()

Cheat Sheet: Main Classes and Methods

Class / Object Method / Attribute Description
Complex compute_d_skeleton(W, max_dim=d, verbose=False) Construct the d-skeleton of the insertion chain complex from a set of words W.
add_blocks(list_blocks, already_blocks=False) Add new blocks to the complex. If already_blocks=True, the elements are Block objects.
remove_blocks(list_blocks) Remove specified blocks and all super-faces containing them.
get_graph() Visualize the complex.
dim Maximum dimension of the complex.
euler_characteristic Euler characteristic of the complex.
get_betti_numbers_z2() Compute Betti numbers with coefficients in $\mathbb{Z}_2$.
get_maximal_blocks() Returns dictionary of maximal blocks by dimension.
Filtration compute_d_skeleton(W, heights=None, max_dim=d) Construct a filtration using word heights.
add_blocks(list_blocks, list_heights) Add blocks to the filtration, optionally updating heights of faces.
remove_blocks(list_blocks) Remove blocks and all higher-dimensional blocks containing them.
get_complex(height=None, max_dim=d) Return a subcomplex at a given height.
filtration_dict Dictionary of blocks by dimension and their heights.
dim Maximum dimension of the filtration.
filtration_values Sorted list of all heights in the filtration.
Block Constructor: Block(string) Create a block from a string representation.
get_all_faces() Returns all subfaces of the block.
get_all_facets() Returns codimension-1 faces.
get_upper_facets() / get_lower_facets() Returns only upper or lower facets.
get_all_vertices() Returns all vertices.
get_face(indices_plus, indices_minus) Returns a specific face by upper/lower indices.
get_vertex(indices) Returns a specific vertex by index list.
Chain Constructor: Chain(string) Linear combination of blocks with integer coefficients.
Arithmetic: +, -, * Combine chains and multiply by integers.
get_blocks() Returns list of blocks in the chain.
get_dict_blocks() Returns dictionary of blocks with their coefficients.
boundary() Compute boundary of the chain.

Documentation

Full documenation can be found at usf-dna-knot-math.github.io/InDelsTopo/

Tutorial

The full Jupyter Notebook tutorial is available in tutorials/InDelsTopo_Tutorial.ipynb.

It covers:

  1. Complexes: constructing, inspecting, and visualizing.
  2. Filtrations: heights, sublevel sets, and persistent homology.
  3. Blocks and Chains: creating, combining, and computing boundaries.
  4. Manipulating complexes and filtrations: adding/removing blocks.
  5. Optional SageMath integration for homology over $\mathbb{Z}$.

Acknowledgements

This package was built under auspices of the Southeast Center for Mathematics and Biology, an NSF-Simons Research Center for Mathematics of Complex Biological Systems, under National Science Foundation Grant No. DMS-1764406 and Simons Foundation Grant No. 594594 as well as NSF DMS-2054321, CCF-2107267, CCF-2505771 and the W.M. Keck Foundation.

Citation

If you use InDelsTopo in your research, please cite the following preprint:

Jonoska, N., Martinez-Figueroa, F., & Saito, M. (2025). The Insertion Chain Complex: A Topological Approach to the Structure of Word Sets. arXiv:2509.12607

Contributing

We welcome contributions to InDelsTopo! You can help by:

  • Reporting bugs or issues via the GitHub Issues page.
  • Submitting pull requests with improvements, bug fixes, or new examples.
  • Suggesting new features or documentation improvements.

Before contributing, please ensure that your code follows the existing style and passes tests.

License

InDelsTopo is released under the MIT License. See the LICENSE file for details.

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

indelstopo-0.1.0.tar.gz (627.1 kB view details)

Uploaded Source

Built Distribution

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

indelstopo-0.1.0-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

Details for the file indelstopo-0.1.0.tar.gz.

File metadata

  • Download URL: indelstopo-0.1.0.tar.gz
  • Upload date:
  • Size: 627.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.8

File hashes

Hashes for indelstopo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2e665c972f10f7f1a97cbdbe1ed079639f35ea27ed28c839a702c8bc0e8a9274
MD5 84eff8b8f10b0029773f0be8e3b85dec
BLAKE2b-256 06ef4a9fb2795c7978801bf5a738749a2f841589d69a2e5446b36253c7670986

See more details on using hashes here.

File details

Details for the file indelstopo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: indelstopo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 42.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.8

File hashes

Hashes for indelstopo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 83eb4d91850297814b75b6d1019dcbcfaf90b8f2429a8987cd2f90a3f73f5a7e
MD5 1c7b2891c6b33398bde7d88efeda4ddc
BLAKE2b-256 85369692db1db197a08a0e8934c47ea6abf2535596d73543be8048c5bd5c3d56

See more details on using hashes here.

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