PEATDB/DNAtool/Restriction_Digest_driver.py
def plot_restriction_sites(self,cut_pos,colour='black',direction='up',add_text='',
			temporary=None,delete_temporary=1,underline_unique=1):
		"""
		Plot all restriction sites in enzymes
		"""
		enzymes=cut_pos.keys()  #enzyme names, for string label of each site

		#
		# Control vars
		#
		if not getattr(self,'new_seq_win_objs',None):
			self.new_seq_win_objs={}
		#
		step=0
		colour_cycle=[colour]#,'green','magenta','cyan','blue']
		
		# Keep track of all the sites we plot
		
		if not getattr(self,'donepos',None):
			self.donepos={}
		if not getattr(self,'temp_sites',None):
			self.temp_sites={}
			self.temp_objs={}
		
		# Delete all temporary sites from last time
		
		if delete_temporary:
			for obj in self.temp_objs.keys():
				self.seqframe.delete(obj)
			self.temp_objs={}
			
			# Remove the influence of the tempsites on self.donepos			
			for site in self.temp_sites.keys():
				self.donepos[site]=self.donepos[site]-self.temp_sites[site]
			#
			self.temp_sites={}
		
		# Plot up or down?
		
		if direction=='up':
			operator=-1
			base_shift=0
			y_org_shift=0
		else:
			# Down
			operator=1
			base_shift=60
			y_org_shift=10
		#
		#List for storing restr. label objects
		#
		if not getattr(self,'sites',None):
			self.sites=list()
		if not getattr(self,'tempsites',None):
			self.tempsites=list()

		i=0
		#
		# Main Loop
		#
		for enzyme in enzymes:
			positions=cut_pos[enzyme]
			for site in positions:
				#print site
				for subsite in site:
					#print subsite
					x,y=self.get_base_pos_on_screen(subsite+1)
					yorg=y # Store org y position as end-point for line
					yorg=yorg+y_org_shift
					#Apply the base shift for drawing upside or downside
					y=y+base_shift

					# If a comparison sequence is loaded raise more
					if self.show_comp_sequence.get()==1:
						if direction=='up':
							if self.maxseqlevel==0:
								y=(y-15)/self.y_scale
							else:
								y=y-(self.maxseqlevel*15)/self.y_scale
							if self.primer_displayed==1 and self.maxseqlevel>0:
								y=(y-15)/self.y_scale
						else:
							y=(y-15)*self.y_scale

					maxlevel=self.canvas_height-50
					#determine if more than one cut at this site
					l=15
					level=1
					if self.donepos.has_key(subsite):
					   if self.donepos[subsite]>1:
							y=y+l*operator
							level=level+1

					#iterate over donepos to see if nearby sites, and if so shift up
					for donesite in self.donepos.keys():
							if abs(donesite-subsite)<15:
								y=y+l*operator
								level=level+1
					#
					# Should we only show unique sites?
					#
					if self.show_only_unique_sites.get()==1 and len(positions)>1:
						continue
					#
					# Maximum number of sites (other than the unique site button)
					#
					if len(positions)<=self.max_num_sites.get() or self.max_num_sites.get()==100:
						#
						# Select colour
						#
						col=colour_cycle[step]
						step=step+1
						if step==len(colour_cycle):
							step=0

						# Underline unique sites
						font = self.restr_font.get() + " 10"
						uniquetag='nu'
						if underline_unique:
							if len(positions)==1:
								uniquetag='u'
								font=font+' underline'
						
						# Draw site/enzyme label here
						
						obj=self.seqframe.create_text(x,(y-45)/self.y_scale,text=enzyme+add_text,
										activefill='red',font=font,anchor='sw',fill=col,
										tags=('textlabel',uniquetag,level,enzyme+add_text,subsite))

						if temporary:
							self.temp_objs[obj]=1
						else:
							self.new_seq_win_objs[obj]=1
						
						# Keep track of where we've plotted everything						
						if not self.donepos.has_key(subsite):
							self.donepos[subsite]=0
						self.donepos[subsite]=self.donepos[subsite]+1
						#
						if temporary:
							if not self.temp_sites.has_key(subsite):
								self.temp_sites[subsite]=0
							self.temp_sites[subsite]=self.temp_sites[subsite]+1

						#add site text item to list of those currently on canvas
						#if not temporary:
						#	self.sites.append(obj)


		#try to tidy up labels on canvas - testing
		self.tidy_restriction_labels(direction,temporary,underline_unique)
		
		# Restriction details?		
		self.restriction_details()
		return

		Plot all restriction sites in enzymes
		
