Convert and export¶
Render selected frames as text or write batches as structure files and next-step calculation inputs.
Preview without writing¶
from molop import AutoParser
batch = AutoParser("water_mp2.out", n_jobs=1)
rendered = batch.format_transform("xyz", frame=-1, write_to_disk=False)
print(rendered[batch[0].file_path])
Output
The result is {absolute source path: rendered value}. write_to_disk=False creates no file.
Write a batch¶
from pathlib import Path
Path("structures").mkdir(exist_ok=True)
batch.format_transform(
"xyz",
output_dir="structures",
frame=-1,
write_to_disk=True,
)
output_dir must already exist. Output names preserve the source stem and replace the final suffix.
Select frames¶
final_only = batch.format_transform("xyz", frame=-1)
all_in_one = batch.format_transform("xyz", frame="all", embed_in_one_file=True)
one_per_frame = batch.format_transform("xyz", frame="all", embed_in_one_file=False)
print(len(final_only), len(all_in_one), len(one_per_frame))
embed_in_one_file=False returns a list of strings. When writing, the writer produces multiple
frame-specific files.
Available targets¶
| Format ID | Typical use | Main information level |
|---|---|---|
xyz |
Coordinates and visualization | Elements, coordinates, charge/multiplicity comment |
sdf |
Molecular graph and property exchange | Atoms, bonds, coordinates |
smi |
SMILES datasets | Molecular graph, no 3D coordinates |
gjf |
Next Gaussian input | Coordinates, charge/multiplicity, route/link0 |
orcainp |
Next ORCA input | Coordinates, keywords, resources, %block data |
cml |
XML chemical structure exchange | Molecular graph and coordinates |
fakeg |
Gaussian-like text | Compatibility display, not an original Gaussian output |
See the format overview for exact reader and writer status.
Generate next-step inputs¶
from pathlib import Path
Path("gaussian_inputs").mkdir(exist_ok=True)
batch.format_transform(
"gjf",
output_dir="gaussian_inputs",
write_to_disk=True,
route_section="#p B3LYP/6-31G(d) opt",
link0_commands={"nprocshared": "8"},
)
Path("orca_inputs").mkdir(exist_ok=True)
batch.format_transform(
"orcainp",
output_dir="orca_inputs",
write_to_disk=True,
keywords="B3LYP def2-SVP Opt",
maxcore=2000,
)
print("gaussian_inputs/water_mp2.gjf")
print("orca_inputs/water_mp2.inp")
Writer-specific options vary by format. Use CLI completion or the individual format page.
CLI¶
mkdir -p structures
molop -q parse "results/*.out" \
format-transform --format xyz --output-dir structures --frame -1
Information boundary¶
XYZ and SMILES cannot carry full energy, thermochemistry, vibration, or NMR containers. SDF can
embed selected atom-level QM properties, but ordinary format_transform("sdf") is not a lossless
serialization of every calculation result. Use model serialization for complete data exchange.