Skip to content

Commit

Permalink
1. Change storing out file from csearch-crest
Browse files Browse the repository at this point in the history
  • Loading branch information
jvalegre committed Feb 25, 2023
1 parent 8f1d0ac commit 41f0c35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 2 additions & 1 deletion aqme/csearch/crest.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def xtb_opt_main(

xyzoutall = str(dat_dir) + "/" + name_no_path + "_conformers.xyz"

# CREST sampling
if self.args.program.lower() == "crest":
self.args.log.write(f"\no Starting CREST sampling")
if constrained_opt:
Expand Down Expand Up @@ -287,12 +288,12 @@ def xtb_opt_main(

run_command(command, f"/{dat_dir}/{name_no_path}.out")

# get number of n_atoms
try:
natoms = open("crest_best.xyz").readlines()[0].strip()
except FileNotFoundError:
self.args.log.write(f"\nx CREST optimization failed! This might be caused by different reasons. For example, this might happen if you're using metal complexes without specifying any kind of template in the complex_type option (i.e. squareplanar).\n")

# CREGEN sorting
if self.args.cregen and int(natoms) != 1:
self.args.log.write(f"\no Starting CREGEN sorting")
command = ["crest", "crest_best.xyz", "--cregen", "crest_conformers.xyz"]
Expand Down
13 changes: 4 additions & 9 deletions aqme/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,12 @@

def run_command(command, outfile):
"""
Runs the subprocess command and outputs to the necessary output file
Runs the subprocess command and saves the results in an output file (not shown in the terminal)
"""

p2 = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
txt = [line.decode("utf-8") for line in p2.stdout]
p2.stdout.close()

with open(outfile, "w") as f:
for line in txt:
f.write(line)
f.close()
output = open(outfile, "w")
subprocess.run(command, stdout=output, stderr=subprocess.DEVNULL)
output.close()


def periodic_table():
Expand Down

0 comments on commit 41f0c35

Please sign in to comment.