Skip to main content

fragment-explorer

Extract, visualize, and inspect molecular fragments (fingerprint bits) shared by molecules within a class — built on RDKit.

Install

pip install fragment-explorer

Use as a library

from fragment_explorer import load_molecules, load_features, load_labels
from fragment_explorer import get_best_bit, pick_diverse, compute_mcs
from fragment_explorer import draw_molecule_grid

mols = load_molecules("molecules.csv", smiles_col="SMILES")
mol_features = load_features("morgan_bits.csv")   # rows=molecules, cols=bit ids
y_labels = load_labels("labels.csv", label_col="labels")

actives = get_best_bit(mols, class_no=1, mol_features=mol_features,
                        y_labels=y_labels, bit_id=29)
draw_molecule_grid(actives, save_path="actives.svg")

Use from the command line

python -m fragment_explorer \
  --smiles-csv molecules.csv --smiles-col SMILES \
  --features-csv morgan_bits.csv \
  --labels-csv labels.csv --labels-col labels \
  --class-no 1 --bit-id 29 \
  --n-diverse 10 \
  --mol-index 0 --root-atom 0 --env-radius 6 \
  --output-dir results/class1_bit29

This runs the full pipeline:

  1. loads molecules / fingerprint-bit matrix / class labels (all must be row-aligned — same molecule order in all three files)
  2. pulls out the molecules of --class-no that have --bit-id set (as user defined)
  3. label.csv contains encoded class labels of molecules as integer numbers
  4. morgan_bits.csv contains molecular fingerprints. Each row is a molecule Bit-based vector and headers are Bit IDs
  5. saves a grid image of all of them (*_all.svg)
  6. MaxMin-picks --n-diverse diverse molecules and saves a grid of those (*_diverse.svg)
  7. computes the Maximum Common Substructure and saves it (*_mcs.svg)
  8. draws the Morgan-bit highlight for one chosen molecule (--mol-index) and the atom environment around --root-atom (--env-radius)

--mol-index and --root-atom are prompted for interactively (like the original notebook's input() calls) if you don't pass them as flags. Pass --skip-inspection to stop after step 5.

Run python -m fragment_explorer --help for the full flag list.

Notes

  • --features-csv must have one row per molecule and one column per fingerprint bit id (column headers are coerced to int).
  • --labels-csv can be .csv (pick a column with --labels-col) or .npy.
  • Images are written as SVG by default. PNG output (use_svg=False) requires the optional Pillow dependency: pip install fragment-explorer[png].

License

MIT

Download files

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

Source Distribution

fragment_explorer-0.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

fragment_explorer-0.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fragment_explorer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d3adbf167320e08195e5faceec2a40f363288f1284182d4a25317f1f354d8f6a
MD5 fb79ec7cc6717dc1e62449c0e3f0bef1
BLAKE2b-256 0f1886b9837982392811a35b95c9948a0f4a4240748018b3453eeda49b4ad7de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fragment_explorer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dca2fddbbd83866761c700d5dfd6c7a5dc840608a3d9284daca6499550e2cac3
MD5 80dd5905dc22ff612fff337530944e98
BLAKE2b-256 19fcc735095a5a63727aa18a4a507eaa5b6bb111fc50476f5644537763081fee

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 Sentry Error logging StatusPage Status page