Skip to main content

Automatic Topological Generator for Framework Structures

Project description

AuToGraFS

PyPI Python CI codecov License

AuToGraFS — the Automatic Topological Generator for Framework Structures — generates Metal-Organic Frameworks (MOFs), Covalent Organic Frameworks (COFs) and other periodic framework materials by mapping molecular building blocks (SBUs) onto topological blueprints (nets). It also runs the pipeline in reverse: deconstruct an experimental structure back into building blocks and identify its net.

from autografs import Autografs

mofgen = Autografs()
pcu = mofgen.topologies["pcu"]
mof = mofgen.build(pcu, mappings={
    slot: "Zn_mof5_octahedral" if len(slot.atoms.indices_from_symbol("X")) == 6
    else "Benzene_linear"
    for slot in pcu.mappings
})
mof.write_cif("mof5.cif")   # cubic, a = 12.89 A (experiment: 12.9)

Original publication: "Automatic Topological Generator for Framework Structures", Addicoat, Coupry & Heine, J. Phys. Chem. A 2014, 118 (40), 9607.

Why AuToGraFS?

Several excellent framework assemblers exist — notably PORMAKE (Lee et al., whose MIT-licensed building-block library AuToGraFS gratefully bundles) and ToBaCCo (Colón / Gómez-Gualdrón groups). AuToGraFS was one of the first tools in this space (2014) and version 3 is a ground-up rewrite around a small set of design choices:

  • Works out of the box. pip install AuToGraFS ships 2686 RCSR topologies and 930 building blocks (63 curated SBUs + the 867-block PORMAKE library, 2- to 24-connected). No database generation step, no external binaries for building. 96.5 % of the shipped topologies are buildable immediately (see library coverage).
  • 2D nets are first-class. The 200 RCSR layer nets (hcb, sql, kgm, ...) that COF chemistry builds on are stored as plane-group topologies; a build produces a flat layer, and Framework.stack() turns it into a bulk crystal with AA / AB / serrated / staggered stacking at a chosen interlayer spacing.
  • Geometry, not symmetry tables. SBUs are matched to slots by optimally rotating their connection vectors onto the slot's (Hungarian assignment + Kabsch, proper rotations only — chiral building blocks are never silently mirrored). Point-group labels are metadata, not gates, so low-symmetry (C1) vertices stay usable.
  • Physically meaningful cells. The cell is optimized so that every inter-SBU bond sits at its covalent (Cordero) bond length, with the crystal system's constraints enforced (a cubic net optimizes a single length). MOF-5 comes out cubic at 12.89 Å against the experimental 12.9 — before any force-field relaxation. For lower-symmetry nets, whose idealized blueprint fixes proportions no cell parameter can repair, build(..., relax_embedding=True) additionally frees the slot positions within their site symmetry: measured over CoRE MOF, that cuts the built-versus-experimental density error about 3.3× (see embedding relaxation).
  • Fails loudly, never silently. Optional hard gates (max_rmsd, min_distance) raise typed exceptions instead of returning distorted or interpenetrating structures. Identical inputs give identical outputs.
  • Runs in reverse. Deconstruct a CIF (MOF or COF) into library-ready SBUs and identify its net; harvest a whole SBU library from a folder of structures.
  • Rod MOFs, both directions. The MOF-74 family and other rod MOFs are built around an infinite 1-periodic metal-oxo chain — no finite building block. AuToGraFS deconstructs them, gives each rod a screw-aware canonical identity (helicity is chiral and preserved), and builds them forward again — for straight and helical rods, including general (non-180°) screws. See Rod MOFs.
  • Post-processing built in. UFF4MOF assignment on every output, GULP input generation, EQeq partial charges, and one-call relaxation — in-process LAMMPS/UFF4MOF or any ASE calculator (GFN-FF, GFN1-xTB, DFTB+) — plus elastic constants via finite differences (pip install "autografs[relax]").
  • Safe, versioned data formats. Topology libraries are plain JSON (diffable, shareable, survives pymatgen upgrades) — not pickles.
  • A guided CLI. The autografs wizard walks through topology → SBUs → build → stack → export without writing a script.
  • MIT licensed, pure-Python installation on Linux / macOS / Windows.

If you need features AuToGraFS doesn't have yet (see Roadmap), PORMAKE and ToBaCCo are actively maintained and may fit better — comparisons age quickly, so evaluate against their current versions.

Installation

pip install AuToGraFS

Requires Python ≥ 3.11. Core dependencies: pymatgen, ASE, numpy, scipy, networkx.

Optional extras:

