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

1"""DMol-3 COSMO file parser. 

2 

3This module provides functions to parse COSMO output files from DMol-3. 

4""" 

5 

6import re 

7 

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) 

15 

16FORMAT_NAME = "DMol-3" 

17 

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) 

24 

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) 

31 

32VOLUME_REGEX = re.compile(r"Total volume of cavity \(A\*\*3\)\s*=\s*(\d+(?:\.\d+)?)") 

33 

34ATOM_POSITION_CONVERSION_FACTOR = 1.0 

35VOLUME_CONVERSION_FACTOR = 1.0 

36 

37 

38def is_dmol3_format(contents: str) -> bool: 

39 """Check if the contents are a DMol-3 COSMO file. 

40 

41 Parameters 

42 ---------- 

43 contents : str 

44 Contents of a COSMO file. 

45 

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