Coverage for cosmolayer/parser/turbomole.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-26 00:09 +0000

1import re 

2 

3from .common import ( # noqa: F401 

4 ATOM_INFO_SCHEMA, 

5 ATOM_POSITION_CONVERSION_FACTOR, 

6 ATOM_ROW_REGEX, 

7 SEGMENT_INFO_SCHEMA, 

8 SEGMENT_POSITION_CONVERSION_FACTOR, 

9 SEGMENT_ROW_REGEX, 

10 VOLUME_CONVERSION_FACTOR, 

11) 

12 

13FORMAT_NAME = "TURBOMOLE" 

14 

15SEGMENT_SECTION_REGEX = re.compile( 

16 rf"^\$segment_information\b.*?\n((?:{SEGMENT_ROW_REGEX.pattern}(?:\n|$))+)", 

17 re.MULTILINE | re.DOTALL, 

18) 

19 

20ATOM_SECTION_REGEX = re.compile( 

21 rf"\$coord_car\b.*?\n((?:{ATOM_ROW_REGEX.pattern}(?:\n|$))+)", 

22 re.MULTILINE | re.DOTALL, 

23) 

24 

25VOLUME_REGEX = re.compile(r"volume=\s+(\d+(?:\.\d+)?)") 

26 

27 

28def is_turbomole_format(contents: str) -> bool: 

29 """Check if the contents are a Turbomole COSMO file. 

30 

31 Parameters 

32 ---------- 

33 contents : str 

34 Contents of a COSMO file. 

35 

36 Returns 

37 ------- 

38 bool 

39 True if the contents are a Turbomole COSMO file, False otherwise. 

40 """ 

41 return "$segment_information" in contents and "$coord_car" in contents