PEATSA/Core/Programs.py
def absoluteStability(self, pdbFiles=[], verbose=False):
	
		'''Calculates the absolute stability of a number of structures
		
		FIXME: Incomplete'''
				
		#If there are no compare pdbs supplied raise an exception
		if len(pdbFiles) == 0:
			raise Exceptions.StabilityError, "Unable to perform stability calculation - No files supplied"
			
		#The run file name
		runFile = os.path.join(self.directoryPath, "run%d.txt" % self.environment.rank())
		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[STABILITY] Running absolute stability calculation for %d structures' % len(pdbFiles))
		self.environment.output('[STABILITY] Using Uffbaps at %s' % self.executablePath)
		self.environment.output('[STABILITY] Beginning stability calculation ')
		
		#Force output of last print line - required when using ","
		sys.stdout.flush()
	
		#Variables for informing user of progress
		ten = int(len(pdbFiles)/10.0)
		#Avoid module zero if their are less than 10 pbds
		if ten == 0:
			ten = 1
		count = 0
	
		#Accumulate the results for each file into this list
		#It will be used at the end to create a matrix
		rows = []
		
		#Ask the environment to split the pdbFiles array if this is a parallel run
		pdbFiles = self.environment.splitArray(pdbFiles)
		for pdbFile in pdbFiles:
			if verbose:
				self.environment.output('[STABILITY] Structure %s' % os.path.split(pdbFile)[1], rootOnly=False)
			
			#Copy the mutant to the working dir
			pdbName = os.path.split(pdbFile)[1]
			copiedFile = self.workingDirectory.copyFileToUffbapsDirectory(pdbFile)
			
			#Create the run file 
			self.__writeAbsoluteStabilityRunFile__(pdbName, filename=runFile)
			
			#Run
			process = subprocess.Popen([executable, runFile], cwd=self.directoryPath, stdout=outputStream)
			process.wait()
		
			components = self.__processAbsoluteStabilityResults__()
						
			if verbose:
				self.environment.output(
					'[STABILITY] %s' % zip(UFFBAPS.stabilityResultsHeaders, components), 
					rootOnly=False)
			
			#Add the name of the pdbFile and then the stability values 
			#to the 'rows' variable
			row = [os.path.splitext(pdbName)[0]]
			row.extend(components)	
			rows.append(row)
			
			#Reset the stream
			outputStream.seek(0)
			outputStream.truncate()
			
			#Get rid of the mutant pdb file we copied
			os.remove(os.path.join(self.directoryPath, copiedFile))
			
			if not verbose:
				count = count + 1
				if count%ten == 0:
					#A ugly space is left if print is used
					sys.stdout.write(".")
					sys.stdout.flush()
								
		outputStream.close()
		#Combine all the rows
		rows = self.environment.combineArray(rows)
		
		if self.environment.isRoot():
			headers = ['Mutations']
			headers.extend(UFFBAPS.stabilityResultsHeaders)
			self.resultsMatrix = Matrix.PEATSAMatrix(rows=rows, headers=headers, name="Stability")
	
			#Add some comments
			comments = stabilityCommentStrings[:]
			date = datetime.datetime.today()
			comments.insert(1, "Generated  by PEAT_SA on %s" % date.strftime('%A %d/%m/%Y %H:%M:%S %Z'))
Calculates the absolute stability of a number of structures
		
		FIXME: Incomplete
