GitBucket
Pull requests
Issues
Snippets
Sign in
s18h024
/
振動数と赤外線強度を抜き出すやつ。InChIを抜く部分を追記。
Fork
0
Created at Mon Jul 26 08:32:06 JST 2021
Download ZIP
HTTP
Embed
Embed this snippet in your website.
HTTP
Clone with Git using the repository's web address.
Code
Revision
Forks
s18h024
revised this
on 26 Jul 2021
98f2f55
振動数と赤外線強度を抜き出すやつ。InChIを抜く部分を追記。
import pandas as pd import csv import pubchempy as pup import os import time element = [] files =os.listdir("./edit/imput") element_z = [f for f in files if os.path.isfile(os.path.join("./edit/imput", f))] for j in element_z: a=j.replace(".log","") element.append(a) failed_element = ["Water","Vaseline","IWC","OMEGA"] flag = False for i in element: try: ary_f = ["Frequencies"] ary_r = ["IR Inten"] ary_i = ["InChI"] path = "./edit/imput/"+i + ".log" path_j = "./edit/output/" + i + ".csv" req = ["MolecularFormula","inchi"] #////////////////////////// # TEST ELEMENT i = "Water" # TEST ELEMENT #///////////////////////// out = pup.get_properties(req,i,'name') print(out[0]) ary_i.append(out[0].get("InChI")) time.sleep(1) with open(path,"r") as d: for i, line in enumerate(d): if 'Frequencies' in line: data = line.replace("Frequencies --","") print(data) datas = data.split() for l in datas: ary_f.append(l) elif 'IR Inten' in line: data = line.replace("IR Inten --","") datas = data.split() for m in datas: ary_r.append(m) # jsondata = {} # jsondata [i] = { # "Frequencies" : ary_f, # "IR Inten" : ary_i, # "InChI": inchi # } with open(path_j,"w") as j: writer = csv.writer(j) writer.writerow(ary_f) with open(path_j,"a") as a: writer = csv.writer(a) writer.writerow(ary_r) with open(path_j,"a") as b: writer = csv.writer(b) writer.writerow(ary_i) # 実数の配列に # 変更 except: failed_element.append(i) flag = True if flag == True: cnt = 0 with open("./edit/imput/failedelement.txt","w") as c: for i in failed_element: c.write(failed_element[cnt]) c.write("\n") cnt = cnt +1
import pandas as pd import csv import pubchempy as pup import os import time element = [] files =os.listdir("/Users/ozaki/Desktop/push/edit/imput") element_z = [f for f in files if os.path.isfile(os.path.join("/Users/ozaki/Desktop/push/edit/imput", f))] for j in element_z: a=j.replace(".log","") element.append(a) failed_element = ["Water","Vaseline","IWC","OMEGA"] flag = False for i in element: try: ary_f = ["Frequencies"] ary_r = ["IR Inten"] ary_i = ["InChI"] path = "/Users/ozaki/Desktop/push/edit/imput/"+i + ".log" path_j = "/Users/ozaki/Desktop/push/edit/output/" + i + ".csv" req = ["MolecularFormula","inchi"] #////////////////////////// # TEST ELEMENT i = "Water" # TEST ELEMENT #///////////////////////// out = pup.get_properties(req,i,'name') print(out[0]) ary_i.append(out[0].get("InChI")) time.sleep(1) with open(path,"r") as d: for i, line in enumerate(d): if 'Frequencies' in line: data = line.replace("Frequencies --","") print(data) datas = data.split() for l in datas: ary_f.append(l) elif 'IR Inten' in line: data = line.replace("IR Inten --","") datas = data.split() for m in datas: ary_r.append(m) # jsondata = {} # jsondata [i] = { # "Frequencies" : ary_f, # "IR Inten" : ary_i, # "InChI": inchi # } with open(path_j,"w") as j: writer = csv.writer(j) writer.writerow(ary_f) with open(path_j,"a") as a: writer = csv.writer(a) writer.writerow(ary_r) with open(path_j,"a") as b: writer = csv.writer(b) writer.writerow(ary_i) # 実数の配列に # 変更 except: failed_element.append(i) flag = True if flag == True: cnt = 0 with open("/Users/ozaki/Desktop/push/edit/output/failedelement.txt","w") as c: for i in failed_element: c.write(failed_element[cnt]) c.write("\n") cnt = cnt +1
s18h024
revised this
on 26 Jul 2021
b3f03e5
振動数と赤外線強度を抜き出すやつ。InChIを抜く部分を追記。
import pandas as pd import csv import pubchempy as pup import os import time element = [] files =os.listdir("/Users/ozaki/Desktop/push/edit/imput") element_z = [f for f in files if os.path.isfile(os.path.join("/Users/ozaki/Desktop/push/edit/imput", f))] for j in element_z: a=j.replace(".log","") element.append(a) failed_element = ["Water","Vaseline","IWC","OMEGA"] flag = False for i in element: try: ary_f = ["Frequencies"] ary_r = ["IR Inten"] ary_i = ["InChI"] path = "/Users/ozaki/Desktop/push/edit/imput/"+i + ".log" path_j = "/Users/ozaki/Desktop/push/edit/output/" + i + ".csv" req = ["MolecularFormula","inchi"] #////////////////////////// # TEST ELEMENT i = "Water" # TEST ELEMENT #///////////////////////// out = pup.get_properties(req,i,'name') print(out[0]) ary_i.append(out[0].get("InChI")) time.sleep(1) with open(path,"r") as d: for i, line in enumerate(d): if 'Frequencies' in line: data = line.replace("Frequencies --","") print(data) datas = data.split() for l in datas: ary_f.append(l) elif 'IR Inten' in line: data = line.replace("IR Inten --","") datas = data.split() for m in datas: ary_r.append(m) # jsondata = {} # jsondata [i] = { # "Frequencies" : ary_f, # "IR Inten" : ary_i, # "InChI": inchi # } with open(path_j,"w") as j: writer = csv.writer(j) writer.writerow(ary_f) with open(path_j,"a") as a: writer = csv.writer(a) writer.writerow(ary_r) with open(path_j,"a") as b: writer = csv.writer(b) writer.writerow(ary_i) # 実数の配列に # 変更 except: failed_element.append(i) flag = True if flag == True: cnt = 0 with open("/Users/ozaki/Desktop/push/edit/output/failedelement.txt","w") as c: for i in failed_element: c.write(failed_element[cnt]) c.write("\n") cnt = cnt +1