Coverage for cosmolayer/parser/dmol3.py: 100%
10 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-26 00:09 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-26 00:09 +0000
1"""DMol-3 COSMO file parser.
3This module provides functions to parse COSMO output files from DMol-3.
4"""
6import re
8from .common import ( # noqa: F401
9 ATOM_INFO_SCHEMA,
10 ATOM_ROW_REGEX,
11 SEGMENT_INFO_SCHEMA,
12 SEGMENT_POSITION_CONVERSION_FACTOR,
13 SEGMENT_ROW_REGEX,
14)
16FORMAT_NAME = "DMol-3"
18SEGMENT_SECTION_REGEX = re.compile(
19 r"Segment information:.*?n\s+atom\s+position.*?potential\s*\n+((?:"
20 + SEGMENT_ROW_REGEX.pattern
21 + r"(?:\n|$))+)",
22 re.MULTILINE | re.DOTALL,
23)
25ATOM_SECTION_REGEX = re.compile(
26 r"Molecular car file\s*:.*?!DATE[^\n]*\n((?:"
27 + ATOM_ROW_REGEX.pattern
28 + r"(?:\n|$))+)",
29 re.MULTILINE | re.DOTALL,
30)
32VOLUME_REGEX = re.compile(r"Total volume of cavity \(A\*\*3\)\s*=\s*(\d+(?:\.\d+)?)")
34ATOM_POSITION_CONVERSION_FACTOR = 1.0
35VOLUME_CONVERSION_FACTOR = 1.0
38def is_dmol3_format(contents: str) -> bool:
39 """Check if the contents are a DMol-3 COSMO file.
41 Parameters
42 ----------
43 contents : str
44 Contents of a COSMO file.
46 Returns
47 -------
48 bool
49 True if the contents are a DMol-3 COSMO file, False otherwise.
50 s"""
51 return "DMol3/COSMO Results" in contents