Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions POVME/POVME2_GUI.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python

from Tkinter import *
from tkinter import *
#------------------------------------------------------------------------------#
# #
# POVME2_GUI #
Expand All @@ -12,7 +12,7 @@ def __init__(self,Master=None,**kw):
#Your code here
#

apply(Frame.__init__,(self,Master),kw)
Frame.__init__(*(self,Master), **kw)
self.__Frame2 = Frame(self)
self.__Frame2.pack(side='top')
self.__Label1 = Label(self.__Frame2,background='#000000'
Expand Down Expand Up @@ -828,8 +828,8 @@ def is_int(self, str):
except ValueError:
return False

import tkMessageBox
import tkFileDialog
import tkinter.messagebox
import tkinter.filedialog
import os
#import shutil
import sys
Expand Down
106 changes: 54 additions & 52 deletions POVME/POVME3.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
import POVME.packages.binana.peel as peel
import multiprocessing
import platform
from functools import reduce

#from guppy import hpy

#hp=hpy()

try: from cStringIO import StringIO
except: from StringIO import StringIO
try: from io import StringIO
except: from io import StringIO

from scipy.spatial.distance import cdist
from scipy.spatial.distance import pdist
Expand Down Expand Up @@ -89,7 +90,7 @@ def log(astr, parameters):
'''

# Print the output to the screen.
print astr
print(astr)

# Save it to the output file as well.
try:
Expand Down Expand Up @@ -135,7 +136,7 @@ def __init__(self, inputs, num_processors, task_class):
self.results = []

if num_processors != 1 and (platform.system().upper()[:3] == "WIN" or "NT" in platform.system().upper()): # If it's windows, you can only use one processor.
print "WARNING: Use of multiple processors is not supported in Windows. Proceeding with one processor..."
print("WARNING: Use of multiple processors is not supported in Windows. Proceeding with one processor...")
num_processors = 1

if num_processors == 1: # so just running on 1 processor, perhaps under windows
Expand All @@ -157,7 +158,7 @@ def __init__(self, inputs, num_processors, task_class):

# reduce the number of processors if too many have been specified
if len(inputs) < num_processors:
print 'Too many processors requested (%i requested, vs %i frames to analyze). Lowering number requested.' %(num_processors, len(inputs))
print('Too many processors requested (%i requested, vs %i frames to analyze). Lowering number requested.' %(num_processors, len(inputs)))
num_processors = len(inputs)

if len(inputs) == 0: # if there are no inputs, there's nothing to do.
Expand Down Expand Up @@ -849,6 +850,7 @@ def determineFirstConvexHull(index_and_pdbs,parameters):
hydros = this_pdb.selections.select_atoms({'element_stripped':['H']})
not_hydros = this_pdb.selections.invert_selection(hydros)
not_hydros_coors = this_pdb.information.get_coordinates()[not_hydros]
break


akl_toussaint_pts = convex_hull_3d.akl_toussaint(not_hydros_coors) # quickly reduces input size
Expand Down Expand Up @@ -878,9 +880,9 @@ def value_func(self, item, results_queue, color = False):
results_queue -- A multiprocessing.Queue() object for storing the calculation output

"""
print '---------------------------------'
print 'STARTING CALC VOLUME'#,hp.heap()
print '---------------------------------'
print('---------------------------------')
print('STARTING CALC VOLUME')#,hp.heap()
print('---------------------------------')


frame_indx = item[0]
Expand Down Expand Up @@ -1140,7 +1142,7 @@ def value_func(self, item, results_queue, color = False):
extra_data_to_add['CalculateSurfaceArea'] = surfA
#print "Surface Area for frame %r: %r" %(frame_indx, len(surfacePointsSet.intersection(adjacentPointsSet)))
#if parameters[SaveIndividualPocketVolumes] == True:
for color in coloredMaps.keys():
for color in list(coloredMaps.keys()):
#First make a copy of coloredMaps[color] that only contains the points over the intensity threshold
#print color, coloredMaps[color]
#log('AAAAA' + color + str(frame_indx), parameters)
Expand Down Expand Up @@ -1188,9 +1190,9 @@ def value_func(self, item, results_queue, color = False):
#else:
# log("\tFrame " + str(frame_indx) + ": " + repr(volume) + " A^3", parameters)
self.results.append((frame_indx, volume, extra_data_to_add))
print '---------------------------------'
print 'FINISHING CALC VOLUME'#,hp.heap()
print '---------------------------------'
print('---------------------------------')
print('FINISHING CALC VOLUME')#,hp.heap()
print('---------------------------------')

#if len(extra_data_to_add.keys()) != 0:
#else: self.results.append((frame_indx, volume))
Expand Down Expand Up @@ -1219,8 +1221,8 @@ def value_func(self, item, results_queue):
pdb.fileio.load_pym_into(pym_filename)

ligand_atoms = pdb.select_atoms({'resname_stripped':parameters[DefinePocketByLigand]})
print parameters[DefinePocketByLigand]
print ligand_atoms
print(parameters[DefinePocketByLigand])
print(ligand_atoms)
ligand_coords = pdb.get_coordinates()[ligand_atoms].round()
ligand_coords_set = set([tuple(row) for row in ligand_coords])
self.results.append(ligand_coords_set)
Expand Down Expand Up @@ -1597,7 +1599,7 @@ def __init__ (self, FileName):
# has more than 2 members, python will crash. However, each entity in self.entities should have only 2 members
# due to the processing code above.
for parameter,values in self.entities:
print parameter, values
print(parameter, values)
#if unexpected config keyword in config file, throw this exception
if parameter not in all_parameters:
raise Exception('%s is not a valid parameter. Valid parameters are: %r' %(parameter,all_parameters))
Expand Down Expand Up @@ -1683,13 +1685,13 @@ def load_multi_frame_pdb(self, filename, parameters):
log("", parameters)
log("Reading frames from " + filename, parameters)

f = open(filename, 'rb')
f = open(filename, 'r')
while True:

if parameters[NumFrames] != -1:
if len(pdb_strings) >= parameters[NumFrames]: break

line = f.readline()
line = str(f.readline())

if len(line) == 0:
pdb_strings.append(growing_string)
Expand Down Expand Up @@ -1717,18 +1719,18 @@ def __init__(self, argv):
argv -- A list of the command-line arguments.

'''
print '---------------------------------'
print 'START'#,hp.heap()
print '---------------------------------'
print('---------------------------------')
print('START')#,hp.heap()
print('---------------------------------')

start_time = time.time()

# Load the configuration file
if len(argv) == 1:
print "\nPOVME " + version
print "\nPlease specify the input file from the command line!\n\nExample: python POVME.py input_file.ini"
print("\nPOVME " + version)
print("\nPlease specify the input file from the command line!\n\nExample: python POVME.py input_file.ini")
self.reference({})
print
print()
sys.exit()

config = ConfigFile(argv[1])
Expand Down Expand Up @@ -1768,7 +1770,7 @@ def __init__(self, argv):
# print out parameters
#consider this section for deletion
log("Parameters:", parameters)
for i in parameters.keys():
for i in list(parameters.keys()):

if i == 'NumFrames' and parameters[NumFrames] == -1: continue # So only show this parameter if it's value is not the default.

Expand All @@ -1779,24 +1781,24 @@ def __init__(self, argv):
if parameters[i] != "": log("\t" + str(i) + ": " + str(parameters[i]), parameters)
#this section ^ total garbage

print '---------------------------------'
print 'PARAMETERS DEFINED'#,hp.heap()
print '---------------------------------'
print('---------------------------------')
print('PARAMETERS DEFINED')#,hp.heap()
print('---------------------------------')

pts = None

if parameters[PDBFileName] != '': # so there's a PDB point specified for calculating the volume.

# load the points in they aren't already present

print '---------------------------------'
print 'ABOUT TO LOAD RECEPTORS'#,hp.heap()
print '---------------------------------'
print('---------------------------------')
print('ABOUT TO LOAD RECEPTORS')#,hp.heap()
print('---------------------------------')
# load the PDB frames
index_and_pdbs = self.load_multi_frame_pdb(parameters[PDBFileName], parameters)
print '---------------------------------'
print 'RECEPTORS LOADED'#,hp.heap()
print '---------------------------------'
print('---------------------------------')
print('RECEPTORS LOADED')#,hp.heap()
print('---------------------------------')

# calculate all the volumes
log("", parameters)
Expand Down Expand Up @@ -1968,9 +1970,9 @@ def __init__(self, argv):

log("Calculating the pocket volume of each frame", parameters)
tmp = Multithreading([(index, pdb_object, parameters) for index, pdb_object in index_and_pdbs], parameters[NumProcessors], MultithreadingCalcVolumeTask)
print '---------------------------------'
print 'VOLUMES CALCULATED'#,hp.heap()
print '---------------------------------'
print('---------------------------------')
print('VOLUMES CALCULATED')#,hp.heap()
print('---------------------------------')

# delete the temp swap directory if necessary

Expand Down Expand Up @@ -2015,7 +2017,7 @@ def __init__(self, argv):
if parameters[CompressOutput] == True: traj_file = gzip.open(parameters[OutputFilenamePrefix] + "volume_trajectory.pdb.gz", 'wb')
else: traj_file = open(parameters[OutputFilenamePrefix] + "volume_trajectory.pdb", 'w')

for frame_index in range(1,len(volume_dic.keys())+1):
for frame_index in range(1,len(list(volume_dic.keys()))+1):
if parameters[CompressOutput] == True: frame_file = gzip.open(parameters[OutputFrameFilenamePrefix] + "frame_" + str(frame_index) + ".pdb.gz", 'rb')
else: frame_file = open(parameters[OutputFrameFilenamePrefix] + "frame_" + str(frame_index) + ".pdb", 'r')

Expand All @@ -2028,12 +2030,12 @@ def __init__(self, argv):
traj_file.close()

#if parameters[SaveColoredMap] == True:
colors = tmp.results[0][2]['SaveColoredMap'].keys()
colors = list(tmp.results[0][2]['SaveColoredMap'].keys())
for color in colors:
if parameters[CompressOutput] == True: traj_file = gzip.open(parameters[OutputFilenamePrefix] + color + "_trajectory.pdb.gz", 'wb')
else: traj_file = open(parameters[OutputFilenamePrefix] + color + "_volume_trajectory.pdb", 'w')

for frame_index in range(1,len(volume_dic.keys())+1):
for frame_index in range(1,len(list(volume_dic.keys()))+1):
if parameters[CompressOutput] == True: frame_file = gzip.open(parameters[OutputFrameFilenamePrefix] + "frame_" + str(frame_index) + "_" + color + ".pdb.gz", 'rb')
else: frame_file = open(parameters[OutputFrameFilenamePrefix] + "frame_" + str(frame_index) + "_" + color + ".pdb", 'r')

Expand Down Expand Up @@ -2067,9 +2069,9 @@ def __init__(self, argv):



print '---------------------------------'
print 'ABOUT TO CALCULATE OCCUPANCY AVERAGE'#,hp.heap()
print '---------------------------------'
print('---------------------------------')
print('ABOUT TO CALCULATE OCCUPANCY AVERAGE')#,hp.heap()
print('---------------------------------')
# Generate the frame-averages volumetric density map
#if parameters[SaveVolumetricDensityDX] == True or parameters[SaveVolumetricDensityNpy] == True:
unique_points = {}
Expand Down Expand Up @@ -2127,22 +2129,22 @@ def __init__(self, argv):



print '---------------------------------'
print 'CALCULATED OCCUPANCY AVERAGE'#,hp.heap()
print '---------------------------------'
print('---------------------------------')
print('CALCULATED OCCUPANCY AVERAGE')#,hp.heap()
print('---------------------------------')


#if parameters[SaveColoredMap] == True:

print '---------------------------------'
print 'ABOUT TO CALCULATE COLOR MAPS'#,hp.heap()
print '---------------------------------'
print('---------------------------------')
print('ABOUT TO CALCULATE COLOR MAPS')#,hp.heap()
print('---------------------------------')

#print 'Saving Colored Maps!'
#start = time.time()


colors = tmp.results[0][2]['SaveColoredMap'].keys()
colors = list(tmp.results[0][2]['SaveColoredMap'].keys())
for color in colors:
overall_min = numpy.ones(3) * 1e100
overall_max = numpy.ones(3) * -1e100
Expand Down Expand Up @@ -2197,9 +2199,9 @@ def __init__(self, argv):
#if parameters[SaveVolumetricDensityNpy] == True:
numpy.save(colorParams['OutputFrameFilenamePrefix']+'volumetric_density.npy', all_pts)
#print 'time to save map for %s: %s' %(color, str(time.time()-start3))
print '---------------------------------'
print 'CALCULATED COLOR MAPS'#,hp.heap()
print '---------------------------------'
print('---------------------------------')
print('CALCULATED COLOR MAPS')#,hp.heap()
print('---------------------------------')


if __name__ == "__main__": dorun = runit(sys.argv)
Loading