/usr/lib/python2.7/dist-packages/chempy/tinker/__init__.py is in pymol 1.8.4.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | #A* -------------------------------------------------------------------
#B* This file contains source code for the PyMOL computer program
#C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
#D* -------------------------------------------------------------------
#E* It is unlawful to modify or remove this copyright notice.
#F* -------------------------------------------------------------------
#G* Please see the accompanying LICENSE file for further information.
#H* -------------------------------------------------------------------
#I* Additional authors of this source file include:
#-* Scott Dixon, Metaphorics, LLC
#-*
#-*
#Z* -------------------------------------------------------------------
from __future__ import print_function
import os
import shutil
import glob
import re
import string
import sys
import time
from chempy import feedback
# "do" is the preferred command for running tinker
def do(command,in_prefix,run_prefix,out_prefix,tokens,capture=None):
if feedback['tinker']:
print(" "+str(__name__)+': creating temporary files "%s.*"' % (run_prefix))
print(" "+str(__name__)+': launching %s...' % command)
c = 1
for a in tokens:
print(" "+str(__name__)+': input %d = %s' % (c,a))
c = c + 1
if hasattr(sys.stdout,"flush"):
sys.stdout.flush()
for a in glob.glob(run_prefix+".*"):
os.unlink(a)
for a in glob.glob(out_prefix+".*"):
os.unlink(a)
for src in glob.glob(in_prefix+".*"):
dst = string.split(src,'.')
dst = run_prefix+'.'+dst[len(dst)-1]
shutil.copyfile(src,dst)
if capture==1:
pipe = os.popen(bin_path+command+"> "+run_prefix+".out","w")
elif capture==2:
pipe = os.popen(bin_path+command+" | tee "+run_prefix+".out","w")
else:
pipe = os.popen(bin_path+command,"w")
if not pipe:
print("Error: can't run tinker!!!")
raise RunError
for a in tokens:
pipe.write(a+"\n")
pipe.close()
# NFS workaround (flushes the directory cache so that glob will work)
try: os.unlink(".sync")
except: pass
f = open(".sync",'w')
f.close()
#
for src in glob.glob(run_prefix+".*_2"):
dst = string.replace(src,'_2','')
if os.path.exists(dst):
os.unlink(dst)
# os.rename(src,dst) rename can fail over NFS (remote action)
shutil.copyfile(src,dst)
# sloppy workaround for buggy NFS on linux
os.unlink(src)
for src in glob.glob(run_prefix+".*"):
dst = string.split(src,'.')
dst = out_prefix+'.'+dst[len(dst)-1]
if os.path.exists(dst):
os.unlink(dst)
# os.rename(src,dst) rename can fail over NFS (remote action)
shutil.copy(src,dst)
os.unlink(src)
for a in glob.glob(in_prefix+".*"):
os.unlink(a)
if feedback['tinker']:
print(" "+str(__name__)+': %s job complete. ' % command)
print(" "+str(__name__)+': creating output files "%s.*"' % (out_prefix))
# DEPRECATED
prefix = "tinker_run"
def run(command,in_prefix,out_prefix,tokens,capture=None):
if feedback['tinker']:
print(" "+str(__name__)+': creating temporary files "%s.*"' % (prefix))
print(" "+str(__name__)+': launching %s...' % command)
c = 1
for a in tokens:
print(" "+str(__name__)+': input %d = %s' % (c,a))
c = c + 1
if hasattr(sys.stdout,"flush"):
sys.stdout.flush()
for a in glob.glob(prefix+".*"):
os.unlink(a)
for a in glob.glob(out_prefix+".*"):
os.unlink(a)
for src in glob.glob(in_prefix+".*"):
dst = string.split(src,'.')
dst = prefix+'.'+dst[len(dst)-1]
shutil.copyfile(src,dst)
if capture:
pipe = os.popen(bin_path+command+"> "+out_prefix+".out","w")
else:
pipe = os.popen(bin_path+command,"w")
if not pipe:
print("Error: can't run tinker!!!")
raise RunError
for a in tokens:
pipe.write(a+"\n")
pipe.close()
for src in glob.glob(prefix+".*_2"):
dst = string.replace(src,'_2','')
if os.path.exists(dst):
os.unlink(dst)
# os.rename(src,dst) rename can fail over NFS (remote action)
shutil.copy(src,dst)
os.unlink(src)
for src in glob.glob(prefix+".*"):
dst = string.split(src,'.')
dst = out_prefix+'.'+dst[len(dst)-1]
if os.path.exists(dst):
os.unlink(dst)
# os.rename(src,dst) rename can fail over NFS (remote action)
shutil.copy(src,dst)
if feedback['tinker']:
print(" "+str(__name__)+': %s job complete. ' % command)
print(" "+str(__name__)+': creating output files "%s.*"' % (out_prefix))
if 'TINKER_PATH' in os.environ:
base = os.environ['TINKER_PATH']
bin_path = base + '/bin/'
params_path = base + '/params/'
elif 'FREEMOL_ETC' in os.environ:
base = os.environ['FREEMOL_ETC'] + '/tinker'
bin_path = base + '/bin/'
params_path = base + '/params/'
else:
base = ''
bin_path = ''
params_path = ''
if 'PYMOL_PATH' in os.environ:
pymol_path = os.environ['PYMOL_PATH']
test_path = pymol_path + '/data/chempy/tinker/'
if os.path.exists(test_path):
params_path = test_path
|