Module python

Module python 

Source
Expand description

Expose public assembly_theory functionality to a Python package using pyo3.

The package is available on PyPI; see that README for installation and usage instructions. To build the Python package directly from this crate’s source code, see the instructions in the GitHub README.

Note that all Rust functions in this module have the form _fn_name, which correspond to the actual Rust function fn_name elsewhere in the crate and are exposed to the Python package as fn_name.

§Python Example

import assembly_theory as at

# Load a mol block from file...
with open('data/checks/anthracene.mol') as f:
    mol_block = f.read()

# ...or define the mol block directly.
mol_block = """


 14 16  0  0  0  0  0  0  0  0999 V2000
   25.2202  -16.2366    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   25.2202  -17.6385    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   26.4373  -18.3394    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   26.4373  -15.5356    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   27.6471  -16.2366    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   27.6412  -17.6385    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   28.8523  -18.3446    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   28.8644  -15.5409    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   30.0755  -16.2469    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   30.1327  -17.6453    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   31.2674  -18.3552    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   32.4846  -17.6672    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   32.4973  -16.2688    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   31.2927  -15.5589    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  9  8  2  0     0  0
  8  5  1  0     0  0
  5  4  2  0     0  0
  4  1  1  0     0  0
  1  2  2  0     0  0
  2  3  1  0     0  0
  3  6  2  0     0  0
  9 10  1  0     0  0
 10 11  1  0     0  0
 11 12  2  0     0  0
 12 13  1  0     0  0
 13 14  2  0     0  0
 14  9  1  0     0  0
  5  6  1  0     0  0
  6  7  1  0     0  0
  7 10  2  0     0  0
M  END"""

# Calculate the molecule's assembly index.
at.index(mol_block)  # 6

Functions§

_depth
Compute assembly depth; see Pagel et al. (2024).
_index
Computes a molecule’s assembly index using an efficient default strategy.
_index_search
Computes a molecule’s assembly index and related information using a top-down recursive search, parameterized by the specified options.
_mol_info
Get a pretty-printable string of this molecule’s graph representation.