pip install "autografs[relax]"   # UFF4MOF relaxation via LAMMPS

On Windows, the LAMMPS wheel additionally needs the Microsoft MPI runtime (winget install Microsoft.MSMPI).

Development install:

git clone https://github.com/DCoupry/autografs.git
cd autografs
pip install -e ".[dev]"

Quickstart: MOF-5

from autografs import Autografs

mofgen = Autografs()

# what fits the pcu net?
available = mofgen.list_building_units(sieve="pcu")
for slot_type, sbu_names in available.items():
    print(slot_type, len(sbu_names), "candidates")
# Oh 6 : ... candidates      (the octahedral node)
# D*h 2 : ... candidates     (the linear edge)

# pick one SBU per slot type
topology = mofgen.topologies["pcu"]
mappings = {}
for slot_type in topology.mappings:
    n_connections = len(slot_type.atoms.indices_from_symbol("X"))
    if n_connections == 6:
        mappings[slot_type] = "Zn_mof5_octahedral"
    else:
        mappings[slot_type] = "Benzene_linear"

mof = mofgen.build(topology, mappings=mappings)
print(mof)
# Framework('pcu', 'Zn4 H12 C24 O13', abc=(12.89, 12.89, 12.89))

mof.write_cif("mof5.cif")

Then keep going: build options and batch enumeration, 2D COFs, editing, or deconstruction.

Command line

No script needed — the autografs wizard covers build, deconstruct, stack, and export interactively, and autografs-topologies (re)builds a topology library:

autografs                                    # bundled libraries; guided session
autografs --xyz my_sbus.xyz                  # add custom building blocks
autografs-topologies --use_rcsr -o topologies.json.gz   # regenerate the library

Full walkthrough of both commands: Command line.

Documentation

The README is the overview; the depth lives in docs/:

  • Building frameworks — the Python API: exploring the libraries, build, build_all, working with the Framework result (porosity, save/load, exports), relaxation (LAMMPS or any ASE calculator), partial charges, elastic constants, error handling.
  • 2D COFs and stacking — layer nets, turning a layer into a bulk crystal (AA / AB / serrated / staggered), and commensurate twisted (moiré) bilayers.
  • Rod MOFs — 1-periodic building units (MOF-74 & friends): deconstructing, screw-aware canonical identity, and forward building of straight and helical rods.
  • Editing — editing SBUs before a build, and post-build supercells, statistical defects, and functionalization.
  • Deconstruction — CIF → SBUs + net, net identification, interpenetration, COFs, batch harvesting, and assembly fingerprints.
  • Command line — the autografs wizard and autografs-topologies in full.
  • Extending the libraries — custom SBUs (XYZ) and custom topologies (CGD → JSON).
  • How it works & architecture — the 2014 idea, the build pipeline, and a module map of the codebase.
  • Library coverage — what fraction of RCSR is buildable today, and the nets that aren't.

FAQ

Does it build COFs? Yes — 2D layer nets are first-class. Build a flat layer on a layer net (hcb, sql, ...), then Framework.stack() turns it into a bulk crystal. See 2D COFs and stacking.

Do I need LAMMPS? Only for Framework.relax(). Building, export, deconstruction, and everything else are pure-Python. Install the relaxation backend with pip install "autografs[relax]".

My SBU is rejected / I get AlignmentError — why? Usually the geometric gate: the SBU's connection-vector shape doesn't match the slot's within max_rmsd. Raise max_rmsd, pick a net whose vertex figure fits, or edit the SBU. Point-group symmetry is diagnostic metadata, not the gate. If you passed bond_tolerance, the same exception also means the build did not close — correctly shaped units that no cell can bring to bonding distance.

My built structure is too open / its density looks wrong. Most likely the blueprint's proportions rather than your SBUs. A build places every unit at its idealized slot centre and only varies the cell, and the idealized (maximum-symmetry, near-equal-edge) embedding is systematically more open than real chemistry — no single cell scale can fix a fractional coordinate. Try build(..., relax_embedding=True), which frees the slot positions within their site symmetry; on nets that have any such freedom it cuts the density error about 3.3× over a CoRE MOF corpus. High-symmetry nets (pcu, dia, fcu) have nothing to free and are unaffected. Details and the measured trade-offs are in embedding relaxation.

Is my net in the library? 2686 RCSR nets ship; list them with mofgen.list_topologies(). 96.5 % are buildable out of the box — the rest, and how to enable them, are in library coverage.

Does it handle rod MOFs (MOF-74, metal carboxylates)? Yes — rod MOFs, whose building unit is an infinite 1-periodic chain, are a first-class case in both directions: deconstruct them, harvest rod families with a screw-aware canonical identity, and build them forward (straight and helical rods, including general non-180° screws). See Rod MOFs.