Plot all restriction sites in enzymes
Plot all restriction sites in enzymes
def plot_restriction_sites(self,cut_pos,colour='black',direction='up',add_text='',
			temporary=None,delete_temporary=1,underline_unique=1):
		enzymes=cut_pos.keys()  
		 Control vars
		if not getattr(self,'new_seq_win_objs',None):
			self.new_seq_win_objs={}
		step=0
		colour_cycle=[colour],'green','magenta','cyan','blue']
		 Keep track of all the sites we plot
		if not getattr(self,'donepos',None):
			self.donepos={}
		if not getattr(self,'temp_sites',None):
			self.temp_sites={}
			self.temp_objs={}
		 Delete all temporary sites from last time
		if delete_temporary:
			for obj in self.temp_objs.keys():
				self.seqframe.delete(obj)
			self.temp_objs={}
			 Remove the influence of the tempsites on self.donepos			
			for site in self.temp_sites.keys():
				self.donepos[site]=self.donepos[site]-self.temp_sites[site]
			self.temp_sites={}
		 Plot up or down?
		if direction=='up':
			operator=-1
			base_shift=0
			y_org_shift=0
		else:
			 Down
			operator=1
			base_shift=60
			y_org_shift=10
		List for storing restr. label objects
		if not getattr(self,'sites',None):
			self.sites=list()
		if not getattr(self,'tempsites',None):
			self.tempsites=list()
		i=0
		 Main Loop
		for enzyme in enzymes:
			positions=cut_pos[enzyme]
			for site in positions:
				print site
				for subsite in site:
					print subsite
					x,y=self.get_base_pos_on_screen(subsite+1)
					yorg=y  Store org y position as end-point for line
					yorg=yorg+y_org_shift
					Apply the base shift for drawing upside or downside
					y=y+base_shift
					 If a comparison sequence is loaded raise more
					if self.show_comp_sequence.get()==1:
						if direction=='up':
							if self.maxseqlevel==0:
								y=(y-15)/self.y_scale
							else:
								y=y-(self.maxseqlevel*15)/self.y_scale
							if self.primer_displayed==1 and self.maxseqlevel>0:
								y=(y-15)/self.y_scale
						else:
							y=(y-15)*self.y_scale
					maxlevel=self.canvas_height-50
					determine if more than one cut at this site
					l=15
					level=1
					if self.donepos.has_key(subsite):
					   if self.donepos[subsite]>1:
							y=y+l*operator
							level=level+1
					iterate over donepos to see if nearby sites, and if so shift up
					for donesite in self.donepos.keys():
							if abs(donesite-subsite)<15:
								y=y+l*operator
								level=level+1
					 Should we only show unique sites?
					if self.show_only_unique_sites.get()==1 and len(positions)>1:
						continue
					 Maximum number of sites (other than the unique site button)
					if len(positions)<=self.max_num_sites.get() or self.max_num_sites.get()==100:
						 Select colour
						col=colour_cycle[step]
						step=step+1
						if step==len(colour_cycle):
							step=0
						 Underline unique sites
						font = self.restr_font.get() + " 10"
						uniquetag='nu'
						if underline_unique:
							if len(positions)==1:
								uniquetag='u'
								font=font+' underline'
						 Draw site/enzyme label here
						obj=self.seqframe.create_text(x,(y-45)/self.y_scale,text=enzyme+add_text,
										activefill='red',font=font,anchor='sw',fill=col,
										tags=('textlabel',uniquetag,level,enzyme+add_text,subsite))
						if temporary:
							self.temp_objs[obj]=1
						else:
							self.new_seq_win_objs[obj]=1
						 Keep track of where we've plotted everything						
						if not self.donepos.has_key(subsite):
							self.donepos[subsite]=0
						self.donepos[subsite]=self.donepos[subsite]+1
						if temporary:
							if not self.temp_sites.has_key(subsite):
								self.temp_sites[subsite]=0
							self.temp_sites[subsite]=self.temp_sites[subsite]+1
						add site text item to list of those currently on canvas
						if not temporary:
							self.sites.append(obj)
		try to tidy up labels on canvas - testing
		self.tidy_restriction_labels(direction,temporary,underline_unique)
		 Restriction details?		
		self.restriction_details()
		return
