agentsclimarketplace

Molecular graph representation encoding

Skill HolobiomicsLab/asb-skill-collections/packs/metabolomics/lc-ms/skills/molecular-graph-representation-encoding

Use when when you have a collection of molecular structures (as InChI strings, SMILES, or RDKit Mol objects) and need to feed them into a pretrained or transfer-learning neural network that expects both molecular graph topology and structural fingerprints as inputs.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill molecular-graph-representation-encoding

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

8.7 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it

molecular-graph-representation-encoding

Summary

Encodes molecular structures as graph representations and fingerprints for input to neural network models predicting molecular properties (e.g., retention time). This skill transforms unstructured chemical data (InChI, SMILES, or molecular objects) into tensor-compatible graph and fingerprint features suitable for graph convolution and transformer architectures.

When to use

When you have a collection of molecular structures (as InChI strings, SMILES, or RDKit Mol objects) and need to feed them into a pretrained or transfer-learning neural network that expects both molecular graph topology and structural fingerprints as inputs. Specifically apply this skill when preparing data for retention time prediction models like RT-Transformer or when adapting a pretrained model to a new chromatographic dataset.

When NOT to use

  • Input molecules are already pre-encoded as fixed-size numerical feature tables or pre-computed embeddings; re-encoding is redundant.
  • The neural network architecture does not use graph convolutions or fingerprint features (e.g., it expects raw SMILES strings to be processed by an embedded tokenizer).
  • Molecular structures are missing or malformed (invalid InChI/SMILES); encoding will fail or produce null tensors.

Inputs

  • CSV file with 'InChI' and/or 'SMILES' columns and experimental property values (e.g., 'RT' for retention time)
  • RDKit Mol objects or canonical SMILES strings
  • Molecular structure dataset (SMRT, PredRet, or user-provided in CSV format with 'InChI' and 'RT' columns)

Outputs

  • PyTorch tensors (node features, edge indices, edge attributes) compatible with torch_geometric
  • Batched DataLoader objects for mini-batch training/inference
  • Graph representation objects (torch_geometric Data objects) with fingerprint and graph features

How to apply

Load molecular structures from your dataset (e.g., CSV with 'InChI' or 'SMILES' columns) using RDKit. For each molecule, generate two complementary representations: (1) molecular fingerprints using rdkit-pypi's fingerprint functions (e.g., Morgan fingerprints), and (2) a graph representation capturing atomic connectivity using RDKit's molecular graph API. Convert both representations to PyTorch tensors; use torch_geometric to construct graph objects with node features (atomic properties), edge indices (bonds), and edge attributes. Batch these tensors using torch_geometric's DataLoader for efficient mini-batch training. The rationale is that fingerprints capture global structural patterns while graphs preserve local connectivity, enabling the model to learn both low-level chemical patterns and multi-scale structural relationships relevant to chromatographic behavior.

Related tools

  • rdkit-pypi (Generate molecular fingerprints and RDKit Mol objects; parse InChI/SMILES strings into structured molecular graphs) — https://rdkit.org/
  • torch_geometric (Construct graph tensor representations (node features, edge indices) and batch them for neural network input) — https://pytorch-geometric.readthedocs.io/
  • torch-scatter, torch-sparse, torch-cluster (Backend operations for efficient graph convolution and aggregation in torch_geometric) — https://pytorch-geometric.readthedocs.io/
  • torch (Framework for tensor creation, batching, and neural network training/inference) — https://pytorch.org/
  • pandas (Load and manage tabular datasets (CSV) containing InChI/SMILES and experimental property labels)

Examples

from rdkit import Chem; from torch_geometric.data import DataLoader; molecules = [Chem.MolFromInChI(inchi) for inchi in df['InChI']]; fingerprints = [AllChem.GetMorganFingerprintAsBitVect(mol, 2, nBits=2048) for mol in molecules]; graphs = [mol_to_graph(mol) for mol in molecules]; loader = DataLoader([concatenate_features(fp, g) for fp, g in zip(fingerprints, graphs)], batch_size=32)

Evaluation signals

  • Verify all molecules in the dataset successfully parse to valid RDKit Mol objects; check for parse errors or null objects using RDKit's validity checks.
  • Confirm fingerprint tensors have consistent dimensionality (e.g., 2048-dim Morgan fingerprints) and numeric range [0, 1] or [0, N] depending on fingerprint type.
  • Validate graph tensors: node feature tensors have shape [num_atoms, feature_dim], edge indices have shape [2, num_bonds] with valid atomic indices, and edge attributes (if present) match bond count.
  • Check DataLoader batches: verify batch sizes match specified batch_size parameter and that graphs are correctly stacked without index collisions across batch elements.
  • Confirm output tensors match the input layer dimensionality of the downstream neural network model (e.g., concatenated fingerprint + graph feature size matches the RT-Transformer encoder input).

Limitations

  • Fingerprint methods are lossy; isomeric discrimination depends on fingerprint type and radius. Different fingerprint types (Morgan, RDKit, MACCS) may capture different structural patterns; choice affects model performance.
  • Graph representation depends on valid 2D/3D structure; molecules with ambiguous or missing connectivity may fail to parse or produce incorrect graphs.
  • Different chromatographic methods may exhibit vastly different retention time distributions for the same molecule; graph encoding alone cannot capture method-specific effects; transfer learning requires adaptation of the prediction head or fine-tuning.
  • Large molecular graphs (>100 atoms) may exceed GPU memory during batching; padding or graph pooling strategies may be necessary for scalability.
  • Fingerprint generation and graph construction are computationally expensive for large datasets; preprocessing and caching of encoded tensors is recommended to avoid redundant computation.

Evidence

  • [other] generate molecular fingerprints or graph representations using rdkit-pypi and convert to PyTorch tensors with torch_geometric for graph convolution layers: "generate molecular fingerprints or graph representations using rdkit-pypi and convert to PyTorch tensors with torch_geometric for graph convolution layers"
  • [readme] The RT-Tranformer combine the fingerprint and the molecular graph data and predict retention time as the output: "The RT-Tranformer combine the fingerprint and the molecular graph data and predict retention time as the output"
  • [readme] Prepare your dataset as a csv file which has 'InChI' and 'RT' columns: "Prepare your dataset as a csv file which has 'InChI' and 'RT' columns"
  • [other] Load the SMRT-pretrained RT-Transformer model checkpoint and the PredRet dataset containing molecular structures and retention time annotations: "Load the SMRT-pretrained RT-Transformer model checkpoint and the PredRet dataset containing molecular structures and retention time annotations"
  • [intro] Liquid chromatography retention times prediction can assist in metabolite identification, which is a critical task and challenge in non-targeted metabolomics: "Liquid chromatography retention times prediction can assist in metabolite identification, which is a critical task and challenge in non-targeted metabolomics"

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.