Calculates the absolute stability of a number of structures
FIXME: Incomplete
Calculates the absolute stability of a number of structures FIXME : Incomplete
def absoluteStability(self, pdbFiles=[], verbose=False):
		if len(pdbFiles) == 0:
			raise Exceptions.StabilityError, "Unable to perform stability calculation - No files supplied"
		runFile = os.path.join(self.directoryPath, "run%d.txt" % self.environment.rank())
		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[STABILITY] Running absolute stability calculation for %d structures' % len(pdbFiles))
		self.environment.output('[STABILITY] Using Uffbaps at %s' % self.executablePath)
		self.environment.output('[STABILITY] Beginning stability calculation ')
		sys.stdout.flush()
		ten = int(len(pdbFiles)/10.0)
		if ten == 0:
			ten = 1
		count = 0
		rows = []
		pdbFiles = self.environment.splitArray(pdbFiles)
		for pdbFile in pdbFiles:
			if verbose:
				self.environment.output('[STABILITY] Structure %s' % os.path.split(pdbFile)[1], rootOnly=False)
			pdbName = os.path.split(pdbFile)[1]
			copiedFile = self.workingDirectory.copyFileToUffbapsDirectory(pdbFile)
			self.__writeAbsoluteStabilityRunFile__(pdbName, filename=runFile)
			process = subprocess.Popen([executable, runFile], cwd=self.directoryPath, stdout=outputStream)
			process.wait()
			components = self.__processAbsoluteStabilityResults__()
			if verbose:
				self.environment.output(
					'[STABILITY] %s' % zip(UFFBAPS.stabilityResultsHeaders, components), 
					rootOnly=False)
			row = [os.path.splitext(pdbName)[0]]
			row.extend(components)	
			rows.append(row)
			outputStream.seek(0)
			outputStream.truncate()
			os.remove(os.path.join(self.directoryPath, copiedFile))
			if not verbose:
				count = count + 1
				if count%ten == 0:
					sys.stdout.write(".")
					sys.stdout.flush()
		outputStream.close()
		rows = self.environment.combineArray(rows)
		if self.environment.isRoot():
			headers = ['Mutations']
			headers.extend(UFFBAPS.stabilityResultsHeaders)
			self.resultsMatrix = Matrix.PEATSAMatrix(rows=rows, headers=headers, name="Stability")
			comments = stabilityCommentStrings[:]
			date = datetime.datetime.today()
			comments.insert(1, "Generated  by PEAT_SA on %s" % date.strftime('%A %d/%m/%Y %H:%M:%S %Z'))
def absoluteStability ( self , pdbFiles = [ ] , verbose = False ) : if len ( pdbFiles ) == 0 : raise Exceptions . StabilityError , "Unable to perform stability calculation - No files supplied" runFile = os . path . join ( self . directoryPath , "run%d.txt" % self . environment . rank ( ) ) 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[STABILITY] Running absolute stability calculation for %d structures' % len ( pdbFiles ) ) self . environment . output ( '[STABILITY] Using Uffbaps at %s' % self . executablePath ) self . environment . output ( '[STABILITY] Beginning stability calculation ' ) sys . stdout . flush ( ) ten = int ( len ( pdbFiles ) / 10.0 ) if ten == 0 : ten = 1 count = 0 rows = [ ] pdbFiles = self . environment . splitArray ( pdbFiles ) for pdbFile in pdbFiles : if verbose : self . environment . output ( '[STABILITY] Structure %s' % os . path . split ( pdbFile ) [ 1 ] , rootOnly = False ) pdbName = os . path . split ( pdbFile ) [ 1 ] copiedFile = self . workingDirectory . copyFileToUffbapsDirectory ( pdbFile ) self . __writeAbsoluteStabilityRunFile__ ( pdbName , filename = runFile ) process = subprocess . Popen ( [ executable , runFile ] , cwd = self . directoryPath , stdout = outputStream ) process . wait ( ) components = self . __processAbsoluteStabilityResults__ ( ) if verbose : self . environment . output ( '[STABILITY] %s' % zip ( UFFBAPS . stabilityResultsHeaders , components ) , rootOnly = False ) row = [ os . path . splitext ( pdbName ) [ 0 ] ] row . extend ( components ) rows . append ( row ) outputStream . seek ( 0 ) outputStream . truncate ( ) os . remove ( os . path . join ( self . directoryPath , copiedFile ) ) if not verbose : count = count + 1 if count % ten == 0 : sys . stdout . write ( "." ) sys . stdout . flush ( ) outputStream . close ( ) rows = self . environment . combineArray ( rows ) if self . environment . isRoot ( ) : headers = [ 'Mutations' ] headers . extend ( UFFBAPS . stabilityResultsHeaders ) self . resultsMatrix = Matrix . PEATSAMatrix ( rows = rows , headers = headers , name = "Stability" ) comments = stabilityCommentStrings [ : ] date = datetime . datetime . today ( ) comments . insert ( 1 , "Generated  by PEAT_SA on %s" % date . strftime ( '%A %d/%m/%Y %H:%M:%S %Z' ) )
Calculates the absolute stability of a number of structures
FIXME: Incomplete
Calculates the absolute stability of a number of structures FIXME : Incomplete
'''Calculates the absolute stability of a number of structures
		
		FIXME: Incomplete''' #If there are no compare pdbs supplied raise an exception #The run file name #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 file into this list #It will be used at the end to create a matrix #Ask the environment to split the pdbFiles array if this is a parallel run #Copy the mutant to the working dir #Create the run file  #Run #Add the name of the pdbFile and then the stability values  #to the 'rows' variable #Reset the stream #Get rid of the mutant pdb file we copied #A ugly space is left if print is used #Combine all the rows #Add some comments
self
pdbFiles
verbose