Skip to content

5-minute start

Use a downloadable ORCA output to parse a file, read its final structure and energy, build a summary, and export XYZ.

Prepare

  1. Install MolOP using the installation guide.
  2. Download water_mp2.out into an empty directory.
  3. Start Python in that directory.

The example comes from cclib’s ORCA regression data. See the example data notes for its source and license. This tutorial parses an existing output; it does not run ORCA.

Parse and read results

Python
from molop import AutoParser

batch = AutoParser("water_mp2.out", n_jobs=1)
parsed_file = batch[0]
frame = parsed_file[-1]

print(parsed_file.detected_format_id)
print(len(frame.atoms), frame.coords.shape)
print(frame.energies.total_energy.m_as("hartree"))
Output
Text Only
orcaout
3 (3, 3)
-74.999374598107

AutoParser always returns a batch. The access sequence here is:

Text Only
batch -> first input file -> final frame
          batch[0]           [-1]

Build a full summary

Python
summary = batch.to_summary_df(
    frame=-1,
    brief=False,
    flatten_columns=True,
)
summary.to_csv("summary.csv", index=False)
print(summary.shape)
Complete table result
Text Only
(1, 23)

Notebook 02 renders all 23 columns as the complete HTML DataFrame generated by this call. It does not create a temporary column subset.

summary.csv contains one final-frame row. Use brief=False to include extended energy, thermochemistry, and vibration columns. DiskStorage.FilePath contains an absolute path whose value depends on the directory from which the example is run.

Export the final structure

Python
rendered = batch.format_transform("xyz", frame=-1, write_to_disk=False)
print(rendered[parsed_file.file_path])

batch.format_transform(
    "xyz",
    output_dir=".",
    frame=-1,
    write_to_disk=True,
)

The first call prints:

Output
Text Only
3
comment charge 0 multiplicity 1
O               1.7849140000      1.2624220000      0.5119850000
H               2.6482370000      1.0729290000      0.1316310000
H               1.1831680000      1.2568160000     -0.2388350000

The first call returns XYZ text. The second writes water_mp2.xyz in the current directory.

Use your own files

Only the path changes:

Python
gaussian = AutoParser("calculation.log")
orca = AutoParser("job.out")
xtb = AutoParser("xtb.out")
many_files = AutoParser("results/*.log")

When an extension is ambiguous, specify the format explicitly:

Python
batch = AutoParser("calculation.out", parser_detection="orcaout")

Next steps