Minor fixes in pizza tools

This commit is contained in:
Richard Berger
2021-06-01 16:57:19 -04:00
parent 0d0c0ab136
commit 62675e6e2b
6 changed files with 33 additions and 34 deletions

View File

@ -275,7 +275,7 @@ class dump:
print("no column assignments made") print("no column assignments made")
elif len(self.names): elif len(self.names):
print("assigned columns:",self.names2str()) print("assigned columns:",self.names2str())
elif self.snaps[0].atoms == None: elif self.snaps[0].atoms is None:
print("no column assignments made") print("no column assignments made")
elif len(self.snaps[0].atoms[0]) == 5: elif len(self.snaps[0].atoms[0]) == 5:
self.map(1,"id",2,"type",3,"x",4,"y",5,"z") self.map(1,"id",2,"type",3,"x",4,"y",5,"z")
@ -969,12 +969,12 @@ class dump:
xhi = yhi = zhi = None xhi = yhi = zhi = None
for snap in self.snaps: for snap in self.snaps:
if not snap.tselect: continue if not snap.tselect: continue
if xlo == None or snap.xlo < xlo: xlo = snap.xlo if xlo is None or snap.xlo < xlo: xlo = snap.xlo
if xhi == None or snap.xhi > xhi: xhi = snap.xhi if xhi is None or snap.xhi > xhi: xhi = snap.xhi
if ylo == None or snap.ylo < ylo: ylo = snap.ylo if ylo is None or snap.ylo < ylo: ylo = snap.ylo
if yhi == None or snap.yhi > yhi: yhi = snap.yhi if yhi is None or snap.yhi > yhi: yhi = snap.yhi
if zlo == None or snap.zlo < zlo: zlo = snap.zlo if zlo is None or snap.zlo < zlo: zlo = snap.zlo
if zhi == None or snap.zhi > zhi: zhi = snap.zhi if zhi is None or snap.zhi > zhi: zhi = snap.zhi
return [xlo,ylo,zlo,xhi,yhi,zhi] return [xlo,ylo,zlo,xhi,yhi,zhi]
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -851,7 +851,7 @@ class gl:
ncolor = self.vizinfo.ntcolor ncolor = self.vizinfo.ntcolor
for tri in self.tridraw: for tri in self.tridraw:
itype = int(tri[1]) itype = int(tri[1])
if itype > ncolor: raise StandardError("tri type too big") if itype > ncolor: raise Exception("tri type too big")
red,green,blue = self.vizinfo.tcolor[itype] red,green,blue = self.vizinfo.tcolor[itype]
glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,[red,green,blue,1.0]); glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,[red,green,blue,1.0]);
glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,self.shiny); glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,self.shiny);
@ -909,7 +909,7 @@ class gl:
ymin >= ylo and ymax <= yhi and zmin >= zlo and zmax <= zhi: ymin >= ylo and ymax <= yhi and zmin >= zlo and zmax <= zhi:
if bond[10] > bound: continue if bond[10] > bound: continue
itype = int(bond[1]) itype = int(bond[1])
if itype > ncolor: raise StandardError("bond type too big") if itype > ncolor: raise Exception("bond type too big")
red,green,blue = self.vizinfo.bcolor[itype] red,green,blue = self.vizinfo.bcolor[itype]
rad = self.vizinfo.brad[itype] rad = self.vizinfo.brad[itype]
glPushMatrix() glPushMatrix()
@ -941,7 +941,7 @@ class gl:
ymin >= ylo and ymax <= yhi and \ ymin >= ylo and ymax <= yhi and \
zmin >= zlo and zmax <= zhi: zmin >= zlo and zmax <= zhi:
itype = int(tri[1]) itype = int(tri[1])
if itype > ncolor: raise StandardError("tri type too big") if itype > ncolor: raise Exception("tri type too big")
red,green,blue = self.vizinfo.tcolor[itype] red,green,blue = self.vizinfo.tcolor[itype]
glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION, glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,
[red,green,blue,1.0]); [red,green,blue,1.0]);

