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:
- loads molecules / fingerprint-bit matrix / class labels (all must be row-aligned — same molecule order in all three files)
- pulls out the molecules of
--class-nothat have--bit-idset (as user defined) label.csvcontains encoded class labels of molecules as integer numbersmorgan_bits.csvcontains molecular fingerprints. Each row is a molecule Bit-based vector and headers are Bit IDs- saves a grid image of all of them (
*_all.svg) - MaxMin-picks
--n-diversediverse molecules and saves a grid of those (*_diverse.svg) - computes the Maximum Common Substructure and saves it (
*_mcs.svg) - 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-csvmust have one row per molecule and one column per fingerprint bit id (column headers are coerced toint).--labels-csvcan be.csv(pick a column with--labels-col) or.npy.- Images are written as SVG by default. PNG output (
use_svg=False) requires the optionalPillowdependency: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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3adbf167320e08195e5faceec2a40f363288f1284182d4a25317f1f354d8f6a
|
|
| MD5 |
fb79ec7cc6717dc1e62449c0e3f0bef1
|
|
| BLAKE2b-256 |
0f1886b9837982392811a35b95c9948a0f4a4240748018b3453eeda49b4ad7de
|
File details
Details for the file fragment_explorer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fragment_explorer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dca2fddbbd83866761c700d5dfd6c7a5dc840608a3d9284daca6499550e2cac3
|
|
| MD5 |
80dd5905dc22ff612fff337530944e98
|
|
| BLAKE2b-256 |
19fcc735095a5a63727aa18a4a507eaa5b6bb111fc50476f5644537763081fee
|