Skip to main content

ChemiGraph — a Python library for chemical graph theory: a priori VIF/LPI and EI mass-spectral fragment prediction directly from a molecular structure.

Project description

ChemiGraph logo

ChemiGraph

A Python Library for Chemical Graph Theory

ChemiGraph turns a molecular structure into quantum-chemical insight using only graph theory and linear algebra. It is a fully automated implementation of the Valency Interaction Formula (VIF) theory — formulated by Oktay Sinanoğlu (Theoret. Chim. Acta 1985, 68, 251) — and its application to mass spectrometry by Berkay Sütay (JOTCSA 2017, 4(1), 179).

Give it nothing but a structure (a SMILES string or a PubChem name) and it will:

  • build the VIF graph of the molecule,
  • compute the Level Pattern Indices (LPI) = the exact count of bonding, nonbonding and antibonding molecular orbitals,
  • locate the soft bonds (the weakest linkages), and
  • predict the principal electron-impact (EI) mass-spectral fragmentsa priori, in milliseconds, without any large-scale quantum-chemical computation.

Theoretical background

1. The molecule becomes a graph. Each atom is drawn as a set of vertices equal to the size of its valence shell — 1 for H/He, 4 (s + 3p) for the second- and third-row main-group elements, 9 for transition metals. The vertices of one atom form an intra-atomic clique (the hybrid-orbital interactions), and each chemical bond is an edge joining vertices of neighbouring atoms.

2. The graph is the Hamiltonian. This picture is exactly the matrix representation — the adjacency matrix — of the one-electron molecular Hamiltonian in a non-orthonormal valence-orbital basis. Nothing is approximated away; the graph encodes the same connectivity the operator does.

3. Reduction = congruence = invariant signature. Sinanoğlu showed that the pictorial reduction rules of VIF are congruence transformations (A → SᵀAS) of this matrix under the general linear group. By Sylvester's law of inertia (1852), a congruence transformation cannot change the signature — the number of positive, zero and negative eigenvalues. That invariant is the LPI:

LPI = (n+, n0, n-)
      n+  = # positive eigenvalues = bonding molecular orbitals
      n0  = # zero eigenvalues     = nonbonding molecular orbitals
      n-  = # negative eigenvalues = antibonding molecular orbitals

So the electronic level pattern of a molecule can be read off its structural formula alone — no basis-set SCF cycle required.

4. Soft bonds and mass spectra. Sütay's insight (2017) is that the interactions which cancel during reduction — the soft bonds — are the chemically weakest linkages, and are precisely the bonds that break first under 70 eV electron impact. Each soft-bond cleavage is a fragment peak in the mass spectrum.

What ChemiGraph adds

It reduces Sinanoğlu's hand-drawn calculus directly to numerical linear algebra:

LPI(G) = signature of the adjacency matrix of G,  via numpy.linalg.eigvalsh   (O(n³))

Soft-bond detection is a rank-2 perturbation test: if deleting bond (i, j) leaves the LPI unchanged, that bond would already have vanished during reduction — so it is soft. A chemically motivated α-cleavage rule suppresses unphysical fragments (e.g. a bare carbonyl oxygen would never leave as atomic O), and every m/z is reported on the nominal-mass (most-abundant-isotope) scale, the mass-spectrometric convention.

The implementation reproduces the reference LPI values of Sinanoğlu (1985) and the mass-spectral predictions of Sütay (2017) — including the chlorine- substituted cyclohexanone-oxime of the 2017 paper, for which it returns the experimental peaks at m/z = 35 (Cl), 17 (OH) and 218 (M − OH) exactly.


Worked example — nitrobenzene

chemigraph nitrobenzene

Nitrobenzene VIF graph    Nitrobenzene predicted MS

Left — the VIF graph. Every atom is a coloured clique of valence-orbital vertices; solid black edges are ordinary bonds; red dashed edges are soft bonds. The single soft bond linking the benzene ring to the nitro group is the C–N bond — LPI = {18, 0, 23}.

Right — the predicted mass spectrum. Because the C–N bond is soft, the nitro group is lost, giving the phenyl cation C₆H₅⁺ at m/z = 77 — the dominant fragment observed experimentally — alongside the molecular ion M⁺ at 123. This matches Figure 6 of Sütay (2017).