View File

@ -87,12 +87,12 @@ g.curve(N,'r') set color of curve N
# Imports and external programs # Imports and external programs
import types, os import os
try: from DEFAULTS import PIZZA_GNUPLOT try: from DEFAULTS import PIZZA_GNUPLOT
except: PIZZA_GNUPLOT = "gnuplot -p" except ImportError: PIZZA_GNUPLOT = "gnuplot -p"
try: from DEFAULTS import PIZZA_GNUTERM try: from DEFAULTS import PIZZA_GNUTERM
except: PIZZA_GNUTERM = "x11" except ImportError: PIZZA_GNUTERM = "x11"
# Class definition # Class definition
@ -122,7 +122,7 @@ class gnu:
def enter(self): def enter(self):
while 1: while 1:
command = raw_input("gnuplot> ") command = input("gnuplot> ")
if command == "quit" or command == "exit": return if command == "quit" or command == "exit": return
self.__call__(command) self.__call__(command)
@ -136,7 +136,7 @@ class gnu:
self.export(file,linear,vectors[0]) self.export(file,linear,vectors[0])
self.figures[self.current-1].ncurves = 1 self.figures[self.current-1].ncurves = 1
else: else:
if len(vectors) % 2: raise StandardError("vectors must come in pairs") if len(vectors) % 2: raise Exception("vectors must come in pairs")
for i in range(0,len(vectors),2): for i in range(0,len(vectors),2):
file = self.file + ".%d.%d" % (self.current,i/2+1) file = self.file + ".%d.%d" % (self.current,i/2+1)
self.export(file,vectors[i],vectors[i+1]) self.export(file,vectors[i],vectors[i+1])
@ -170,7 +170,7 @@ class gnu:
def export(self,filename,*vectors): def export(self,filename,*vectors):
n = len(vectors[0]) n = len(vectors[0])
for vector in vectors: for vector in vectors:
if len(vector) != n: raise StandardError("vectors must be same length") if len(vector) != n: raise Exception("vectors must be same length")
f = open(filename,'w') f = open(filename,'w')
nvec = len(vectors) nvec = len(vectors)
for i in range(n): for i in range(n):

View File

@ -68,7 +68,7 @@ index,time,flag = p.iterator(1)
# Imports and external programs # Imports and external programs
import sys, types, glob, urllib import sys, glob, urllib
PY3 = sys.version_info[0] == 3 PY3 = sys.version_info[0] == 3
if PY3: if PY3:
@ -93,7 +93,7 @@ class pdbfile:
elif len(args) == 2: elif len(args) == 2:
filestr = args[0] filestr = args[0]
self.data = args[1] self.data = args[1]
else: raise StandardError("invalid args for pdb()") else: raise Exception("invalid args for pdb()")
# flist = full list of all PDB input file names # flist = full list of all PDB input file names
# append .pdb if needed # append .pdb if needed
@ -104,17 +104,17 @@ class pdbfile:
for file in list: for file in list:
if '*' in file: flist += glob.glob(file) if '*' in file: flist += glob.glob(file)
else: flist.append(file) else: flist.append(file)
for i in xrange(len(flist)): for i in range(len(flist)):
if flist[i][-4:] != ".pdb": flist[i] += ".pdb" if flist[i][-4:] != ".pdb": flist[i] += ".pdb"
if len(flist) == 0: if len(flist) == 0:
raise StandardError("no PDB file specified") raise Exception("no PDB file specified")
self.files = flist self.files = flist
else: self.files = [] else: self.files = []
if len(self.files) > 1 and self.data: if len(self.files) > 1 and self.data:
raise StandardError("cannot use multiple PDB files with data object") raise Exception("cannot use multiple PDB files with data object")
if len(self.files) == 0 and not self.data: if len(self.files) == 0 and not self.data:
raise StandardError("no input PDB file(s)") raise Exception("no input PDB file(s)")
# grab PDB file from http://rcsb.org if not a local file # grab PDB file from http://rcsb.org if not a local file

View File

