-
Notifications
You must be signed in to change notification settings - Fork 0
/
Search_by_reaction.py
36 lines (33 loc) · 1.33 KB
/
Search_by_reaction.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
__author__ = 'arkadii'
import glob
import subprocess as sp
import sys
import ensure_dir
def search_by_reaction(number,folder,SMILES_reaction, PATH):
files_mrv = glob.glob(folder + 'search_' + str(number+1) + '/' + '*.mrv')
ensure_dir.ensure_dir(folder + 'temporary/')
fn=0
for file in files_mrv:
g = open(file)
ggg = g.readlines()
g.close()
fn+=1
if len(ggg)>2:
print(file)
print ('Standardizing...')
try:
sp.call(['standardize', file, '-c', PATH+'/standardizer2.xml', '-f', 'rdf', '-o', file[:-3] + 'rdf'])
except:
print ('Not enough memory for Standardizer!!!')
sys.exit()
print ('Searching by reaction...')
try:
sp.call(['jcsearch', '-q', SMILES_reaction[number*2], '-f', 'MRV', '-o', folder + 'temporary/' + file.split('/')[-1], file[:-3] + 'rdf'])
except:
print ('Not enough memory for jcsearch!!!')
sys.exit()
print (file.split('/')[-1] + ' is done..')
print (str(fn*100//len(files_mrv)) + '%')
sp.call([PATH+'/molconvert_calling.sh', folder.rstrip('/'), str(number+1)])
sp.call(["rm", "-r", folder + 'temporary/'])
print ('Substructure search in jcsearch by reaction is done...')