-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.py
61 lines (45 loc) · 1.14 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
import subprocess as sp
import numpy as np
from rdkit import Chem
import pandas as pd
import rdkit
from rdkit.Chem import rdmolops
import time
from time import sleep
def listelementsToString(lst):
return [str(i) for i in lst]
def quotes(s):
return f"'{s}'"
def log(s):
with open("output.log", "a") as logfile:
t = time.strftime("%H:%M:%S")
logfile.write(f"[{t}]: {s}")
logfile.write("\n")
def box(msg):
row = len(msg) + 2
h = "".join(["+"] + ["-" * row] + ["+"])
result = h + "\n" "| " + msg + " |" "\n" + h
return result
def run(command):
sleep(1)
p = sp.Popen(command, stdout=sp.PIPE, encoding="utf8")
output, _ = p.communicate()
return output
def removeJunk():
os.system(
"rm charges charges3 energy tda.dat wfn.xtb wbo xtbopt* xtbrestart .xtboptok"
)
def flatten_list(nd_list):
flat_list = []
for i in nd_list:
if type(i) is list:
for item in i:
flat_list.append(item)
else:
flat_list.append(i)
return flat_list
def convert(x, ab):
a = ab[0]
b = ab[1]
return (float(x) * a) + b