Ghost/Chemical_shift.py
def print_accessibility(self,threshold=0.15,access='total'):
		'''Plot the influence of the accessibility on dielectric constant
		It does it only for residues which nrmsd is below the threshold'''
		if access=='total':
			colomn=-3
		elif access=='backbone':
			colomn=-2
		elif access=='side chain':
			colomn=-1
		else:
			print
			print 'Usage: accessibility could take only following values:'
			print 'total'
			print 'background'
			print 'side chain'
			os._exit(0)
			
		dir_name=os.path.join(os.getcwd(),'figures/')
		file_name='%saccessibility_%s.out' %(dir_name,self.pdb)
		if not os.path.isfile(file_name):
			self.accessibility()
		if not os.path.isdir(os.path.join(os.getcwd(),'figures/')):
			os.system('mkdir figures')
		dir_name=os.path.join(os.getcwd(),'figures/')
		fd=open('%saccessibility_%s.out' %(dir_name,self.pdb),'r')
		lines=fd.readlines()
		fd.close()
		acc_total={}
		acc_side={}
		acc_back={}
		plot2D={}
		plot2D_1={}
		for line in lines:
			line=string.strip(line)
			num=string.split(line)[3]
			residue='A:'+string.zfill(num,4)
			acc_total[residue]=float(string.split(line)[-3])
			acc_back[residue]=float(string.split(line)[-2])
			acc_side[residue]=float(string.split(line)[-1])
			
		for residue in self.residues:
			if (residue in self.ultimate_distance.keys()) and (self.ultimate_distance[residue]<=threshold):
				if access=='total':
					acc=acc_total[residue]
				elif access=='backbone':
					acc=acc_back[residue]
				elif access=='side chain':
					acc=acc_side[residue]
				plot2D[acc]=self.ultimate_diel[residue]
				
				if self.ultimate_distance[residue]<=threshold/2:
					plot2D_1[acc]=self.ultimate_diel[residue]
					
		clf()
		figure(num=1,dpi=400,figsize=(10,5),frameon=False)
		grid(True)
		hold(True)
		xlabel('%s access.[A^2]'%access)
		ylabel('effective dielectric constant')
		plot(plot2D.keys(),plot2D.values(),'bo',label='%4s<NRMSD<=%4s'%(str(threshold/2),str(threshold)))
		plot(plot2D_1.keys(),plot2D_1.values(),'ro',label='NRMSD<=%4s'%str(threshold/2))
		
		file_name=dir_name+'%s_accessibility_vs_diel.png'%access
		legend()
		savefig(file_name)
		
		
		#3D plot
		X=[]
		Y=[]
		Z=[]
		X1=[]
		Y1=[]
		Z1=[]
		for residue in self.residues:
			if (residue in self.ultimate_distance.keys()) and (self.ultimate_distance[residue]<=threshold):
				if self.ultimate_distance[residue]<=threshold/2:
					X1.append(acc_back[residue])
					Z1.append(self.ultimate_diel[residue])
				else:
					X.append(acc_back[residue])
					Z.append(self.ultimate_diel[residue])
				interactions=[]
				for titgroup in self.titgroups:
					if (titgroup[:6] in self.ultimate_distance.keys()):
						if (titgroup[-3:]=='HIS') or (titgroup[-3:]=='ASP') or (titgroup[-3:]=='GLU'):
							diel=self.ultimate_diel[residue]
							interactions.append(self.dict_CS[diel][residue][titgroup])
				interactions.sort()
				for titgroup in self.titgroups:
					if interactions[0]==self.dict_CS[diel][residue][titgroup]:
						if self.ultimate_distance[residue]<=threshold/2:
							Y1.append(acc_side[titgroup[:6]])
						else:
							Y.append(acc_side[titgroup[:6]])
						break

		clf()
		import matplotlib.axes3d as p3
		fig=figure(num=1,dpi=400,figsize=(10,5),frameon=False)
		ax = p3.Axes3D(fig)
		ax.scatter3D(array(X),array(Y),array(Z),color='b')
		ax.scatter3D(array(X1),array(Y1),array(Z1),color='r')
		ax.set_xlabel('back access residue')
		ax.set_ylabel('side chain access titgroup')
		ax.set_zlabel('effective diel')
		file_name=dir_name+'3Daccessibility_vs_diel.png'
		savefig(file_name)
Plot the influence of the accessibility on dielectric constant
		It does it only for residues which nrmsd is below the threshold
