PEATSA/Core/Data.py
def applyToSequence(self, wildTypeSequence, id='A', pdb=None, offset=None):

		'''Applies the mutations defined by the receiver to wildTypeSequence
		
		Note: wildTypeSequence must correspond to a single chain which is specified by id
		Also sequence are assumed to have a 1 offset.
		Thus the mutation A1A is applied to element 0 of wildTypeSequence
		
		Parameters:
			wildTypeSequence: A string of one letter amino-acid codes
			
			chain: The chain the sequence corresponds to.
				Defauts to A.

			pdb: Optional. A protool instance of a pdb containing the chain
			corresponding to wild-type sequence. If this is not None the wild-type
			residue from the pdb is compared to that in the supplied sequence
			and an exception is raised if the two are not the same.

			offset: Number such that (seqResidue + offset = pdbResidue)
			If None it is equal to the number of the first residue in the pdb if supplied
			If the pdb is None it defaults to 1
			
		Returns: 
			The mutant sequence'''

		if pdb is not None and offset is None:
			res = GetChainResidues(pdb)[id][0]
			chain, index = Utilities.ParseResidueCode(res)
			offset = index
		elif offset is None:
			offset = -1
			
		seq = list(wildTypeSequence)	
		for code in self.mutationCodes(pdb=pdb):
			components = Utilities.ParseMutationCode(code)
			if components[0] == id:
				if pdb is not None:
					chain, index, wt, mut = components
					#Check the wt res defined by the sequence is the
					#same as that defined by the pdb
					if seq[index - offset] == Utilities.aminoAcidCodes[wt]:
						seq[index - offset] =  Utilities.aminoAcidCodes[mut]
					else:
						message = 'Residue in pdb does not correspond to reside in sequence (%s %s)' % (Utilities.aminoAcidCodes[wt], seq[index - offset])
						raise Exceptions.MutationCodeApplicationError(mutationCode=code, message=message)
				else:
					chain, index, mut = components
					seq[index - offset] = Utilities.aminoAcidCodes[mut]
				
		return "".join(seq)
Applies the mutations defined by the receiver to wildTypeSequence
		
		Note: wildTypeSequence must correspond to a single chain which is specified by id
		Also sequence are assumed to have a 1 offset.
		Thus the mutation A1A is applied to element 0 of wildTypeSequence
		
		Parameters:
			wildTypeSequence: A string of one letter amino-acid codes
			
			chain: The chain the sequence corresponds to.
				Defauts to A.

			pdb: Optional. A protool instance of a pdb containing the chain
			corresponding to wild-type sequence. If this is not None the wild-type
			residue from the pdb is compared to that in the supplied sequence
			and an exception is raised if the two are not the same.

			offset: Number such that (seqResidue + offset = pdbResidue)
			If None it is equal to the number of the first residue in the pdb if supplied
			If the pdb is None it defaults to 1
			
		Returns: 
			The mutant sequence
Applies the mutations defined by the receiver to wildTypeSequence
Note: wildTypeSequence must correspond to a single chain which is specified by id
Also sequence are assumed to have a 1 offset.
Thus the mutation A1A is applied to element 0 of wildTypeSequence

A string of one letter amino-acid codes

The chain the sequence corresponds to.
Defauts to A.

Optional. A protool instance of a pdb containing the chain
corresponding to wild-type sequence. If this is not None the wild-type
residue from the pdb is compared to that in the supplied sequence
and an exception is raised if the two are not the same.

Number such that (seqResidue + offset = pdbResidue)
If None it is equal to the number of the first residue in the pdb if supplied
If the pdb is None it defaults to 1

