PEATSA/Core/Data.py
def MutantFromRotamerOperations(structure, operations):

	'''Convert a protool structure into a mutant using the information in operations
	
	structure: A protool instance representing a structure to be mutated
	
	operations: A list containing information on how to create a mutant relative to structure
	It is assumed this list was obtained by calling 'rotamerOperationsForMutant:() on a MutantCollection
	instance whose pdb attributed is equal to the structure object
		
	Exceptions: 
		Raises an Exceptions.MutantModellingError if an error occurs during mutant creation'''
 
 
 	mutant = copy.deepcopy(structure)
	mutationSet = mutationSetFromRotamerOperations(operations)
 
	for operation, atomCode, atomData in operations:
		if operation == 'delete':
			mutant.remove_atom(atomCode)
			
	for operation, atomCode, atomData in operations:
		if operation == 'add':
			#ParseResidueCode can also parse atom codes
			chainId, residueNumber, atomName = Utilities.ParseResidueCode(atomCode) 
			
			result = mutant.add_atom(uniqueid=atomCode,
					     atomname=atomName,
					     residuenumber=residueNumber,
					     chainid=chainId,
					     residuename=atomData['RESNAME'],
					     xcoord=atomData['X'],
					     ycoord=atomData['Y'],
					     zcoord=atomData['Z'])
				     
			if not result:
				Exceptions.MutantModellingError, mutationSet

			mutant.Update()
			# Rename the rest of the atoms
			residueCode = Utilities.CreateResidueCode(chain=chainId, number=residueNumber)
			for atom in mutant.residues[residueCode]:
				mutant.atoms[atom]['RESNAME'] = atomData['RESNAME']
			
			mutant.Update()

	return mutant
Convert a protool structure into a mutant using the information in operations
	
	structure: A protool instance representing a structure to be mutated
	
	operations: A list containing information on how to create a mutant relative to structure
	It is assumed this list was obtained by calling 'rotamerOperationsForMutant:() on a MutantCollection
	instance whose pdb attributed is equal to the structure object
		
	Exceptions: 
		Raises an Exceptions.MutantModellingError if an error occurs during mutant creation
Convert a protool structure into a mutant using the information in operations
structure: A protool instance representing a structure to be mutated

A list containing information on how to create a mutant relative to structure
It is assumed this list was obtained by calling 'rotamerOperationsForMutant:() on a MutantCollection
instance whose pdb attributed is equal to the structure object

Raises an Exceptions.MutantModellingError if an error occurs during mutant creation
Convert a protool structure into a mutant using the information in operations structure : A protool instance representing a structure to be mutated A list containing information on how to create a mutant relative to structure It is assumed this list was obtained by calling ' rotamerOperationsForMutant : () on a MutantCollection instance whose pdb attributed is equal to the structure object Raises an Exceptions . MutantModellingError if an error occurs during mutant creation
def MutantFromRotamerOperations(structure, operations):
 	mutant = copy.deepcopy(structure)
	mutationSet = mutationSetFromRotamerOperations(operations)
	for operation, atomCode, atomData in operations:
		if operation == 'delete':
			mutant.remove_atom(atomCode)
	for operation, atomCode, atomData in operations:
		if operation == 'add':
			chainId, residueNumber, atomName = Utilities.ParseResidueCode(atomCode) 
			result = mutant.add_atom(uniqueid=atomCode,
					     atomname=atomName,
					     residuenumber=residueNumber,
					     chainid=chainId,
					     residuename=atomData['RESNAME'],
					     xcoord=atomData['X'],
					     ycoord=atomData['Y'],
					     zcoord=atomData['Z'])
			if not result:
				Exceptions.MutantModellingError, mutationSet
			mutant.Update()
			residueCode = Utilities.CreateResidueCode(chain=chainId, number=residueNumber)
			for atom in mutant.residues[residueCode]:
				mutant.atoms[atom]['RESNAME'] = atomData['RESNAME']
			mutant.Update()
	return mutant
def MutantFromRotamerOperations ( structure , operations ) : mutant = copy . deepcopy ( structure ) mutationSet = mutationSetFromRotamerOperations ( operations ) for operation , atomCode , atomData in operations : if operation == 'delete' : mutant . remove_atom ( atomCode ) for operation , atomCode , atomData in operations : if operation == 'add' : chainId , residueNumber , atomName = Utilities . ParseResidueCode ( atomCode ) result = mutant . add_atom ( uniqueid = atomCode , atomname = atomName , residuenumber = residueNumber , chainid = chainId , residuename = atomData [ 'RESNAME' ] , xcoord = atomData [ 'X' ] , ycoord = atomData [ 'Y' ] , zcoord = atomData [ 'Z' ] ) if not result : Exceptions . MutantModellingError , mutationSet mutant . Update ( ) residueCode = Utilities . CreateResidueCode ( chain = chainId , number = residueNumber ) for atom in mutant . residues [ residueCode ] : mutant . atoms [ atom ] [ 'RESNAME' ] = atomData [ 'RESNAME' ] mutant . Update ( ) return mutant
Convert a protool structure into a mutant using the information in operations
structure: A protool instance representing a structure to be mutated
Convert a protool structure into a mutant using the information in operations structure : A protool instance representing a structure to be mutated
'''Convert a protool structure into a mutant using the information in operations
	
	structure: A protool instance representing a structure to be mutated
	
	operations: A list containing information on how to create a mutant relative to structure
	It is assumed this list was obtained by calling 'rotamerOperationsForMutant:() on a MutantCollection
	instance whose pdb attributed is equal to the structure object
		
	Exceptions: 
		Raises an Exceptions.MutantModellingError if an error occurs during mutant creation''' #ParseResidueCode can also parse atom codes # Rename the rest of the atoms
structure
operations