Getting Started¶
This guide covers installation and three ways to compute distances between molecular datasets.
Installation¶
Prerequisites¶
- Python 3.10 or higher
Install from PyPI (recommended)¶
Install only the extras you need:
pip install "themap[ml]" # molecular analysis
pip install "themap[protein]" # protein analysis (ESM2)
pip install "themap[otdd]" # OTDD distance computation
Install from source (development)¶
git clone https://github.com/HFooladi/THEMAP.git
cd THEMAP
source install.sh # creates .venv with uv, installs dev + test extras
To reactivate the environment later:
The editable equivalent of the extras above is pip install -e ".[all]" (or ".[ml]", ".[dev,test]", etc.).
Verify Installation¶
Quick Start¶
Option 1: Command Line¶
The fastest way to compute distances:
This computes Euclidean distances between all train and test datasets using ECFP fingerprints and saves results to output/molecule_distances.csv.
Option 2: Python One-Liner¶
from themap import quick_distance
results = quick_distance(
data_dir="datasets",
output_dir="output",
molecule_featurizer="ecfp",
molecule_method="euclidean",
)
Option 3: Config File¶
For reproducible experiments, use a YAML configuration:
Or from Python:
Example config.yaml:
data:
directory: "datasets"
molecule:
enabled: true
featurizer: "ecfp"
method: "euclidean"
output:
directory: "output"
format: "csv"
Understanding Results¶
The output is a CSV distance matrix with source tasks as rows and target tasks as columns:
import pandas as pd
distances = pd.read_csv("output/molecule_distances.csv", index_col=0)
# Find closest source for each target
for target in distances.columns:
closest = distances[target].idxmin()
dist = distances[target].min()
print(f"{target} <- {closest} (distance: {dist:.4f})")
Lower distance values indicate more similar datasets (easier transfer learning).
Data Format¶
Organize your data in this structure:
datasets/
├── train/
│ ├── CHEMBL123456.jsonl.gz
│ └── ...
└── test/
├── CHEMBL111111.jsonl.gz
└── ...
Each .jsonl.gz file contains molecules in JSON lines format:
Tip
Use themap convert to convert CSV files to the required JSONL.GZ format:
Next Steps¶
- Distance Computation Guide - detailed explanation of all distance methods
- Tutorials - step-by-step walkthroughs
- CLI Reference - all command-line options