a python wrapper to interact with the semiempirical quantum chemistry program MOPAC
Project description
pyMOPAC
initial test build with basic functionality
wraps MOPAC to conveniently interact with the program from within python scripts
Dependencies
- MOPAC in $PATH (some search is done for slightly different names, but older versions might not parse)
recommended install via conda install mopac
Optional (skip via pip --no-dependencies, supports Input from pure XYZ data and runs without plotting)
-
rdkit
-
numpy
-
matplotlib
Installation
- via pip
pip install pymopac
- directly from github (nightly)
git clone Acetylsalicylsaeure/pymopac
cd pymopac
pip install .
Usage
At the core, this module implements two classes, MopacInput and MopacOutput. These represent the MOPAC .mop input and .out output files, respectively. MopacInput takes a molecular geometry in various supported formats like SMILES or rdkit Mol. Furthermore, various keywords are accepted that define the MOPAC Header. The input file can be sent to MOPAC via the .run() method, which returns a MopacOutput object.
This Object Class parses the .out file and aims to dynamically extract calculation results.
Minimal working example:
import pymopac
infile = pymopac.MopacInput("CC")
outfile = infile.run()
print(outfile.result)
Getting calculated properties
import pymopac
outfile = pymopac.MopacInput("c1ccccc1").run()
print(outfile.keys())
print(outfile["IONIZATION_POTENTIAL"])
working with Mol objects
The module internally represents the molecule via rdkit Mol objects. They can serve both as inputs and can be accessed as outputs after having their geometry optimized with MOPAC
from rdkit import Chem
from rdkit.Chem import AllChem
import pymopac
mmff_mol = Chem.MolFromSmiles("c1ccc1")
mmff_mol = AllChem.AddHs(mmff_mol)
AllChem.EmbedMolecule(mmff_mol)
AllChem.MMFFOptimizeMolecule(mmff_mol)
outfile = pymopac.MopacInput(mmff_mol).run()
mopac_mol = outfile.toMol()
print(AllChem.GetBestRMS(mmff_mol, mopac_mol))
Run feedback
3 different keywords are implemented, which offer feedback to a MOPAC run
-
verbose=Trueprints internal messages from the python module to stdout -
stream=Truestreams the MOPAC .out file to stdout -
plot=Trueuses matplotlib to plot the progress in gradient and heat of formation
Parsers
Custom parsers can be written, inherinting from input.BaseParser. Every Output class has a list at self.parser which, custom parsers can simply be added. If a parser has been added after Output initialization, parsing can be redone using Output.parseAll()
By convention, custom parsers are able to set attributes on the Ouput class by having the Output passed as an argument at parse time.
AUX Parser
A parser working on the MOPAC AUX file is called when a .aux file is passed, as is standard when creating the output via the MopacInput.run() method. Using this, all properties can be parsed in an unsupervised manner. Results of this can be found under Output.auxDict.
API
Starting with MOPAC v23, there exist API headers which are now also wrapped in pyMOPAC. Significant speedups can be observed for small molecules, as the computation takes place in memory and writes to disk can be avoided.
Tests
done for Ubuntu 24 LTS and Fedora 40,
Python 3.9-12
Roadmap
- add parsing for further keywords
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymopac-1.1.tar.gz.
File metadata
- Download URL: pymopac-1.1.tar.gz
- Upload date:
- Size: 113.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6530a6b35d3964b9db639b1997302e485c1a72e63e0fc5b25edaa9d057170eb3
|
|
| MD5 |
0a5d5aef0edfc120d724c125a5ef752a
|
|
| BLAKE2b-256 |
bf1843bc03a7491903e62fbb483ae623c0b7d5a1c5b42085d4e8e5ba1654fe99
|
Provenance
The following attestation bundles were made for pymopac-1.1.tar.gz:
Publisher:
python-publish.yml on Acetylsalicylsaeure/pymopac
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymopac-1.1.tar.gz -
Subject digest:
6530a6b35d3964b9db639b1997302e485c1a72e63e0fc5b25edaa9d057170eb3 - Sigstore transparency entry: 169885870
- Sigstore integration time:
-
Permalink:
Acetylsalicylsaeure/pymopac@3b6abc01f52e05c7c2bbd4fc9b5a426014983f49 -
Branch / Tag:
refs/tags/v1.1 - Owner: https://github.com/Acetylsalicylsaeure
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3b6abc01f52e05c7c2bbd4fc9b5a426014983f49 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pymopac-1.1-py3-none-any.whl.
File metadata
- Download URL: pymopac-1.1-py3-none-any.whl
- Upload date:
- Size: 41.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60d38541829946f8633e6842c8203f23ce616fae26394a3e8b76ec5294db6b45
|
|
| MD5 |
a7f8ccff6a35cf1ca1e27e7cdd5b05a2
|
|
| BLAKE2b-256 |
962eee093c460ea69a73d1423f98725d1a4d3bf5e97521b621b574daa29b798f
|
Provenance
The following attestation bundles were made for pymopac-1.1-py3-none-any.whl:
Publisher:
python-publish.yml on Acetylsalicylsaeure/pymopac
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymopac-1.1-py3-none-any.whl -
Subject digest:
60d38541829946f8633e6842c8203f23ce616fae26394a3e8b76ec5294db6b45 - Sigstore transparency entry: 169885871
- Sigstore integration time:
-
Permalink:
Acetylsalicylsaeure/pymopac@3b6abc01f52e05c7c2bbd4fc9b5a426014983f49 -
Branch / Tag:
refs/tags/v1.1 - Owner: https://github.com/Acetylsalicylsaeure
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3b6abc01f52e05c7c2bbd4fc9b5a426014983f49 -
Trigger Event:
release
-
Statement type: