PEATSA/Core/Programs.py
def binding(self, comparePDBs=[], ligand=None, verbose=False):
	
		'''Calculates the binding free-energy of a ligand to the source pdb and the compare pdbs.
		
		Also calculates the change in binding free-energy for each to the source pdb
		
		Parameters
			comparePDBs - A list of paths to PDB files.
				All the pdbs in this list will be compared to the sourcePDB.
				The names of the compare pdbs are expected to conform to the following
				.....
				(FIXME: Possibly only have to be of a certain format to do a 'mutantStability' run?)
				
			ligand - The path to a pdb file containing the ligand to check'''
	
		#If there are no mutants supplied raise an exception
		if len(comparePDBs) == 0:
			raise Exceptions.StabilityError, "Unable to perform stability calculation - No mutants supplied"

		#Copy the wildType and ligand to the working dir
		pdbName = os.path.split(self.sourcePDB)[1]
		ligandName = os.path.split(ligand)[1]
		if self.environment.isRoot():
			shutil.copyfile(self.sourcePDB, os.path.join(self.directoryPath, pdbName))
			shutil.copyfile(ligand, os.path.join(self.directoryPath, ligandName))
			
		self.environment.wait()	
	
		#Create the output stream
		outputFile = os.path.join(self.directoryPath, "output%d.txt" % self.environment.rank())
		outputStream = open(outputFile, "a+")
		
		#The executable
		executable = os.path.join(self.executablePath, "Uffbaps")
		
		self.environment.output('\n[BINDING] Running initial wild-type calculation for %s' % ligandName)
		self.environment.output('[BINDING] Using Uffbaps at %s' % self.executablePath)
		
		wildTypeResults = self._runBindingCalculation(pdbName, ligandName, executable, outputStream)

		self.environment.output('[BINDING] Wild-Type results - %s' % zip(UFFBAPS.bindingResultsHeaders, wildTypeResults))
		self.environment.output('\n[BINDING] Beginning mutant binding calculations \n')
		
		#Force output of last print line - required when using ","
		sys.stdout.flush()
	
		#Variables for informing user of progress
		ten = int(len(comparePDBs)/10.0)
		#Avoid module zero if their are less than 10 pbds
		if ten == 0:
			ten = 1
		count = 0
	
		#Accumulate the results for each mutation into this list
		#It will be used at the end to create a matrix
		rows = []
		comparePDBs = self.environment.splitArray(comparePDBs)
		for pdbFile in comparePDBs:
			if verbose:
				self.environment.output('[BINDING] Mutant %s' % os.path.split(pdbFile)[1], rootOnly=False)
			
			#Copy the mutant to the working dir
			compareName = os.path.split(pdbFile)[1]
			shutil.copyfile(pdbFile, os.path.join(self.directoryPath, compareName))
			
			#Do the calculation
			components = self._runBindingCalculation(compareName, ligandName, executable, outputStream)
			
			if components is not None:
				if verbose:
					self.environment.output(
						'[BINDING] Results - %s' % zip(UFFBAPS.bindingResultsHeaders, components),
						rootOnly=False)
				else:
					count = count + 1
					if count%ten == 0:
						#A ugly space is left if print is used
						sys.stdout.write(".")
						sys.stdout.flush()		
			
				#Add the name of the mutation and then the ligand values 
				#to the 'rows' variable
				row = [os.path.splitext(compareName)[0]]
				row.extend(components)	
				rows.append(row)
			
				#Get rid of the mutant pdb file we copied
				os.remove(os.path.join(self.directoryPath, compareName))
								
		outputStream.close()
		
		#This is required in order to catch if any the processes exited the 
		#above loop due to an exception	
		self.environment.wait()	
		#Combine all the rows
		rows = self.environment.combineArray(rows)
		
		if self.environment.isRoot():
			
			headers = ['Mutations']
			headers.extend(UFFBAPS.bindingResultsHeaders)
			self.bindingMatrix = Matrix.PEATSAMatrix(rows=rows, headers=headers, name="Binding")
			
			#Create a delta stability matrix Gmut - Gwt
			deltaRows = []
			for row in rows:
				#Get just the numbers
				values = row[1:]
				#Add the residue information to a new row entry
				newRow = [row[0]]
				#Extend it with  (values - wildTypeResults)
				try:
					newRow.extend(map(operator.sub, values, wildTypeResults))
					deltaRows.append(newRow)
				except:
					print 'Unable to subtract %s from %s' % (values, wildTypeResults)

			self.deltaBindingMatrix = Matrix.PEATSAMatrix(rows=deltaRows, headers=headers, name="DeltaBinding")
