chemparseplot.parse.grammar.xyz#
XYZ grammar (parsimonious) for multi-atom frames.
Port of the wailord paper thesis: structured grammar parsing for XYZ rather than ad-hoc line splits. Multi-character element symbols and scientific floats are supported.
Added in version 1.9.9.
Module Contents#
Classes#
Functions#
Compiled XYZ grammar (cached). |
|
Parse a single-frame XYZ string with the grammar visitor. |
|
Read and parse an XYZ file. |
|
Serialize a frame back to XYZ text (Å). |
Data#
API#
- chemparseplot.parse.grammar.xyz._XYZ_GRAMMAR_SRC = <Multiline-String>#
- class chemparseplot.parse.grammar.xyz.XyzAtom[source]#
One atom line: element symbol and Cartesian coordinates (Å).
- class chemparseplot.parse.grammar.xyz.XyzFrame[source]#
Parsed single-frame XYZ.
- atoms: tuple[chemparseplot.parse.grammar.xyz.XyzAtom, ...]#
None
- property counts: collections.Counter#
- chemparseplot.parse.grammar.xyz.parse_xyz_text(text: str) chemparseplot.parse.grammar.xyz.XyzFrame[source]#
Parse a single-frame XYZ string with the grammar visitor.
Parameters
text: Full XYZ content including atom count and comment line.
Returns
XyzFrame Structured frame (natoms, comment, atoms).
- chemparseplot.parse.grammar.xyz.parse_xyz_file(path: str | pathlib.Path) chemparseplot.parse.grammar.xyz.XyzFrame[source]#
Read and parse an XYZ file.