Skip to content

Commit

Permalink
Add changes to achieve progress described
Browse files Browse the repository at this point in the history
The progress with Tutorial 4 is detailed in issue hjkgrp#176
hjkgrp#176
  • Loading branch information
tlinjordet committed Sep 20, 2023
1 parent 432e374 commit 092af15
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
13 changes: 6 additions & 7 deletions molSimplify/Classes/globalvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,12 @@ def mybash(cmd):
"""
p = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout = []
while True:
line = p.stdout.readline()
stdout.append(line)
if line == '' and p.poll() is not None:
break
return ''.join(stdout)
stdout, stderr = p.communicate()
lines = stdout.decode('utf-8').splitlines()
lines = [line+"\n" for line in lines if line !=""]
#print(cmd)
#print(''.join(lines))
return ''.join(lines)


# Defines global variables used throughout the code
Expand Down
10 changes: 6 additions & 4 deletions molSimplify/Scripts/dbinteract.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ def getsimilar(smi, nmols, dbselect, finger, squery, args):
print(('database set up :' + str(dbsdf) + ' || ' + str(dbfs)))
print(('Finding results similar, comparing to ' + smi))

obab = 'babel'
obab = 'obabel' # babel -> obabel
if dbfs and args.dbfs:
com = obab + ' ' + dbfs + ' ' + 'simres.smi -d -xf' + \
finger + ' -s"' + smi + '" -al' + nmols
else:
mybash(obab + ' -isdf ' + dbsdf + ' -osdf -O tmp.sdf -d')
com = obab + ' tmp.sdf simres.smi -xf' + finger + ' -s"' + smi + '"'
com = obab + ' tmp.sdf -O simres.smi -xf' + finger + ' -s"' + smi + '"' # babel -> obabel
# perform search using bash commandline
print('Performing substructure search:')
print(('running: ' + str(com)))
Expand Down Expand Up @@ -306,7 +306,7 @@ def checkels(fname, allowedels):
# @param outf Filename containing SMILES strings to be processed
# @param n Number of dissimilar molecules required
def dissim(outf, n):
obab = 'babel'
obab = 'obabel' # babel -> obabel

# clone hitlist file
hit_list_path = "hitlist.smi"
Expand All @@ -317,7 +317,7 @@ def dissim(outf, n):
f.writelines(smiles_list)

# generate fs of original hit list
mybash(obab + ' -ismi ' + hit_list_path + ' -osdf tmp.sdf')
mybash(obab + ' -ismi ' + hit_list_path + ' -osdf -O tmp.sdf') # babel -> obabel
mybash(obab + ' tmp.sdf -ofs')
# number of hits
numcpds = mybash('obabel tmp.sdf -onul')
Expand Down Expand Up @@ -553,6 +553,8 @@ def dbsearch(rundir, args, globs):
shutil.copy('simres.smi', outf)
except FileNotFoundError:
pass
except shutil.SameFileError: # babel -> obabel
pass # babel -> obabel

if args.debug:
print(('after similarity search, outf is ' + str(outputf)))
Expand Down

0 comments on commit 092af15

Please sign in to comment.