Plot the influence of the accessibility on dielectric constant
It does it only for residues which nrmsd is below the threshold
Plot the influence of the accessibility on dielectric constant It does it only for residues which nrmsd is below the threshold
def print_accessibility(self,threshold=0.15,access='total'):
		if access=='total':
			colomn=-3
		elif access=='backbone':
			colomn=-2
		elif access=='side chain':
			colomn=-1
		else:
			print
			print 'Usage: accessibility could take only following values:'
			print 'total'
			print 'background'
			print 'side chain'
			os._exit(0)
		dir_name=os.path.join(os.getcwd(),'figures/')
		file_name='%saccessibility_%s.out' %(dir_name,self.pdb)
		if not os.path.isfile(file_name):
			self.accessibility()
		if not os.path.isdir(os.path.join(os.getcwd(),'figures/')):
			os.system('mkdir figures')
		dir_name=os.path.join(os.getcwd(),'figures/')
		fd=open('%saccessibility_%s.out' %(dir_name,self.pdb),'r')
		lines=fd.readlines()
		fd.close()
		acc_total={}
		acc_side={}
		acc_back={}
		plot2D={}
		plot2D_1={}
		for line in lines:
			line=string.strip(line)
			num=string.split(line)[3]
			residue='A:'+string.zfill(num,4)
			acc_total[residue]=float(string.split(line)[-3])
			acc_back[residue]=float(string.split(line)[-2])
			acc_side[residue]=float(string.split(line)[-1])
		for residue in self.residues:
			if (residue in self.ultimate_distance.keys()) and (self.ultimate_distance[residue]<=threshold):
				if access=='total':
					acc=acc_total[residue]
				elif access=='backbone':
					acc=acc_back[residue]
				elif access=='side chain':
					acc=acc_side[residue]
				plot2D[acc]=self.ultimate_diel[residue]
				if self.ultimate_distance[residue]<=threshold/2:
					plot2D_1[acc]=self.ultimate_diel[residue]
		clf()
		figure(num=1,dpi=400,figsize=(10,5),frameon=False)
		grid(True)
		hold(True)
		xlabel('%s access.[A^2]'%access)
		ylabel('effective dielectric constant')
		plot(plot2D.keys(),plot2D.values(),'bo',label='%4s<NRMSD<=%4s'%(str(threshold/2),str(threshold)))
		plot(plot2D_1.keys(),plot2D_1.values(),'ro',label='NRMSD<=%4s'%str(threshold/2))
		file_name=dir_name+'%s_accessibility_vs_diel.png'%access
		legend()
		savefig(file_name)
		X=[]
		Y=[]
		Z=[]
		X1=[]
		Y1=[]
		Z1=[]
		for residue in self.residues:
			if (residue in self.ultimate_distance.keys()) and (self.ultimate_distance[residue]<=threshold):
				if self.ultimate_distance[residue]<=threshold/2:
					X1.append(acc_back[residue])
					Z1.append(self.ultimate_diel[residue])
				else:
					X.append(acc_back[residue])
					Z.append(self.ultimate_diel[residue])
				interactions=[]
				for titgroup in self.titgroups:
					if (titgroup[:6] in self.ultimate_distance.keys()):
						if (titgroup[-3:]=='HIS') or (titgroup[-3:]=='ASP') or (titgroup[-3:]=='GLU'):
							diel=self.ultimate_diel[residue]
							interactions.append(self.dict_CS[diel][residue][titgroup])
				interactions.sort()
				for titgroup in self.titgroups:
					if interactions[0]==self.dict_CS[diel][residue][titgroup]:
						if self.ultimate_distance[residue]<=threshold/2:
							Y1.append(acc_side[titgroup[:6]])
						else:
							Y.append(acc_side[titgroup[:6]])
						break
		clf()
		import matplotlib.axes3d as p3
		fig=figure(num=1,dpi=400,figsize=(10,5),frameon=False)
		ax = p3.Axes3D(fig)
		ax.scatter3D(array(X),array(Y),array(Z),color='b')
		ax.scatter3D(array(X1),array(Y1),array(Z1),color='r')
		ax.set_xlabel('back access residue')
		ax.set_ylabel('side chain access titgroup')
		ax.set_zlabel('effective diel')
		file_name=dir_name+'3Daccessibility_vs_diel.png'
		savefig(file_name)
