PEATSA/Core/Data.py
def createMutants(self, mutationList=[]):
	
		'''Creates all the mutants represented by the MutationSet instances in mutationList and adds them to the collection.
		
		If modelling a mutant fails it is skipped - see mutationList() for more.
		Note: The default naming of the MutationSets is overridden by the naming scheme of the receiver which is
		set on initialisation'''
	
		print 'Creating mutants'
		#Redirect any whatif output to a log file
		filename = os.path.join(self.location, 'Mutate.log')
		mutateLog = open(filename, 'a+')
		standardOut = sys.stdout
		standardError = sys.stderr
		sys.stdout = mutateLog		
		standardOut.flush()
		
		if len(mutationList) == 0:
			raise Exceptions.MutantCollectionError, 'Cannot create mutants - No mutations provided'
		
		filenames = []
		failedMutants = []
		qualities = []
		operations = {}
		
		location = os.path.join(self.location, 'Mutants')
		listFragment = self.environment.splitArray(mutationList)
	
		for element in listFragment:
			#Set the element naming to the default
			element.reducedDefault = self.useReducedNaming
			self.environment.output('[MUTATE] (%d) Next element %s\n' % (self.environment.rank(), element), 
				stream=standardOut, rootOnly=False)
			try:
				self._createMutant(element, location, filenames, 
					failedMutants, qualities, operations, standardOut)
			except KeyboardInterrupt:
				raise
			except Exception, data:
				name = element.codeString(pdb=self.pdb, reduced=False)		
				self.environment.output('[MUTATE] Unable to create mutant %s. Encountered exception - Reason %s\n' % (name, data), 
					stream=standardOut,
					rootOnly=False)	
				failedMutants.append(name)	
				self.environment.output('[MUTATE] Traceback %s' % Utilities.GetTraceback(), 
					stream=standardOut,
					rootOnly=False)
			except BaseException, data:
				self.environment.output('Caught base exception %s %s' % (BaseException, data), 
					stream=standardOut, rootOnly=False)
				standardOut.flush()
				raise
			except:
				self.environment.output('Caught unknown exception (%d)' % self.envrionment.rank(), 
					stream=standardOut, rootOnly=False)
				raise	
				
			self.environment.output('[MUTATE] Process rank %d has processed %d mutants: %d failures, %d left\n' % (self.environment.rank(), len(filenames), len(failedMutants), len(listFragment) - len(filenames) - len(failedMutants)), stream=standardOut, rootOnly=False) 
			standardOut.flush()
			
		#This is required in order to catch if any the processes exited the 
		#above loop due to an exception	
		self.environment.wait()			
		
		#Combine arrays & dictionaries
		filenames = self.environment.combineArray(filenames)
		failedMutants = self.environment.combineArray(failedMutants)	
		qualities = self.environment.combineArray(qualities)
		operations = self.environment.combineDictionary(operations)
		
		noFailures = len(failedMutants)
		noSuccesses = len(filenames)
		if noFailures is not 0:
			self.environment.output('[MUTATE] Failed to model %d of %d mutations\n' % (noFailures, noSuccesses + noFailures),
						stream=standardError)	
			self.environment.output('[MUTATE] Failures = %s\n' % " ".join(failedMutants), stream=standardError)			
			self.environment.output('[MUTATE] Check Mutation.log for details\n', stream=standardError)
		
		mutateLog.close()
		sys.stdout = standardOut	
		self.collection.extend(filenames)
		
		#Update the mutationList ivar - Filter out the failed mutants
		mutationList = filter(lambda x:  x.codeString(self.pdb, reduced=False) not in failedMutants, mutationList)
		
		self.mutationList.extend(copy.deepcopy(mutationList))
		self._updateMutationList()
		self.environment.output('[MUTATE] Done: %s' % self.__str__()) 
		
		#Update scores matrix
		if self.mutationScores is None:
			self.mutationScores = Matrix.PEATSAMatrix(rows=qualities,
						 headers=['Mutations', 'Score', 'Result'])
		else:				 
			for row in qualities:
				self.mutationScores.addRow(row)
		
		#Write scores
		f = open(os.path.join(self.location, 'Scores.csv'), 'w+')		
		f.write(self.mutationScores.csvRepresentation())
		f.close()
		
		#Update the operations dict
		self.mutationOperations.update(operations)
		self._updateMutationOperations()
