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

9 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-11 14:25 +0000

1import re 

2 

3SEGMENT_ROW_REGEX = re.compile( 

4 r"^\s*\d+\s+(\d+)\s+" # n (not used), atom 

5 + r"\s+".join([r"([+-]?\d+(?:\.\d+)?)"] * 5) # x, y, z, charge, area 

6 + r"\s+" 

7 + r"\s+".join([r"[+-]?\d+(?:\.\d+)?"] * 2) # charge/area, potential (not used) 

8 + r".*?$", 

9 re.MULTILINE, 

10) 

11 

12ATOM_ROW_REGEX = re.compile( 

13 r"^([A-Za-z0-9*]+)\s+" # atom id (e.g., N1, C1, H1, C*, H*) 

14 + r"\s+".join([r"([+-]?\d+(?:\.\d+)?)"] * 3) # x, y, z coordinates 

15 + r"(?:\s+\S+){3}" 

16 + r"\s*([A-Z][a-z]?)" # element symbol 

17 + r"\s*(?:\S+)?", 

18 re.MULTILINE, 

19) 

20 

21SEGMENT_INFO_SCHEMA = { 

22 "atom": int, 

23 "x": float, 

24 "y": float, 

25 "z": float, 

26 "charge": float, 

27 "area": float, 

28} 

29 

30ATOM_INFO_SCHEMA = {"id": str, "x": float, "y": float, "z": float, "element": str} 

31 

32BOHR_TO_ANGSTROM = 0.52917721067 

33ATOM_POSITION_CONVERSION_FACTOR = 1.0 

34SEGMENT_POSITION_CONVERSION_FACTOR = BOHR_TO_ANGSTROM 

35VOLUME_CONVERSION_FACTOR = BOHR_TO_ANGSTROM**3