Bar heights are schematic: VIF predicts which fragments form, not their intensities.


Installation

ChemiGraph is distributed as a pre-compiled package — one pip command installs it and its five scientific dependencies (numpy, networkx, matplotlib, rdkit, mendeleev). Python 3.9+ is required.

pip install chemigraph

pip automatically downloads the pre-built binary matching your operating system (Linux, Windows, macOS) and Python version. Alternatively, grab the wheel for your platform from the Releases page and install it directly:

pip install chemigraph-1.0.0-<your-platform>.whl

Windows users: install Python from https://www.python.org/downloads/ (tick “Add Python to PATH” during setup), then open the Command Prompt (Win + Rcmd → Enter) and run pip install chemigraph. A virtual environment (python -m venv venv && source venv/bin/activate) is recommended on every platform.


Usage

From the terminal

After installation a chemigraph command is available everywhere:

chemigraph aspirin                 # a molecule name → fetched from PubChem
chemigraph "Clc1ccccc1"            # a raw SMILES string
chemigraph caffeine nitrobenzene   # several molecules in one run
chemigraph                         # no argument → the substituted-halogen demo

Each molecule prints its LPI and predicted fragment list, and opens two windows: the VIF graph and the predicted mass spectrum.

As a Python library

import chemigraph as cg

# Full analysis from a SMILES string
result = cg.VIF("Clc1ccccc1")           # chlorobenzene
lpi = result["lpi"]
print(lpi["n+"], lpi["n0"], lpi["n-"])  # 15 0 18   (bonding / nonbonding / antibonding)
print(result["mol_mass"])               # 112       (nominal M+)

# Fetch a molecule by name from PubChem
cg.VIF_from_pubchem("nitrobenzene")

# Silent analysis (no plots), inspect the fragments
r = cg.VIF("CC(=O)Oc1ccccc1C(=O)O", draw=False, show_spectrum=False, verbose=False)
for f in r["fragments"]:
    if f["split"]:
        print(f["bond"], "->", [(x[0], x[2]) for x in f["fragments"]])

Interpreting the output

Field Meaning
lpi {n+, n0, n-} — counts of bonding / nonbonding / antibonding MOs
mol_mass nominal mass of the molecular ion M⁺ (m/z)
soft_bonds the weak interactions detected by the perturbation test
fragments predicted EI fragments; each split gives two (formula, m/z) pairs

References

  1. O. Sinanoğlu, Theoret. Chim. Acta 1985, 68, 251.
  2. O. Sinanoğlu, Chem. Phys. Lett. 1984, 103, 315.
  3. B. Sütay, J. Turk. Chem. Soc. A 2017, 4(1), 179.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

chemigraph-1.0.0-cp312-cp312-win_amd64.whl (196.6 kB view details)

Uploaded CPython 3.12Windows x86-64

chemigraph-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

chemigraph-1.0.0-cp312-cp312-macosx_10_13_universal2.whl (495.7 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

chemigraph-1.0.0-cp311-cp311-win_amd64.whl (201.9 kB view details)

Uploaded CPython 3.11Windows x86-64

chemigraph-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

chemigraph-1.0.0-cp311-cp311-macosx_10_9_universal2.whl (496.3 kB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

chemigraph-1.0.0-cp310-cp310-win_amd64.whl (201.6 kB view details)

Uploaded CPython 3.10Windows x86-64

chemigraph-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

chemigraph-1.0.0-cp310-cp310-macosx_10_9_universal2.whl (501.4 kB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

chemigraph-1.0.0-cp39-cp39-win_amd64.whl (202.1 kB view details)

Uploaded CPython 3.9Windows x86-64

chemigraph-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

chemigraph-1.0.0-cp39-cp39-macosx_10_9_universal2.whl (505.8 kB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file chemigraph-1.0.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: chemigraph-1.0.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 196.6 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for chemigraph-1.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ca81aad811e5c2bf9a6525456c9a9371a9e09a8e26cb52b559e7f9b27831f586
MD5 35b7ed3ae66292e27083ab9b041961da
BLAKE2b-256 4210c6a35046204622439e9996c3d3f339582d90801bf376e3463663526547bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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

File details

Details for the file chemigraph-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e9b5a768420f5669b34d199c41880c1328674f175de009bc55236335f7a55751
MD5 f15ccddc326a909f3e9d31d77b86cabe
BLAKE2b-256 8449360bc4da3a4ed36ebdee27878044568720145b76b5d3a84e3224739e61c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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

File details

Details for the file chemigraph-1.0.0-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.0-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 340dabc5b6b244698f971596d28305f6740048ce29f6373674978b6cc1b40ea5
MD5 92443db2ab744031e53b31f0d8b5d2ea
BLAKE2b-256 3f6ae8645e2ad82294f523b513bfaaa82f614def0996b94468d18d2879d13440

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp312-cp312-macosx_10_13_universal2.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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

File details

Details for the file chemigraph-1.0.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: chemigraph-1.0.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 201.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for chemigraph-1.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 59e5347492b66eb63cc98c704a0ad14879b2f67d182d84e05621b819fb813fe1
MD5 14ffb2644ccf6b6718f511073be4c659
BLAKE2b-256 fcd089d5332cfcf1a8ea651f1d59b6a8ba5e5d571746eff93abd082a8c21a490

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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

File details

Details for the file chemigraph-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5624d921b85c7a629f231b10f7d90a11b05a4c1a4e122f90b5a09222aaa7ff1b
MD5 5391d6a8f0aff2598645e29bf5457629
BLAKE2b-256 8352441ea00e323d2e0a7f88ef67e1ca3afb3c0a14b9a6bf46ee1aa44c26a2d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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

File details

Details for the file chemigraph-1.0.0-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 930aa065b488ef84d22eecf9df7a0a85af5e4eb23e67f8f0f1b6c0e8515a1376
MD5 9aeea481d9ae203c40107602fe22224b
BLAKE2b-256 80f070729b20b50d20b6c9a64857fc0339f50156dc6ce0d44cfbad8d6a388376

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp311-cp311-macosx_10_9_universal2.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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

File details

Details for the file chemigraph-1.0.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: chemigraph-1.0.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 201.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for chemigraph-1.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e33096e40dfd19b994027ecb0db919a7ef1987d7898b6a979390a80fe4b4f033
MD5 10b545c0ba6667f30477296ccc79c8fa
BLAKE2b-256 fd0b0613cf9f47a0497e6e15606916682f169189a62249a6f8ee9c117e0b5bff

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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

File details

Details for the file chemigraph-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e6efe146719bfaad75da3b85800015a74d001d9638f41ead169f50d72105cecf
MD5 3c16a6fce31f2a051ac17aef1b759323
BLAKE2b-256 13711c278bac78e75d42b33e514e7fb366e6b1d25baef921b86e8848b5541e46

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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

File details

Details for the file chemigraph-1.0.0-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 6363c0d993f3d70da6712b0fadbd183a2bf8c22dffa3c6c65ab3b9d516e6cd99
MD5 7e74ce209d8c143cef637f5d2f39f311
BLAKE2b-256 e12480d52902480df6f5af107c2f1581e6187e2fe78d943047929196164ba07e

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp310-cp310-macosx_10_9_universal2.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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

File details

Details for the file chemigraph-1.0.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: chemigraph-1.0.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 202.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for chemigraph-1.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 cf566e0167f5c5c1f87dfb253d74fbc910dd8521d4fda6f0fe959eec9126f504
MD5 d901b0d44c21c1245a063d96f925113a
BLAKE2b-256 c32813af5605c75aed9edefc7f8db1fbf92f30aff187516cbe28fb4579962261

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp39-cp39-win_amd64.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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

File details

Details for the file chemigraph-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d209bb3993685671d54fd70e7ce9a206e7de0b56f1effc11e93d673cafc9969c
MD5 93eccfbb046e0c893430abdeca200a2f
BLAKE2b-256 abab05babd245be29293336531fa01be0009b0bee9f79b986accaba95bb68ba1

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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

File details

Details for the file chemigraph-1.0.0-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 20a2805c1e79a371e0246de7bd41e8f7069a619c09854dd623bca3bbff4e5f64
MD5 c8d668e90ab039d387e888de0de85349
BLAKE2b-256 e603daa325f527e95a3a2484314eaa3d5e946db5554ea76d47f1ef5c480ca1e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.0-cp39-cp39-macosx_10_9_universal2.whl:

Publisher: wheels.yml on SinanGokmen/chemigraph

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