deconstruct() raised DeconstructionError — why? It refuses disordered structures, molecular crystals (no periodic framework to analyze), bare 1-periodic polymers with no framework connections, and 2-periodic (layer) building units. Rod MOFs and metal-free COFs are supported. See Deconstruction.

CIF or JSON — which should I save? CIF for downstream tools, but it loses the bond graph and per-atom provenance that post-build editing needs. Use Framework.save() / Framework.load() (versioned JSON) to keep a framework editable across sessions.

Can I still load my old .pkl topology library? Yes, with a warning. Convert it once with autografs.topology_io.save_topologies to the JSON format and keep that.

Development

pip install -e ".[dev]"

pytest                    # slow tests auto-skipped
pytest -m slow            # only the slow tests
ruff check src tests      # lint
ruff format src tests     # format
mypy src/autografs        # type check

Tests live in tests/; scripts/ holds the coverage audit (sbu_coverage.py), the PORMAKE import (import_pormake_bbs.py), and fixture generators. Architecture and module map: How it works.

Roadmap

The 3.x line has reached feature parity with 2.x and gone well beyond it: the inverse pipeline (deconstruction, net identification, SBU harvesting for MOFs and COFs), rod-MOF support in both directions (helical, cross-linked multi-rod etb/MOF-74, woven multi-axis and lattice-diagonal channels), IZA zeolite import (autografs-topologies --use_iza), partial charges, ASE-driven relaxation, elastic constants, commensurate twisted bilayers, and embedding relaxation for low-symmetry nets have all landed. Remaining directions — EPINET import and curated high-connectivity SBU packs for the last uncovered nets — are tracked in the issue tracker.

Citing

If you use AuToGraFS, please cite:

@article{autografs2014,
  title   = {AuToGraFS: Automatic Topological Generator for Framework Structures},
  author  = {Addicoat, Matthew A. and Coupry, Damien E. and Heine, Thomas},
  journal = {The Journal of Physical Chemistry A},
  volume  = {118},
  number  = {40},
  pages   = {9607--9614},
  year    = {2014},
  doi     = {10.1021/jp507643v}
}

Related work you may also want to cite:

  • UFF4MOF (the force field used for typing and relaxation): Addicoat, Vankova, Akter & Heine, J. Chem. Theory Comput. 2014, 10, 880; Coupry, Addicoat & Heine, J. Chem. Theory Comput. 2016, 12, 5215.
  • PORMAKE (if you use the bundled pormake.xyz building blocks): S. Lee et al., ACS Appl. Mater. Interfaces 2021, 13, 23647.
  • RCSR (the source of the bundled topologies): O'Keeffe, Peskov, Ramsden & Yaghi, Acc. Chem. Res. 2008, 41, 1782.

License

MIT License — see LICENSE.txt.

The bundled building-block library pormake.xyz is converted from PORMAKE (MIT License, Copyright (c) 2022 Sangwon Lee; see PORMAKE_LICENSE.md).

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

autografs-3.2.0.tar.gz (11.5 MB view details)

Uploaded Source

Built Distribution

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

autografs-3.2.0-py3-none-any.whl (11.4 MB view details)

Uploaded Python 3

File details

Details for the file autografs-3.2.0.tar.gz.

File metadata

  • Download URL: autografs-3.2.0.tar.gz
  • Upload date:
  • Size: 11.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for autografs-3.2.0.tar.gz
Algorithm Hash digest
SHA256 5aec2e8b5adbee69212b5ba9f53d4d979d00b5ef54b43f3ad80aab1d15dbac89
MD5 2fb5ba026875637aeccdeac1501bc749
BLAKE2b-256 c4ea3effab2440441f2251f27a647419c80f944254cd99976a864303b615dea4

See more details on using hashes here.

Provenance

The following attestation bundles were made for autografs-3.2.0.tar.gz:

Publisher: publish.yml on DCoupry/autografs

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

File details

Details for the file autografs-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: autografs-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for autografs-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6b1a06a76ff21e46bc2eccc7dbe4fe03bd6be086881a93d63272d208e8df575
MD5 0c31a564df3f10ab7ef93a4b98cb40f3
BLAKE2b-256 6624ef92f9a448375df24a83cc457ff00dfbacd5036146e674f40f0556193c61

See more details on using hashes here.

Provenance

The following attestation bundles were made for autografs-3.2.0-py3-none-any.whl:

Publisher: publish.yml on DCoupry/autografs

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