Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [unreleased]

### Fixed
- Deleted ORCA `parse_natoms` to fix parsing of xTB log files.
- Fixed gradient regex to account for arbitrary number of stars in log file.


## [0.10.1] - 2026-05-02

### Fixed
Expand Down
26 changes: 7 additions & 19 deletions src/qccodec/parsers/orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def parse_hessian(contents: str) -> list[list[float]]:
for block in blocks:
lines = block.splitlines()
if not len(lines) == dim:
raise ParserError(f"Block line count {len(lines)} does not match dimension {dim}: {block}")
raise ParserError(
f"Block line count {len(lines)} does not match dimension {dim}: {block}"
)

for i, line in enumerate(block.splitlines()):
row = list(map(float, line.split()[1:]))
Expand Down Expand Up @@ -194,9 +196,10 @@ def parse_trajectory(

# Capture the stdout for each gradient calculation
regex = (
r"GEOMETRY\s*OPTIMIZATION\s*CYCLE\s*\d+\s*\*\s*\n\s*\**\s*\n" # header
r"(.*?)" # body
r"-*\s*\n\s*ORCA\s+GEOMETRY\s+RELAXATION\s+STEP"
r"GEOMETRY\s*OPTIMIZATION\s*CYCLE\s*\d+.*?" # Match cycle line
r"\*+\n" # Match the line of stars
r"(.*?)" # Body (Captured)
r"-+\s*\n\s*ORCA\s+GEOMETRY\s+RELAXATION\s+STEP" # Footer
)
per_gradient_stdout = re.findall(regex, stdout, flags=re.DOTALL)
if not per_gradient_stdout:
Expand Down Expand Up @@ -249,21 +252,6 @@ def parse_version(contents: str) -> str:
return match.group(1)


@register(filetype=OrcaFileType.STDOUT, target="calcinfo_natoms")
def parse_natoms(contents: str) -> int:
"""Parse number of atoms value from Orca stdout.

Returns:
The number of atoms as an integer.

Raises:
MatchNotFoundError: If the regex does not match.
"""
regex = r"Number of atoms\s*...\s*(\d+)"
match = re_search(regex, contents)
return int(match.group(1))


def parse_basename(contents: str) -> str:
"""Parse the file basename from Orca stdout."""
regex = r"NAME\s+=\s+(.*)"
Expand Down
Loading