def print_accessibility ( self , threshold = 0.15 , access = 'total' ) : if access == 'total' : colomn = - 3 elif access == 'backbone' : colomn = - 2 elif access == 'side chain' : colomn = - 1 else : print print 'Usage: accessibility could take only following values:' print 'total' print 'background' print 'side chain' os . _exit ( 0 ) dir_name = os . path . join ( os . getcwd ( ) , 'figures/' ) file_name = '%saccessibility_%s.out' % ( dir_name , self . pdb ) if not os . path . isfile ( file_name ) : self . accessibility ( ) if not os . path . isdir ( os . path . join ( os . getcwd ( ) , 'figures/' ) ) : os . system ( 'mkdir figures' ) dir_name = os . path . join ( os . getcwd ( ) , 'figures/' ) fd = open ( '%saccessibility_%s.out' % ( dir_name , self . pdb ) , 'r' ) lines = fd . readlines ( ) fd . close ( ) acc_total = { } acc_side = { } acc_back = { } plot2D = { } plot2D_1 = { } for line in lines : line = string . strip ( line ) num = string . split ( line ) [ 3 ] residue = 'A:' + string . zfill ( num , 4 ) acc_total [ residue ] = float ( string . split ( line ) [ - 3 ] ) acc_back [ residue ] = float ( string . split ( line ) [ - 2 ] ) acc_side [ residue ] = float ( string . split ( line ) [ - 1 ] ) for residue in self . residues : if ( residue in self . ultimate_distance . keys ( ) ) and ( self . ultimate_distance [ residue ] <= threshold ) : if access == 'total' : acc = acc_total [ residue ] elif access == 'backbone' : acc = acc_back [ residue ] elif access == 'side chain' : acc = acc_side [ residue ] plot2D [ acc ] = self . ultimate_diel [ residue ] if self . ultimate_distance [ residue ] <= threshold / 2 : plot2D_1 [ acc ] = self . ultimate_diel [ residue ] clf ( ) figure ( num = 1 , dpi = 400 , figsize = ( 10 , 5 ) , frameon = False ) grid ( True ) hold ( True ) xlabel ( '%s access.[A^2]' % access ) ylabel ( 'effective dielectric constant' ) plot ( plot2D . keys ( ) , plot2D . values ( ) , 'bo' , label = '%4s<NRMSD<=%4s' % ( str ( threshold / 2 ) , str ( threshold ) ) ) plot ( plot2D_1 . keys ( ) , plot2D_1 . values ( ) , 'ro' , label = 'NRMSD<=%4s' % str ( threshold / 2 ) ) file_name = dir_name + '%s_accessibility_vs_diel.png' % access legend ( ) savefig ( file_name ) X = [ ] Y = [ ] Z = [ ] X1 = [ ] Y1 = [ ] Z1 = [ ] for residue in self . residues : if ( residue in self . ultimate_distance . keys ( ) ) and ( self . ultimate_distance [ residue ] <= threshold ) : if self . ultimate_distance [ residue ] <= threshold / 2 : X1 . append ( acc_back [ residue ] ) Z1 . append ( self . ultimate_diel [ residue ] ) else : X . append ( acc_back [ residue ] ) Z . append ( self . ultimate_diel [ residue ] ) interactions = [ ] for titgroup in self . titgroups : if ( titgroup [ : 6 ] in self . ultimate_distance . keys ( ) ) : if ( titgroup [ - 3 : ] == 'HIS' ) or ( titgroup [ - 3 : ] == 'ASP' ) or ( titgroup [ - 3 : ] == 'GLU' ) : diel = self . ultimate_diel [ residue ] interactions . append ( self . dict_CS [ diel ] [ residue ] [ titgroup ] ) interactions . sort ( ) for titgroup in self . titgroups : if interactions [ 0 ] == self . dict_CS [ diel ] [ residue ] [ titgroup ] : if self . ultimate_distance [ residue ] <= threshold / 2 : Y1 . append ( acc_side [ titgroup [ : 6 ] ] ) else : Y . append ( acc_side [ titgroup [ : 6 ] ] ) break clf ( ) import matplotlib . axes3d as p3 fig = figure ( num = 1 , dpi = 400 , figsize = ( 10 , 5 ) , frameon = False ) ax = p3 . Axes3D ( fig ) ax . scatter3D ( array ( X ) , array ( Y ) , array ( Z ) , color = 'b' ) ax . scatter3D ( array ( X1 ) , array ( Y1 ) , array ( Z1 ) , color = 'r' ) ax . set_xlabel ( 'back access residue' ) ax . set_ylabel ( 'side chain access titgroup' ) ax . set_zlabel ( 'effective diel' ) file_name = dir_name + '3Daccessibility_vs_diel.png' savefig ( file_name )
Plot the influence of the accessibility on dielectric constant
It does it only for residues which nrmsd is below the threshold
Plot the influence of the accessibility on dielectric constant It does it only for residues which nrmsd is below the threshold
'''Plot the influence of the accessibility on dielectric constant
		It does it only for residues which nrmsd is below the threshold''' #3D plot
self
threshold
access