Calculates the binding free-energy of a ligand to the source pdb and the compare pdbs.
		
		Also calculates the change in binding free-energy for each to the source pdb
		
		Parameters
			comparePDBs - A list of paths to PDB files.
				All the pdbs in this list will be compared to the sourcePDB.
				The names of the compare pdbs are expected to conform to the following
				.....
				(FIXME: Possibly only have to be of a certain format to do a 'mutantStability' run?)
				
			ligand - The path to a pdb file containing the ligand to check
Calculates the binding free-energy of a ligand to the source pdb and the compare pdbs.
Also calculates the change in binding free-energy for each to the source pdb

Parameters
comparePDBs - A list of paths to PDB files.
All the pdbs in this list will be compared to the sourcePDB.
The names of the compare pdbs are expected to conform to the following

(FIXME: Possibly only have to be of a certain format to do a 'mutantStability' run?)

The path to a pdb file containing the ligand to check
Calculates the binding free - energy of a ligand to the source pdb and the compare pdbs . Also calculates the change in binding free - energy for each to the source pdb Parameters comparePDBs - A list of paths to PDB files . All the pdbs in this list will be compared to the sourcePDB . The names of the compare pdbs are expected to conform to the following ( FIXME : Possibly only have to be of a certain format to do a ' mutantStability ' run? ) The path to a pdb file containing the ligand to check
def binding(self, comparePDBs=[], ligand=None, verbose=False):
		if len(comparePDBs) == 0:
			raise Exceptions.StabilityError, "Unable to perform stability calculation - No mutants supplied"
		pdbName = os.path.split(self.sourcePDB)[1]
		ligandName = os.path.split(ligand)[1]
		if self.environment.isRoot():
			shutil.copyfile(self.sourcePDB, os.path.join(self.directoryPath, pdbName))
			shutil.copyfile(ligand, os.path.join(self.directoryPath, ligandName))
		self.environment.wait()	
		outputFile = os.path.join(self.directoryPath, "output%d.txt" % self.environment.rank())
		outputStream = open(outputFile, "a+")
		executable = os.path.join(self.executablePath, "Uffbaps")
		self.environment.output('\n[BINDING] Running initial wild-type calculation for %s' % ligandName)
		self.environment.output('[BINDING] Using Uffbaps at %s' % self.executablePath)
		wildTypeResults = self._runBindingCalculation(pdbName, ligandName, executable, outputStream)
		self.environment.output('[BINDING] Wild-Type results - %s' % zip(UFFBAPS.bindingResultsHeaders, wildTypeResults))
		self.environment.output('\n[BINDING] Beginning mutant binding calculations \n')
		sys.stdout.flush()
		ten = int(len(comparePDBs)/10.0)
		if ten == 0:
			ten = 1
		count = 0
		rows = []
		comparePDBs = self.environment.splitArray(comparePDBs)
		for pdbFile in comparePDBs:
			if verbose:
				self.environment.output('[BINDING] Mutant %s' % os.path.split(pdbFile)[1], rootOnly=False)
			compareName = os.path.split(pdbFile)[1]
			shutil.copyfile(pdbFile, os.path.join(self.directoryPath, compareName))
			components = self._runBindingCalculation(compareName, ligandName, executable, outputStream)
			if components is not None:
				if verbose:
					self.environment.output(
						'[BINDING] Results - %s' % zip(UFFBAPS.bindingResultsHeaders, components),
						rootOnly=False)
				else:
					count = count + 1
					if count%ten == 0:
						sys.stdout.write(".")
						sys.stdout.flush()		
				row = [os.path.splitext(compareName)[0]]
				row.extend(components)	
				rows.append(row)
				os.remove(os.path.join(self.directoryPath, compareName))
		outputStream.close()
		self.environment.wait()	
		rows = self.environment.combineArray(rows)
		if self.environment.isRoot():
			headers = ['Mutations']
			headers.extend(UFFBAPS.bindingResultsHeaders)
			self.bindingMatrix = Matrix.PEATSAMatrix(rows=rows, headers=headers, name="Binding")
			deltaRows = []
			for row in rows:
				values = row[1:]
				newRow = [row[0]]
				try:
					newRow.extend(map(operator.sub, values, wildTypeResults))
					deltaRows.append(newRow)
				except:
					print 'Unable to subtract %s from %s' % (values, wildTypeResults)
			self.deltaBindingMatrix = Matrix.PEATSAMatrix(rows=deltaRows, headers=headers, name="DeltaBinding")
