xnn.ffnn.common.frc.FrcFile#

class xnn.ffnn.common.frc.FrcFile(path, include_dirs=())[source]#

Bases: object

A parsed .frc file (plus everything it #includes).

Parameters:
  • path (str or Path) – The file to read.

  • include_dirs (sequence of str or Path, optional) – Directories searched for #include local:... targets (after the including file’s directory); the xnn data directory is always searched last.

Variables:
  • path (Path) – The top-level file.

  • header (str) – The first line, verbatim.

  • header_dialect (str) – The word after ! in the header ("MolSSI", or "BIOSYM" for legacy files).

  • format_version (int or None) – The format version declared by the header (the trailing number, 1 for every current file); None if the header carries no number.

  • sections (dict) – (kind, label) -> Section for every parameter section read.

  • defines (dict) – name -> Define.

  • references (dict) – (source, number) -> Reference.

  • files (list of Path) – Every file read, in order.

  • missing_includes (list of str) – missing_ok includes that were not found.

classmethod empty(header='!MolSSI forcefield 1')[source]#

A blank in-memory file to fill with sections and defines.

Parameters:

header (str)

Return type:

FrcFile

property forcefields: list[str]#

Names of the variants this file defines, in file order.

forcefield(name=None, version=None)[source]#

Resolve a #define into a ForceField.

Parameters:
  • name (str, optional) – The variant to build; default: the only one, or the one named like the file, or the first.

  • version (str, optional) – Build the force field as of this version (rows newer than it are ignored); default the newest.

Returns:

The merged, ready-to-query force field.

Return type:

ForceField

Raises:

KeyError – If name is not defined in the file.

write(path)[source]#

Write the file in .frc syntax (see write_frc()).

Parameters:

path (str | Path)

Return type:

Path