The mutant sequence
Applies the mutations defined by the receiver to wildTypeSequence Note : wildTypeSequence must correspond to a single chain which is specified by id Also sequence are assumed to have a 1 offset . Thus the mutation A1A is applied to element 0 of wildTypeSequence A string of one letter amino - acid codes The chain the sequence corresponds to . Defauts to A . Optional . A protool instance of a pdb containing the chain corresponding to wild - type sequence . If this is not None the wild - type residue from the pdb is compared to that in the supplied sequence and an exception is raised if the two are not the same . Number such that ( seqResidue + offset = pdbResidue ) If None it is equal to the number of the first residue in the pdb if supplied If the pdb is None it defaults to 1 The mutant sequence
def applyToSequence(self, wildTypeSequence, id='A', pdb=None, offset=None):
		if pdb is not None and offset is None:
			res = GetChainResidues(pdb)[id][0]
			chain, index = Utilities.ParseResidueCode(res)
			offset = index
		elif offset is None:
			offset = -1
		seq = list(wildTypeSequence)	
		for code in self.mutationCodes(pdb=pdb):
			components = Utilities.ParseMutationCode(code)
			if components[0] == id:
				if pdb is not None:
					chain, index, wt, mut = components
					if seq[index - offset] == Utilities.aminoAcidCodes[wt]:
						seq[index - offset] =  Utilities.aminoAcidCodes[mut]
					else:
						message = 'Residue in pdb does not correspond to reside in sequence (%s %s)' % (Utilities.aminoAcidCodes[wt], seq[index - offset])
						raise Exceptions.MutationCodeApplicationError(mutationCode=code, message=message)
				else:
					chain, index, mut = components
					seq[index - offset] = Utilities.aminoAcidCodes[mut]
		return "".join(seq)
def applyToSequence ( self , wildTypeSequence , id = 'A' , pdb = None , offset = None ) : if pdb is not None and offset is None : res = GetChainResidues ( pdb ) [ id ] [ 0 ] chain , index = Utilities . ParseResidueCode ( res ) offset = index elif offset is None : offset = - 1 seq = list ( wildTypeSequence ) for code in self . mutationCodes ( pdb = pdb ) : components = Utilities . ParseMutationCode ( code ) if components [ 0 ] == id : if pdb is not None : chain , index , wt , mut = components if seq [ index - offset ] == Utilities . aminoAcidCodes [ wt ] : seq [ index - offset ] = Utilities . aminoAcidCodes [ mut ] else : message = 'Residue in pdb does not correspond to reside in sequence (%s %s)' % ( Utilities . aminoAcidCodes [ wt ] , seq [ index - offset ] ) raise Exceptions . MutationCodeApplicationError ( mutationCode = code , message = message ) else : chain , index , mut = components seq [ index - offset ] = Utilities . aminoAcidCodes [ mut ] return "" . join ( seq )
Applies the mutations defined by the receiver to wildTypeSequence
Note: wildTypeSequence must correspond to a single chain which is specified by id
Also sequence are assumed to have a 1 offset.
Applies the mutations defined by the receiver to wildTypeSequence Note : wildTypeSequence must correspond to a single chain which is specified by id Also sequence are assumed to have a 1 offset .
'''Applies the mutations defined by the receiver to wildTypeSequence
		
		Note: wildTypeSequence must correspond to a single chain which is specified by id
		Also sequence are assumed to have a 1 offset.
		Thus the mutation A1A is applied to element 0 of wildTypeSequence
		
		Parameters:
			wildTypeSequence: A string of one letter amino-acid codes
			
			chain: The chain the sequence corresponds to.
				Defauts to A.

			pdb: Optional. A protool instance of a pdb containing the chain
			corresponding to wild-type sequence. If this is not None the wild-type
			residue from the pdb is compared to that in the supplied sequence
			and an exception is raised if the two are not the same.

			offset: Number such that (seqResidue + offset = pdbResidue)
			If None it is equal to the number of the first residue in the pdb if supplied
			If the pdb is None it defaults to 1
			
		Returns: 
			The mutant sequence''' #Check the wt res defined by the sequence is the #same as that defined by the pdb
self
wildTypeSequence
id
pdb
offset