def binding ( self , comparePDBs = [ ] , ligand = None , verbose = False ) : if len ( comparePDBs ) == 0 : raise Exceptions . StabilityError , "Unable to perform stability calculation - No mutants supplied" pdbName = os . path . split ( self . sourcePDB ) [ 1 ] ligandName = os . path . split ( ligand ) [ 1 ] if self . environment . isRoot ( ) : shutil . copyfile ( self . sourcePDB , os . path . join ( self . directoryPath , pdbName ) ) shutil . copyfile ( ligand , os . path . join ( self . directoryPath , ligandName ) ) self . environment . wait ( ) outputFile = os . path . join ( self . directoryPath , "output%d.txt" % self . environment . rank ( ) ) outputStream = open ( outputFile , "a+" ) executable = os . path . join ( self . executablePath , "Uffbaps" ) self . environment . output ( '\n[BINDING] Running initial wild-type calculation for %s' % ligandName ) self . environment . output ( '[BINDING] Using Uffbaps at %s' % self . executablePath ) wildTypeResults = self . _runBindingCalculation ( pdbName , ligandName , executable , outputStream ) self . environment . output ( '[BINDING] Wild-Type results - %s' % zip ( UFFBAPS . bindingResultsHeaders , wildTypeResults ) ) self . environment . output ( '\n[BINDING] Beginning mutant binding calculations \n' ) sys . stdout . flush ( ) ten = int ( len ( comparePDBs ) / 10.0 ) if ten == 0 : ten = 1 count = 0 rows = [ ] comparePDBs = self . environment . splitArray ( comparePDBs ) for pdbFile in comparePDBs : if verbose : self . environment . output ( '[BINDING] Mutant %s' % os . path . split ( pdbFile ) [ 1 ] , rootOnly = False ) compareName = os . path . split ( pdbFile ) [ 1 ] shutil . copyfile ( pdbFile , os . path . join ( self . directoryPath , compareName ) ) components = self . _runBindingCalculation ( compareName , ligandName , executable , outputStream ) if components is not None : if verbose : self . environment . output ( '[BINDING] Results - %s' % zip ( UFFBAPS . bindingResultsHeaders , components ) , rootOnly = False ) else : count = count + 1 if count % ten == 0 : sys . stdout . write ( "." ) sys . stdout . flush ( ) row = [ os . path . splitext ( compareName ) [ 0 ] ] row . extend ( components ) rows . append ( row ) os . remove ( os . path . join ( self . directoryPath , compareName ) ) outputStream . close ( ) self . environment . wait ( ) rows = self . environment . combineArray ( rows ) if self . environment . isRoot ( ) : headers = [ 'Mutations' ] headers . extend ( UFFBAPS . bindingResultsHeaders ) self . bindingMatrix = Matrix . PEATSAMatrix ( rows = rows , headers = headers , name = "Binding" ) deltaRows = [ ] for row in rows : values = row [ 1 : ] newRow = [ row [ 0 ] ] try : newRow . extend ( map ( operator . sub , values , wildTypeResults ) ) deltaRows . append ( newRow ) except : print 'Unable to subtract %s from %s' % ( values , wildTypeResults ) self . deltaBindingMatrix = Matrix . PEATSAMatrix ( rows = deltaRows , headers = headers , name = "DeltaBinding" )
Calculates the binding free-energy of a ligand to the source pdb and the compare pdbs.
Calculates the binding free - energy of a ligand to the source pdb and the compare pdbs .
'''Calculates the binding free-energy of a ligand to the source pdb and the compare pdbs.
		
		Also calculates the change in binding free-energy for each to the source pdb
		
		Parameters
			comparePDBs - A list of paths to PDB files.
				All the pdbs in this list will be compared to the sourcePDB.
				The names of the compare pdbs are expected to conform to the following
				.....
				(FIXME: Possibly only have to be of a certain format to do a 'mutantStability' run?)
				
			ligand - The path to a pdb file containing the ligand to check''' #If there are no mutants supplied raise an exception #Copy the wildType and ligand to the working dir #Create the output stream #The executable #Force output of last print line - required when using "," #Variables for informing user of progress #Avoid module zero if their are less than 10 pbds #Accumulate the results for each mutation into this list #It will be used at the end to create a matrix #Copy the mutant to the working dir #Do the calculation #A ugly space is left if print is used #Add the name of the mutation and then the ligand values  #to the 'rows' variable #Get rid of the mutant pdb file we copied #This is required in order to catch if any the processes exited the  #above loop due to an exception	 #Combine all the rows #Create a delta stability matrix Gmut - Gwt #Get just the numbers #Add the residue information to a new row entry #Extend it with  (values - wildTypeResults)
self
comparePDBs
ligand
verbose