def plot_restriction_sites ( self , cut_pos , colour = 'black' , direction = 'up' , add_text = '' , temporary = None , delete_temporary = 1 , underline_unique = 1 ) : enzymes = cut_pos . keys ( ) if not getattr ( self , 'new_seq_win_objs' , None ) : self . new_seq_win_objs = { } step = 0 colour_cycle = [ colour ] if not getattr ( self , 'donepos' , None ) : self . donepos = { } if not getattr ( self , 'temp_sites' , None ) : self . temp_sites = { } self . temp_objs = { } if delete_temporary : for obj in self . temp_objs . keys ( ) : self . seqframe . delete ( obj ) self . temp_objs = { } for site in self . temp_sites . keys ( ) : self . donepos [ site ] = self . donepos [ site ] - self . temp_sites [ site ] self . temp_sites = { } if direction == 'up' : operator = - 1 base_shift = 0 y_org_shift = 0 else : operator = 1 base_shift = 60 y_org_shift = 10 if not getattr ( self , 'sites' , None ) : self . sites = list ( ) if not getattr ( self , 'tempsites' , None ) : self . tempsites = list ( ) i = 0 for enzyme in enzymes : positions = cut_pos [ enzyme ] for site in positions : for subsite in site : x , y = self . get_base_pos_on_screen ( subsite + 1 ) yorg = y yorg = yorg + y_org_shift y = y + base_shift if self . show_comp_sequence . get ( ) == 1 : if direction == 'up' : if self . maxseqlevel == 0 : y = ( y - 15 ) / self . y_scale else : y = y - ( self . maxseqlevel * 15 ) / self . y_scale if self . primer_displayed == 1 and self . maxseqlevel > 0 : y = ( y - 15 ) / self . y_scale else : y = ( y - 15 ) * self . y_scale maxlevel = self . canvas_height - 50 l = 15 level = 1 if self . donepos . has_key ( subsite ) : if self . donepos [ subsite ] > 1 : y = y + l * operator level = level + 1 for donesite in self . donepos . keys ( ) : if abs ( donesite - subsite ) < 15 : y = y + l * operator level = level + 1 if self . show_only_unique_sites . get ( ) == 1 and len ( positions ) > 1 : continue if len ( positions ) <= self . max_num_sites . get ( ) or self . max_num_sites . get ( ) == 100 : col = colour_cycle [ step ] step = step + 1 if step == len ( colour_cycle ) : step = 0 font = self . restr_font . get ( ) + " 10" uniquetag = 'nu' if underline_unique : if len ( positions ) == 1 : uniquetag = 'u' font = font + ' underline' obj = self . seqframe . create_text ( x , ( y - 45 ) / self . y_scale , text = enzyme + add_text , activefill = 'red' , font = font , anchor = 'sw' , fill = col , tags = ( 'textlabel' , uniquetag , level , enzyme + add_text , subsite ) ) if temporary : self . temp_objs [ obj ] = 1 else : self . new_seq_win_objs [ obj ] = 1 if not self . donepos . has_key ( subsite ) : self . donepos [ subsite ] = 0 self . donepos [ subsite ] = self . donepos [ subsite ] + 1 if temporary : if not self . temp_sites . has_key ( subsite ) : self . temp_sites [ subsite ] = 0 self . temp_sites [ subsite ] = self . temp_sites [ subsite ] + 1 self . tidy_restriction_labels ( direction , temporary , underline_unique ) self . restriction_details ( ) return
Plot all restriction sites in enzymes
Plot all restriction sites in enzymes
"""
		Plot all restriction sites in enzymes
		""" #enzyme names, for string label of each site # # Control vars # # #,'green','magenta','cyan','blue'] # Keep track of all the sites we plot # Delete all temporary sites from last time # Remove the influence of the tempsites on self.donepos			 # # Plot up or down? # Down # #List for storing restr. label objects # # # Main Loop # #print site #print subsite # Store org y position as end-point for line #Apply the base shift for drawing upside or downside # If a comparison sequence is loaded raise more #determine if more than one cut at this site #iterate over donepos to see if nearby sites, and if so shift up # # Should we only show unique sites? # # # Maximum number of sites (other than the unique site button) # # # Select colour # # Underline unique sites # Draw site/enzyme label here # Keep track of where we've plotted everything						 # #add site text item to list of those currently on canvas #if not temporary: #	self.sites.append(obj) #try to tidy up labels on canvas - testing # Restriction details?		
self
cut_pos
colour
direction
add_text
temporary
delete_temporary
underline_unique