Creates all the mutants represented by the MutationSet instances in mutationList and adds them to the collection.
		
		If modelling a mutant fails it is skipped - see mutationList() for more.
		Note: The default naming of the MutationSets is overridden by the naming scheme of the receiver which is
		set on initialisation
Creates all the mutants represented by the MutationSet instances in mutationList and adds them to the collection.
If modelling a mutant fails it is skipped - see mutationList() for more.
Note: The default naming of the MutationSets is overridden by the naming scheme of the receiver which is
set on initialisation
Creates all the mutants represented by the MutationSet instances in mutationList and adds them to the collection . If modelling a mutant fails it is skipped - see mutationList () for more . Note : The default naming of the MutationSets is overridden by the naming scheme of the receiver which is set on initialisation
def createMutants(self, mutationList=[]):
		print 'Creating mutants'
		filename = os.path.join(self.location, 'Mutate.log')
		mutateLog = open(filename, 'a+')
		standardOut = sys.stdout
		standardError = sys.stderr
		sys.stdout = mutateLog		
		standardOut.flush()
		if len(mutationList) == 0:
			raise Exceptions.MutantCollectionError, 'Cannot create mutants - No mutations provided'
		filenames = []
		failedMutants = []
		qualities = []
		operations = {}
		location = os.path.join(self.location, 'Mutants')
		listFragment = self.environment.splitArray(mutationList)
		for element in listFragment:
			element.reducedDefault = self.useReducedNaming
			self.environment.output('[MUTATE] (%d) Next element %s\n' % (self.environment.rank(), element), 
				stream=standardOut, rootOnly=False)
			try:
				self._createMutant(element, location, filenames, 
					failedMutants, qualities, operations, standardOut)
			except KeyboardInterrupt:
				raise
			except Exception, data:
				name = element.codeString(pdb=self.pdb, reduced=False)		
				self.environment.output('[MUTATE] Unable to create mutant %s. Encountered exception - Reason %s\n' % (name, data), 
					stream=standardOut,
					rootOnly=False)	
				failedMutants.append(name)	
				self.environment.output('[MUTATE] Traceback %s' % Utilities.GetTraceback(), 
					stream=standardOut,
					rootOnly=False)
			except BaseException, data:
				self.environment.output('Caught base exception %s %s' % (BaseException, data), 
					stream=standardOut, rootOnly=False)
				standardOut.flush()
				raise
			except:
				self.environment.output('Caught unknown exception (%d)' % self.envrionment.rank(), 
					stream=standardOut, rootOnly=False)
				raise	
			self.environment.output('[MUTATE] Process rank %d has processed %d mutants: %d failures, %d left\n' % (self.environment.rank(), len(filenames), len(failedMutants), len(listFragment) - len(filenames) - len(failedMutants)), stream=standardOut, rootOnly=False) 
			standardOut.flush()
		self.environment.wait()			
		filenames = self.environment.combineArray(filenames)
		failedMutants = self.environment.combineArray(failedMutants)	
		qualities = self.environment.combineArray(qualities)
		operations = self.environment.combineDictionary(operations)
		noFailures = len(failedMutants)
		noSuccesses = len(filenames)
		if noFailures is not 0:
			self.environment.output('[MUTATE] Failed to model %d of %d mutations\n' % (noFailures, noSuccesses + noFailures),
						stream=standardError)	
			self.environment.output('[MUTATE] Failures = %s\n' % " ".join(failedMutants), stream=standardError)			
			self.environment.output('[MUTATE] Check Mutation.log for details\n', stream=standardError)
		mutateLog.close()
		sys.stdout = standardOut	
		self.collection.extend(filenames)
		mutationList = filter(lambda x:  x.codeString(self.pdb, reduced=False) not in failedMutants, mutationList)
		self.mutationList.extend(copy.deepcopy(mutationList))
		self._updateMutationList()
		self.environment.output('[MUTATE] Done: %s' % self.__str__()) 
		if self.mutationScores is None:
			self.mutationScores = Matrix.PEATSAMatrix(rows=qualities,
						 headers=['Mutations', 'Score', 'Result'])
		else:				 
			for row in qualities:
				self.mutationScores.addRow(row)
		f = open(os.path.join(self.location, 'Scores.csv'), 'w+')		
		f.write(self.mutationScores.csvRepresentation())
		f.close()
		self.mutationOperations.update(operations)
		self._updateMutationOperations()
