Skip to main content

A package for parsing TeraChem file outputs into structured MolSSI data objects.

Project description

qcparse

A library for parsing Quantum Chemistry output files into structured data objects. Uses data structures from qcio.

image image image Actions status Actions status Ruff

☝️ NOTE

This package was originally designed to run as a standalone parser to generate SinglePointSuccessfulOutput and SinglePointFailedOutput objects parsing all input and provenance data in addition to computed output data; however, once qcop was built to power quantum chemistry programs the only parsing needed was for the simpler SinglePointComputedProperties values. There are still remnants of the original parse function in the repo and I've left them for now in case I find a use for the general purpose parsing.

✨ Basic Usage

  • Installation:

    python -m pip install qcparse
    
  • Parse a file into a SinglePointComputedProperties object with a single line of code.

    from qcparse import parse_computed_props
    
    computed = parse_computed_props("/path/to/tc.out", "terachem")
    
  • The computed object will be a SinglePointComputedProperties object. Run dir(computed) inside a Python interpreter to see the various values you can access. A few prominent values are shown here as an example:

    from qcparse import parse_computed_props
    
    computed = parse_computed_props("/path/to/tc.out", "terachem")
    
    computed.energy
    computed.gradient # If a gradient calc
    computed.hessian # If a hessian calc
    
    computed.calcinfo_nmo # Number of molecular orbitals
    
  • Parsed values can be written to disk like this:

    with open("computed.json", "w") as f:
        f.write(result.json())
    
  • And read from disk like this:

    from qcio import SinglePointComputedProperties as SPProps
    
    computed = SPProps.open("myresult.json")
    
  • You can also run qcparse from the command line like this:

    qcparse -h # Get help message for cli
    
    qcparse terachem ./path/to/tc.out > computed.json # Parse TeraChem stdout to json
    

🤩 Next Steps

This package is integrated into qcop. This means you can use qcop to power your QC programs using standard input data structures in pure Python and get back standardized Python output objects.

from qcop import compute
from qcio import Molecule, SinglePointInput

molecule = Molecule.open("mymolecule.xyz")
sp_input = SinglePointInput(
    molecule=molecule,
    program_args={
          "calc_type": "gradient", # "energy" | "gradient" | "hessian"
          "model": {"method": "b3lyp", "basis": "6-31gs"},
          "keywords": {"restricted": True, "purify": "no"} # Keywords are optional
    })

# result will be SinglePointSuccessfulOutput or SinglePointFailedOutput
result = compute(sp_input, "terachem")

💻 Contributing

If there's data you'd like parsed fromI output files, please open an issue in this repo explaining the data items you'd like parsed and include an example output file containing the data, like this.

If you'd like to add a parser yourself see the docstring in qcparse.parsers for a primer and see the examples written in the module. Adding a parser for new data is quick and easy :)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qcparse-0.3.0.tar.gz (11.7 kB view hashes)

Uploaded Source

Built Distribution

qcparse-0.3.0-py3-none-any.whl (13.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page