Skip to content

Data

The data module manages force field data and resources.

Forcefield

Force field data files.

This submodule provides convenient access to force field data files.

get_forcefield_path

get_forcefield_path(filename)

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
str

Path string to the force field file

Raises:

Type Description
FileNotFoundError

If the file does not exist

Examples:

>>> from molpy.data.forcefield import get_forcefield_path
>>> path = get_forcefield_path("oplsaa.xml")
Source code in src/molpy/data/forcefield/__init__.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def get_forcefield_path(filename: str) -> str:
    """
    Get the path to a force field file.

    Args:
        filename: Name of the force field file (e.g., "oplsaa.xml")

    Returns:
        Path string to the force field file

    Raises:
        FileNotFoundError: If the file does not exist

    Examples:
        >>> from molpy.data.forcefield import get_forcefield_path
        >>> path = get_forcefield_path("oplsaa.xml")
    """
    from pathlib import Path

    return str(get_path(f"forcefield/{filename}"))

list_forcefields

list_forcefields()

List all available force field files.

Returns:

Type Description
list[str]

List of force field filenames

Examples:

>>> from molpy.data.forcefield import list_forcefields
>>> forcefields = list_forcefields()
>>> print(forcefields)
['oplsaa.xml', 'tip3p.xml']
Source code in src/molpy/data/forcefield/__init__.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def list_forcefields() -> list[str]:
    """
    List all available force field files.

    Returns:
        List of force field filenames

    Examples:
        >>> from molpy.data.forcefield import list_forcefields
        >>> forcefields = list_forcefields()
        >>> print(forcefields)
        ['oplsaa.xml', 'tip3p.xml']
    """
    from pathlib import Path

    return [Path(f).name for f in list_files("forcefield", exclude_python=True)]