Data¶
Locators for the data files bundled with MolPy — built-in force fields
(oplsaa.xml, clp.xml, tip3p.xml, alpha.ff, …) and other packaged
assets. These helpers return filesystem paths you can hand to a reader; they do
not parse anything themselves. Available via import molpy as mp
(mp.data.get_forcefield_path).
Quick reference¶
| Symbol | Summary | Preferred for |
|---|---|---|
get_forcefield_path(name) |
Path to a bundled force-field file | Loading a built-in force field |
list_forcefields() |
Names of the bundled force fields | Discovering what ships with MolPy |
get_path(name) |
Path to any bundled data file | Accessing a packaged asset |
list_files() |
Names of all bundled data files | Enumerating packaged assets |
exists(name) |
Whether a bundled file is present | Guarding optional assets |
Full API¶
data ¶
MolPy Data Module - Access to built-in data files.
This module provides a unified interface for accessing built-in data files such as force field parameters, molecule templates, and other resources.
Usage
from molpy.data import get_path, list_files from molpy.data.forcefield import get_forcefield_path
Get path to a data file¶
path = get_path("forcefield/oplsaa.xml")
List available files in a subdirectory¶
files = list_files("forcefield")
Get force field path (convenience function)¶
ff_path = get_forcefield_path("oplsaa.xml")
exists ¶
Check if a data file exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_path
|
str | Path
|
Relative path to the data file |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the file exists, False otherwise |
Examples:
get_forcefield_path ¶
Get the path to a force field file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Name of the force field file (e.g., "oplsaa.xml") |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path object pointing to the force field file |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist |
Examples:
get_path ¶
Get the absolute path to a data file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_path
|
str | Path
|
Relative path to the data file (e.g., "forcefield/oplsaa.xml") |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path object pointing to the data file |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist |
Examples:
list_files ¶
List all files in a data subdirectory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subdirectory
|
str | Path
|
Subdirectory to list (e.g., "forcefield"), empty string for root |
''
|
exclude_python
|
bool
|
If True, exclude Python files (init.py, *.py, etc.) |
True
|
Yields:
| Type | Description |
|---|---|
str
|
Relative paths to files in the subdirectory |
Examples: