torchref.restraints.library module
Monomer Library Manager for TorchRef.
Manages access to the CCP4 Monomer Library restraint dictionaries with a priority-based resolution strategy. Standard amino acids and nucleotides are bundled as package data; non-standard residues are downloaded on demand from the MonomerLibrary GitHub repository and cached locally.
The monomer library provides ideal geometry parameters (bond lengths, angles, torsions, planes, chirals) derived from the Cambridge Structural Database.
References
- Long, F., et al. (2017). AceDRG: a stereochemical description generator
for ligands. Acta Cryst. D73, 112-122.
- class torchref.restraints.library.MonomerLibraryManager(verbose=1)[source]
Bases:
objectManages access to the CCP4 Monomer Library with priority-based resolution.
Resolution priority for individual CIF files: 1.
TORCHREF_MONOMER_LIBenvironment variable (local library install) 2. Bundled package data (standard amino acids, nucleotides) 3. User cache (~/.cache/torchref/monomer_library/) 4. Legacyexternal_monomer_library/directory 5. On-demand download from GitHub (cached for future use)- Parameters:
verbose (int, optional) – Verbosity level. 0 = silent, 1 = warnings, 2 = info. Default 1.
- get_cif_file(resname)[source]
Resolve the CIF file path for a given residue name.
- Parameters:
resname (str) – Residue name (e.g., ‘ALA’, ‘GLY’, ‘ATP’).
- Returns:
Path to the CIF file, or None if not found anywhere.
- Return type:
Path or None
- get_link_definitions_path()[source]
Resolve the path to mon_lib_list.cif (inter-residue link definitions).
- Returns:
Path to mon_lib_list.cif.
- Return type:
Path
- Raises:
FileNotFoundError – If the file cannot be found or downloaded.
- property monomer_dir
Return a directory path suitable for monomer library access.
Prefers environment variable, then bundled data, then legacy path. This is provided for backward compatibility with code that expects a directory path rather than individual file resolution.
- Returns:
Path to the monomer library root directory.
- Return type:
Path