@ -79,7 +79,7 @@ class vizinfo:
# if list of types has a 0, increment each type value # if list of types has a 0, increment each type value
if 0 in ids: if 0 in ids:
for i in xrange(len(ids)): ids[i] += 1 for i in range(len(ids)): ids[i] += 1
# extend storage list if necessary # extend storage list if necessary
# extend other arrays for same "which" so that gl::make_atom_calllist # extend other arrays for same "which" so that gl::make_atom_calllist
@ -109,7 +109,7 @@ class vizinfo:
ntypes = len(ids) ntypes = len(ids)
nrgbs = len(rgbs) nrgbs = len(rgbs)
for i in xrange(ntypes): for i in range(ntypes):
id = ids[i] id = ids[i]
if rgbs[0] == "loop": if rgbs[0] == "loop":
@ -157,7 +157,7 @@ class vizinfo:
# if list of types has a 0, increment each type value # if list of types has a 0, increment each type value
if 0 in ids: if 0 in ids:
for i in xrange(len(ids)): ids[i] += 1 for i in range(len(ids)): ids[i] += 1
# extend storage list if necessary # extend storage list if necessary
# extend other arrays for same "which" so that gl::make_atom_calllist # extend other arrays for same "which" so that gl::make_atom_calllist
@ -220,7 +220,7 @@ class vizinfo:
# if list of types has a 0, increment each type value # if list of types has a 0, increment each type value
if 0 in ids: if 0 in ids:
for i in xrange(len(ids)): ids[i] += 1 for i in range(len(ids)): ids[i] += 1
# extend storage list if necessary # extend storage list if necessary
# extend other arrays for same "which" so that gl::make_atom_calllist # extend other arrays for same "which" so that gl::make_atom_calllist
@ -234,7 +234,7 @@ class vizinfo:
# if list lengths match, set directly, else set types to 1st fill value # if list lengths match, set directly, else set types to 1st fill value
if len(fills) == len(ids): if len(fills) == len(ids):
for i in xrange(len(ids)): self.tfill[ids[i]] = int(fills[i]) for i in range(len(ids)): self.tfill[ids[i]] = int(fills[i])
else: else:
for id in ids: self.tfill[id] = int(fills[0]) for id in ids: self.tfill[id] = int(fills[0])

View File

@ -45,17 +45,16 @@ v.debug([True|False]) display generated VMD script commands?
# Imports and external programs # Imports and external programs
import types, os import os
import numpy
try: from DEFAULTS import PIZZA_VMDNAME try: from DEFAULTS import PIZZA_VMDNAME
except: PIZZA_VMDNAME = "vmd" except ImportError: PIZZA_VMDNAME = "vmd"
try: from DEFAULTS import PIZZA_VMDDIR try: from DEFAULTS import PIZZA_VMDDIR
except: PIZZA_VMDDIR = "/usr/local/lib/vmd" except ImportError: PIZZA_VMDDIR = "/usr/local/lib/vmd"
try: from DEFAULTS import PIZZA_VMDDEV try: from DEFAULTS import PIZZA_VMDDEV
except: PIZZA_VMDDEV = "win" except ImportError: PIZZA_VMDDEV = "win"
try: from DEFAULTS import PIZZA_VMDARCH try: from DEFAULTS import PIZZA_VMDARCH
except: PIZZA_VMDARCH = "LINUXAMD64" except ImportError: PIZZA_VMDARCH = "LINUXAMD64"
# try these settings for a Mac # try these settings for a Mac
#PIZZA_VMDNAME = "vmd" #PIZZA_VMDNAME = "vmd"
@ -64,7 +63,7 @@ except: PIZZA_VMDARCH = "LINUXAMD64"
#PIZZA_VMDARCH = "MACOSXX86" #PIZZA_VMDARCH = "MACOSXX86"
try: import pexpect try: import pexpect
except: except ImportError:
print("pexpect from http://pypi.python.org/pypi/pexpect", \ print("pexpect from http://pypi.python.org/pypi/pexpect", \
"is required for vmd tool") "is required for vmd tool")
raise raise