mirror of
https://github.com/QuantumPackage/qp2.git
synced 2025-04-25 17:54:44 +02:00
79 lines
1.9 KiB
Python
Executable File
79 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
convert output of GAMESS/GAU$$IAN to ezfio
|
|
|
|
Usage:
|
|
qp_convert_output_to_ezfio [-o EZFIO_DIR] FILE
|
|
|
|
Options:
|
|
-o --output=EZFIO_DIR Produced directory
|
|
by default is FILE.ezfio
|
|
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
import tempfile
|
|
from docopt import docopt
|
|
|
|
try:
|
|
QP_ROOT = os.environ["QP_ROOT"]
|
|
QP_EZFIO = os.environ["QP_EZFIO"]
|
|
except KeyError:
|
|
print("Error: QP_ROOT environment variable not found.")
|
|
sys.exit(1)
|
|
else:
|
|
sys.path = [QP_EZFIO + "/Python",
|
|
QP_ROOT + "/install/resultsFile",
|
|
QP_ROOT + "/install",
|
|
QP_ROOT + "/scripts"] + sys.path
|
|
|
|
from ezfio import ezfio
|
|
from qp_import_trexio import write_ezfio
|
|
|
|
try:
|
|
from trexio_tools import trexio_run
|
|
except:
|
|
print("Error: trexio-tools python package is not installed.")
|
|
print("Use pip install trexio-tools to install it.")
|
|
sys.exit(1)
|
|
|
|
|
|
def get_full_path(file_path):
|
|
file_path = os.path.expanduser(file_path)
|
|
file_path = os.path.expandvars(file_path)
|
|
return file_path
|
|
|
|
class NoneDict(dict):
|
|
def __missing__(self, key):
|
|
return None
|
|
|
|
def main(FILE,EZFIO_FILE):
|
|
with tempfile.NamedTemporaryFile(mode='w+b', delete=True, errors=None) as f:
|
|
trexio_file = f.name
|
|
|
|
args = NoneDict()
|
|
args["convert-from"] = True
|
|
args["--input"] = FILE
|
|
args["--back_end"] = "hdf5"
|
|
args["--type"] = "gaussian"
|
|
args["TREXIO_FILE"] = trexio_file
|
|
|
|
trexio_run.main(filename=trexio_file, args=args)
|
|
write_ezfio(trexio_file, EZFIO_FILE)
|
|
trexio_run.remove_trexio_file(trexio_file, overwrite=True)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
ARGUMENTS = docopt(__doc__)
|
|
|
|
FILE = get_full_path(ARGUMENTS['FILE'])
|
|
|
|
if ARGUMENTS["--output"]:
|
|
EZFIO_FILE = get_full_path(ARGUMENTS["--output"])
|
|
else:
|
|
EZFIO_FILE = "{0}.ezfio".format(FILE)
|
|
|
|
main (FILE,EZFIO_FILE)
|
|
|