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.1-cp312-cp312-win_amd64.whl (196.6 kB view details)

Uploaded CPython 3.12Windows x86-64

chemigraph-1.0.1-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.1-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.1-cp311-cp311-win_amd64.whl (201.9 kB view details)

Uploaded CPython 3.11Windows x86-64

chemigraph-1.0.1-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.1-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.1-cp310-cp310-win_amd64.whl (201.6 kB view details)

Uploaded CPython 3.10Windows x86-64

chemigraph-1.0.1-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.1-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.1-cp39-cp39-win_amd64.whl (202.1 kB view details)

Uploaded CPython 3.9Windows x86-64

chemigraph-1.0.1-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.1-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.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: chemigraph-1.0.1-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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6382bc20a1acd2ea1b6fb02c30f033221d5718f92e3df3dca5f9a03964f3f150
MD5 b9269847d1bbc07b9f4602ec235d1468
BLAKE2b-256 b740a6d4b8811559d610329cb7b25ebaab5c85bf96561ab57b128194fe57c1fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 56c787e1053811b34f1317340b8484bb2ebcb2b6d12e58660025e3e17b6aadf0
MD5 5db89a47d5109c928199a1f4ef939ac4
BLAKE2b-256 20858f2e29644abf6a6a3aa6597eb54b598ef654b0933603f4328c715218bcc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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.1-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.1-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 bab7ea78b91d3c1755574aae8a0e16cdc547251284bb59e037306ff90ceb4181
MD5 179783bc8a37dd99e6cb86ffd622df68
BLAKE2b-256 3d2d9058b429f40b9e78c5b56b81a58f211ec35a57b48b41c943a5ca4a989ed3

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: chemigraph-1.0.1-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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bd075b71a29b6182d42b717cbc718e6d07477be4fcff469d2d0e93343c365d42
MD5 cc82afea942f88581d2e3f366bd6280b
BLAKE2b-256 935dfbe8f503e92a6e8bedf0f0c2da11eaea5e24554f547d46312aa5f392f2b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c3b77e3cd362c16caf63dc5f93a1dacb32782327e9b991947be6b6b68c8b65c
MD5 c1edce5e017912c02aff5498ab9061a7
BLAKE2b-256 85176b04866dc7929fa785893aa6baa73e95c0bafd7fa78d40a754fe241a63cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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.1-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 d3b089b09e85a39f5f60eaad1548a9edd8716d2a9702248dc83a339ab6bc7dd4
MD5 a666ae66c2ecf2caaade7e23b9436002
BLAKE2b-256 1f25ff266845acdea9f612ea2cce460d10619eea614d32bad8d491aaa5aafa24

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: chemigraph-1.0.1-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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a9e294940270383326a75008c7eee6e27d4fb674c200b0040e150241d94c4a0e
MD5 a4602702d1c0937b767c25dc3882bc3f
BLAKE2b-256 74c968d5bac50527f65be1df9e363f07b6286acf078c64370b9ab8857b15fee1

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 caa19f2777516b4cdfa39cf635e7735efdef6b284a3ac135fb39e72ae984d665
MD5 5c2d21242904ff0ade51b984903886d1
BLAKE2b-256 6f7cc6a7112a088dd59c8a5856b0684970e14b9937fa6f17e9e1a4b0779cc582

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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.1-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.1-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 fa1f1ca21a1894c648a09e748805d9bd4cfc09a0ae6aab8f03e8ef27b3e37ac1
MD5 3f67f845462eb74cb1513622648e2a33
BLAKE2b-256 d1e77630feb1850306479d2c3e1b63f4ff3ccf78c054175e70265a6543ace195

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: chemigraph-1.0.1-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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a419648228d25191eaefc9d8482aa13629f2f9b7364d763b1312912ed706a19c
MD5 d810a396ed48902f4ad3106baddb1947
BLAKE2b-256 b0469a495417b7290ecc4d810a554447c7fa8171a7c1a507670dcb179b221e41

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3a60d88bcd69937c91fecc9f1185bb9e501ea26b8b94dbe6602a88ce11b9fcd4
MD5 c5b0a80920c2a2a8f90dfa6fb79a5447
BLAKE2b-256 26874abee4e6a581475cd8f180662b3ff3de84d99d233d2502ca9d2b40c54e8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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.1-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for chemigraph-1.0.1-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 83d6f1905de847eb0515ba08017db3e90fe7b5d53cc138a14c8978e3e1a8cca4
MD5 a7a7bf6260a600f104fed9585958ef26
BLAKE2b-256 4a641e9007ce6447fadebb98402dcdff5a2d63129056269a07965a2567ae35cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for chemigraph-1.0.1-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