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

Metadata

Release files for fragment-explorer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fragment-explorer 0.1.0
File Size Uploaded Provenance Actions
fragment_explorer-0.1.0.tar.gz 11.3 kB Without provenance Details for fragment_explorer-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fragment-explorer 0.1.0
File Interpreter ABI Platform Actions
fragment_explorer-0.1.0-py3-none-any.whl Python 3 none any Details for fragment_explorer-0.1.0-py3-none-any.whl

Total release size: 23.6 kB

Release files / fragment_explorer-0.1.0.tar.gz

Download URL fragment_explorer-0.1.0.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d3adbf167320e08195e5faceec2a40f363288f1284182d4a25317f1f354d8f6a
BLAKE2b-256 checksum
How to use checksums
0f1886b9837982392811a35b95c9948a0f4a4240748018b3453eeda49b4ad7de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / fragment_explorer-0.1.0-py3-none-any.whl

Download URL fragment_explorer-0.1.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dca2fddbbd83866761c700d5dfd6c7a5dc840608a3d9284daca6499550e2cac3
BLAKE2b-256 checksum
How to use checksums
19fcc735095a5a63727aa18a4a507eaa5b6bb111fc50476f5644537763081fee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for fragment-explorer 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page