def createMutants ( self , mutationList = [ ] ) : print 'Creating mutants' filename = os . path . join ( self . location , 'Mutate.log' ) mutateLog = open ( filename , 'a+' ) standardOut = sys . stdout standardError = sys . stderr sys . stdout = mutateLog standardOut . flush ( ) if len ( mutationList ) == 0 : raise Exceptions . MutantCollectionError , 'Cannot create mutants - No mutations provided' filenames = [ ] failedMutants = [ ] qualities = [ ] operations = { } location = os . path . join ( self . location , 'Mutants' ) listFragment = self . environment . splitArray ( mutationList ) for element in listFragment : element . reducedDefault = self . useReducedNaming self . environment . output ( '[MUTATE] (%d) Next element %s\n' % ( self . environment . rank ( ) , element ) , stream = standardOut , rootOnly = False ) try : self . _createMutant ( element , location , filenames , failedMutants , qualities , operations , standardOut ) except KeyboardInterrupt : raise except Exception , data : name = element . codeString ( pdb = self . pdb , reduced = False ) self . environment . output ( '[MUTATE] Unable to create mutant %s. Encountered exception - Reason %s\n' % ( name , data ) , stream = standardOut , rootOnly = False ) failedMutants . append ( name ) self . environment . output ( '[MUTATE] Traceback %s' % Utilities . GetTraceback ( ) , stream = standardOut , rootOnly = False ) except BaseException , data : self . environment . output ( 'Caught base exception %s %s' % ( BaseException , data ) , stream = standardOut , rootOnly = False ) standardOut . flush ( ) raise except : self . environment . output ( 'Caught unknown exception (%d)' % self . envrionment . rank ( ) , stream = standardOut , rootOnly = False ) raise self . environment . output ( '[MUTATE] Process rank %d has processed %d mutants: %d failures, %d left\n' % ( self . environment . rank ( ) , len ( filenames ) , len ( failedMutants ) , len ( listFragment ) - len ( filenames ) - len ( failedMutants ) ) , stream = standardOut , rootOnly = False ) standardOut . flush ( ) self . environment . wait ( ) filenames = self . environment . combineArray ( filenames ) failedMutants = self . environment . combineArray ( failedMutants ) qualities = self . environment . combineArray ( qualities ) operations = self . environment . combineDictionary ( operations ) noFailures = len ( failedMutants ) noSuccesses = len ( filenames ) if noFailures is not 0 : self . environment . output ( '[MUTATE] Failed to model %d of %d mutations\n' % ( noFailures , noSuccesses + noFailures ) , stream = standardError ) self . environment . output ( '[MUTATE] Failures = %s\n' % " " . join ( failedMutants ) , stream = standardError ) self . environment . output ( '[MUTATE] Check Mutation.log for details\n' , stream = standardError ) mutateLog . close ( ) sys . stdout = standardOut self . collection . extend ( filenames ) mutationList = filter ( lambda x : x . codeString ( self . pdb , reduced = False ) not in failedMutants , mutationList ) self . mutationList . extend ( copy . deepcopy ( mutationList ) ) self . _updateMutationList ( ) self . environment . output ( '[MUTATE] Done: %s' % self . __str__ ( ) ) if self . mutationScores is None : self . mutationScores = Matrix . PEATSAMatrix ( rows = qualities , headers = [ 'Mutations' , 'Score' , 'Result' ] ) else : for row in qualities : self . mutationScores . addRow ( row ) f = open ( os . path . join ( self . location , 'Scores.csv' ) , 'w+' ) f . write ( self . mutationScores . csvRepresentation ( ) ) f . close ( ) self . mutationOperations . update ( operations ) self . _updateMutationOperations ( )
Creates all the mutants represented by the MutationSet instances in mutationList and adds them to the collection.
Creates all the mutants represented by the MutationSet instances in mutationList and adds them to the collection .
'''Creates all the mutants represented by the MutationSet instances in mutationList and adds them to the collection.
		
		If modelling a mutant fails it is skipped - see mutationList() for more.
		Note: The default naming of the MutationSets is overridden by the naming scheme of the receiver which is
		set on initialisation''' #Redirect any whatif output to a log file #Set the element naming to the default #This is required in order to catch if any the processes exited the  #above loop due to an exception	 #Combine arrays & dictionaries #Update the mutationList ivar - Filter out the failed mutants #Update scores matrix #Write scores #Update the operations dict
self
mutationList