Chemical Component Dictionary metadata helpers.
- class neurosnap.database.ccd.CCD(code, name, smiles, type)[source]#
Bases:
objectMinimal Chemical Component Dictionary entry.
- Variables:
code – CCD identifier, typically 1-5 characters.
name – Human-readable component name.
smiles – SMILES string for the component (technically canonicalized but the canonicalization algorithm used by wwPDB is inconsistent with that of RDkit).
type – CCD component type.
-
code:
str#
-
name:
str#
-
smiles:
str#
- smiles_canonical()[source]#
Return the RDKit-canonicalized SMILES string for this CCD entry.
- Return type:
str
- to_mol()[source]#
Return an RDKit molecule parsed from the canonical SMILES string.
- Return type:
Mol- Returns:
RDKit molecule for the CCD entry.
- Raises:
ValueError – If the stored canonical SMILES cannot be parsed.
-
type:
str#
- neurosnap.database.ccd.get_ccd(code, *, cache_path='~/.cache/neurosnap/ccd_entries.json', overwrite=False, max_age_days=7, timeout=30)[source]#
Return a CCD entry by its component code.
- Return type:
Optional[CCD]
- neurosnap.database.ccd.get_ccd_canonical_aa(ccd, *, standard=True, cache_path='~/.cache/neurosnap/ccd_entries.json', overwrite=False, max_age_days=7, timeout=30)[source]#
Return the most similar canonical or standard amino acid for a CCD entry.
If the input CCD code already has an explicit amino-acid mapping in the amino-acid residue tables, that mapping is reused directly. Otherwise, the CCD entry is compared against canonical amino-acid CCD entries using RDKit Morgan fingerprints and the highest-similarity amino acid is returned. Selenium-containing residues are also compared after conservative selenium-to-sulfur normalization so common analogs such as MSE can map to their sulfur parent without being hard-coded into the amino-acid constants.
- Parameters:
standard (
bool) – IfTrue(default), collapse results to the 20 standard amino acids. IfFalse, allow all canonical residues, includingSECandPYL.cache_path (
str) – Local cache file path for the CCD JSON payload.overwrite (
bool) – IfTrue, force a fresh CCD payload download.max_age_days (
int) – Maximum accepted payload age in days.timeout (
int) – HTTP timeout in seconds for CCD payload downloads.
- Return type:
- Returns:
The best-matching amino-acid record under the requested mode.
- Raises:
TypeError – If
ccdis not a string orCCD.ValueError – If the CCD code is unknown or its SMILES cannot be parsed.
- neurosnap.database.ccd.get_ccd_entries(*, cache_path='~/.cache/neurosnap/ccd_entries.json', overwrite=False, max_age_days=7, timeout=30)[source]#
Fetch and cache CCD metadata entries.
The CCD payload is cached locally and refreshed when the cached payload exceeds
max_age_daysbased on its embeddedcreated_attimestamp.- Parameters:
cache_path (
str) – Local cache file path for the raw JSON payload.overwrite (
bool) – IfTrue, force a fresh download.max_age_days (
int) – Maximum accepted payload age in days.timeout (
int) – HTTP timeout in seconds for the download request.
- Return type:
Dict[str,CCD]- Returns:
Dictionary mapping CCD code to
CCD.