Skip to content

Commit

Permalink
adding CLI for processed
Browse files Browse the repository at this point in the history
  • Loading branch information
ale94mleon committed Nov 6, 2023
1 parent a1b6c1e commit 8053af7
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ abfe = [
]

[project.scripts]
aleimi-run = "aleimi.cli:_aleimi"
aleimi-run = "aleimi.cli:_aleimi"
aleimi-processed="aleimi.cli:_aleimi_processed"
39 changes: 37 additions & 2 deletions src/aleimi/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from aleimi import confgen, boltzmann, extractor, __version__, utils
from aleimi import confgen, boltzmann, extractor, __version__, utils, processed
import argparse, os, yaml

"""
Expand All @@ -12,7 +12,7 @@
"""


def _aleimi():
def _aleimi_run():
"""CLI of ``aleimi``
"""
parser = argparse.ArgumentParser(description=__doc__,
Expand Down Expand Up @@ -85,5 +85,40 @@ def _aleimi():
extractor.main(f"{mol_name}.arc", f"{mol_name}_boltzmann.csv", **boltzmann_keywords)


def _aleimi_processed():
"""CLI of ``processed``
"""
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawTextHelpFormatter)


parser.add_argument('--no_sub_dirs',
help ='Should be True if :meth:`aleimi.extractor.main` was used with ``mkdir = True``, by default True',
nargs = "?",
dest = 'no_sub_dirs',
const = False,
default = True,
type=bool)
parser.add_argument('-e, --engine',
help ="psi4, gaussian or orca. It depends on the engine defined on :meth:`aleimi.extractor.main` was used with ``engine`` keyword, by default 'psi4'",
dest = 'engine',
default = 'psi4',
type=str)

parser.add_argument('--xyz_out',
help ='If True, it will write the xyz coordinates of the conformer with the lowest energy, by default False',
nargs = "?",
dest = 'xyz_out',
const = True,
default = False,
type=bool)

args = parser.parse_args()

processed(
SubDirs=not args.no_sub_dirs,
engine=args.engine,
xyz_out=args.xyz_out
)
if __name__ == '__main__':
pass
13 changes: 8 additions & 5 deletions src/aleimi/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ def get_coords(input_file, indx_to_extract):
if 79*'-' in line:
while True:
line = f.readline()
if (79*'*' in line) or (len(line) == 0):break
if (79*'*' in line) or (len(line) == 0):
break

if 'CELL' in line:
if 'CELL' in line:
cell = int(line.split(':')[1])

elif 'CARTESIAN COORDINATES' in line and cell in indx_to_extract:
utils.ignoreLines(f, 1)
cont = 0
chunk = []
chunk = []
while cont < natoms:
chunk.append(f.readline())
cont += 1
Expand Down Expand Up @@ -135,10 +136,12 @@ def main(
elif engine == 'gaussian':
InputExt = '.gjf'
else:
print(f"Warning!: It was used 'in' as generic extension for the input file for the non recognized engine: {engine}")
print("Warning!: It was used 'in' as generic extension for the input "
f"file for the non recognized engine: {engine}")
InputExt = '.in'

indx_to_extract = extract(boltzmann_file, energy_cut=energy_cut, conformer_cut=conformer_cut)
indx_to_extract = extract(boltzmann_file, energy_cut=energy_cut,
conformer_cut=conformer_cut)
names_coords = get_coords(input_file, indx_to_extract)
for name, coords in names_coords:
INPUT_obj = templates.INPUT(engine, machine=machine, name=name, coords=coords, **keywords)
Expand Down

0 comments on commit 8053af7

Please sign in to comment.