PEATDB/DNAtool/primer_database.py
def display_primer(self,this_primer,delete=1,only_delete=None,focus=1):
        """Display the primer in the sequence window"""

        font = self.parent.getCurrentFont()
        # Keep track of the objects
        if not getattr(self,'primer_objs',None):
            self.primer_objs={}
        if delete or only_delete:
            for obj in self.primer_objs.keys():
                self.parent.seqframe.delete(obj)
            self.primer_objs={}
            if only_delete:
                return

        # Do we have a primer?
        if this_primer['sequence']=='' or not this_primer['sequence']:
            return

        # Draw the new primer
        mismatches,match,objs=self.draw_primer(this_primer,lvl=self.parent.maxseqlevel)
        for obj in objs.keys():
            self.primer_objs[obj]=1

        # Get the restriction map differences
        unique_added,unique_removed,non_unique_added,non_unique_removed=self.get_primer_restriction_differences(this_primer)

        # Plot the thing
        self.parent.plot_restriction_sites(unique_added,colour='darkgreen',direction='down',
                                           add_text='(+)',temporary=1,delete_temporary=1)
        self.parent.plot_restriction_sites(unique_removed,colour='red',direction='down',
                                           add_text='(-)',temporary=1,delete_temporary=None)
        self.parent.plot_restriction_sites(non_unique_added,colour='darkgreen',direction='down',
                                           add_text='(+)',temporary=1,delete_temporary=None,underline_unique=None)
        self.parent.plot_restriction_sites(non_unique_removed,colour='darkred',direction='down',
                                           add_text='(-)',temporary=1,delete_temporary=None,underline_unique=None)

        # See if there are any AA changes and show (only if we have an ORF)

        self.mutations=[]
        if self.parent.data.has_key('ORF_selected'):
            # Find any differences in the sequence
            frame=self.parent.data['ORF_selected']['frame']-1
            wtseq=self.parent.data['ORF_selected']['aaseq3']
            new_DNA=self.apply_primer_to_DNA(this_primer,self.parent.data['DNAseq'],this_primer['startpos'])
            import mutation
            AA_seqs3,AA_seqs1=mutation.translate(new_DNA)

            # Get only the part of sequence that's defined in the ORF
            ORF_start=self.parent.data['ORF_selected']['start']
            AA_seqs3[frame]=AA_seqs3[frame][ORF_start-1:]
            for count in range(min(len(AA_seqs1[frame]),len(wtseq))):
                if AA_seqs3[frame][count]!=wtseq[count]:
                    newres=AA_seqs3[frame][count]
                    position=count+1
                    #print 'position',position
                    x,y_junk=self.parent.get_aa_pos_on_screen(position+ORF_start-2,frame+2)
                    colour='red'
                    y=(y_junk-25)*self.parent.y_scale

                    obj=self.parent.seqframe.create_text(x+2,y,
                                                         text=newres,
                                                         font=font,
                                                         anchor='w',fill=colour)
                    self.primer_objs[obj]=1
                    self.mutations.append(':'+wtseq[count]+':'+str(count+self.parent.data['ORF_selected']['aastart_number'])+':'+AA_seqs3[frame][count])

        # Update the view of the sequence window
        if focus:
            position=this_primer['startpos']
            if this_primer['startpos']<0:
                position=len(self.parent.data['DNAseq'])-(abs(position)+len(this_primer['sequence']))
            x,y=self.parent.get_base_pos_on_screen(position+len(this_primer['sequence'])/2)

            # We need to center on the aa preferably
            center=max(0.0,x-(self.parent.x_size-self.parent.canvas_border_x)/2.0)
            # Moveto works in fractions of the screen, so get the fraction
            frac=center/self.parent.canvas_x
            self.parent.seqframe.xview('moveto', frac)
            self.parent.seqframe.yview('moveto', 0.2)  #middle of scrollregion
        return match
Display the primer in the sequence window
Display the primer in the sequence window
Display the primer in the sequence window
def display_primer(self,this_primer,delete=1,only_delete=None,focus=1):
        font = self.parent.getCurrentFont()
        if not getattr(self,'primer_objs',None):
            self.primer_objs={}
        if delete or only_delete:
            for obj in self.primer_objs.keys():
                self.parent.seqframe.delete(obj)
            self.primer_objs={}
            if only_delete:
                return
        if this_primer['sequence']=='' or not this_primer['sequence']:
            return
        mismatches,match,objs=self.draw_primer(this_primer,lvl=self.parent.maxseqlevel)
        for obj in objs.keys():
            self.primer_objs[obj]=1
        unique_added,unique_removed,non_unique_added,non_unique_removed=self.get_primer_restriction_differences(this_primer)
        self.parent.plot_restriction_sites(unique_added,colour='darkgreen',direction='down',
                                           add_text='(+)',temporary=1,delete_temporary=1)
        self.parent.plot_restriction_sites(unique_removed,colour='red',direction='down',
                                           add_text='(-)',temporary=1,delete_temporary=None)
        self.parent.plot_restriction_sites(non_unique_added,colour='darkgreen',direction='down',
                                           add_text='(+)',temporary=1,delete_temporary=None,underline_unique=None)
        self.parent.plot_restriction_sites(non_unique_removed,colour='darkred',direction='down',
                                           add_text='(-)',temporary=1,delete_temporary=None,underline_unique=None)
        self.mutations=[]
        if self.parent.data.has_key('ORF_selected'):
            frame=self.parent.data['ORF_selected']['frame']-1
            wtseq=self.parent.data['ORF_selected']['aaseq3']
            new_DNA=self.apply_primer_to_DNA(this_primer,self.parent.data['DNAseq'],this_primer['startpos'])
            import mutation
            AA_seqs3,AA_seqs1=mutation.translate(new_DNA)
            ORF_start=self.parent.data['ORF_selected']['start']
            AA_seqs3[frame]=AA_seqs3[frame][ORF_start-1:]
            for count in range(min(len(AA_seqs1[frame]),len(wtseq))):
                if AA_seqs3[frame][count]!=wtseq[count]:
                    newres=AA_seqs3[frame][count]
                    position=count+1
                    x,y_junk=self.parent.get_aa_pos_on_screen(position+ORF_start-2,frame+2)
                    colour='red'
                    y=(y_junk-25)*self.parent.y_scale
                    obj=self.parent.seqframe.create_text(x+2,y,
                                                         text=newres,
                                                         font=font,
                                                         anchor='w',fill=colour)
                    self.primer_objs[obj]=1
                    self.mutations.append(':'+wtseq[count]+':'+str(count+self.parent.data['ORF_selected']['aastart_number'])+':'+AA_seqs3[frame][count])
        if focus:
            position=this_primer['startpos']
            if this_primer['startpos']<0:
                position=len(self.parent.data['DNAseq'])-(abs(position)+len(this_primer['sequence']))
            x,y=self.parent.get_base_pos_on_screen(position+len(this_primer['sequence'])/2)
            center=max(0.0,x-(self.parent.x_size-self.parent.canvas_border_x)/2.0)
            frac=center/self.parent.canvas_x
            self.parent.seqframe.xview('moveto', frac)
            self.parent.seqframe.yview('moveto', 0.2)  
        return match
def display_primer ( self , this_primer , delete = 1 , only_delete = None , focus = 1 ) : font = self . parent . getCurrentFont ( ) if not getattr ( self , 'primer_objs' , None ) : self . primer_objs = { } if delete or only_delete : for obj in self . primer_objs . keys ( ) : self . parent . seqframe . delete ( obj ) self . primer_objs = { } if only_delete : return if this_primer [ 'sequence' ] == '' or not this_primer [ 'sequence' ] : return mismatches , match , objs = self . draw_primer ( this_primer , lvl = self . parent . maxseqlevel ) for obj in objs . keys ( ) : self . primer_objs [ obj ] = 1 unique_added , unique_removed , non_unique_added , non_unique_removed = self . get_primer_restriction_differences ( this_primer ) self . parent . plot_restriction_sites ( unique_added , colour = 'darkgreen' , direction = 'down' , add_text = '(+)' , temporary = 1 , delete_temporary = 1 ) self . parent . plot_restriction_sites ( unique_removed , colour = 'red' , direction = 'down' , add_text = '(-)' , temporary = 1 , delete_temporary = None ) self . parent . plot_restriction_sites ( non_unique_added , colour = 'darkgreen' , direction = 'down' , add_text = '(+)' , temporary = 1 , delete_temporary = None , underline_unique = None ) self . parent . plot_restriction_sites ( non_unique_removed , colour = 'darkred' , direction = 'down' , add_text = '(-)' , temporary = 1 , delete_temporary = None , underline_unique = None ) self . mutations = [ ] if self . parent . data . has_key ( 'ORF_selected' ) : frame = self . parent . data [ 'ORF_selected' ] [ 'frame' ] - 1 wtseq = self . parent . data [ 'ORF_selected' ] [ 'aaseq3' ] new_DNA = self . apply_primer_to_DNA ( this_primer , self . parent . data [ 'DNAseq' ] , this_primer [ 'startpos' ] ) import mutation AA_seqs3 , AA_seqs1 = mutation . translate ( new_DNA ) ORF_start = self . parent . data [ 'ORF_selected' ] [ 'start' ] AA_seqs3 [ frame ] = AA_seqs3 [ frame ] [ ORF_start - 1 : ] for count in range ( min ( len ( AA_seqs1 [ frame ] ) , len ( wtseq ) ) ) : if AA_seqs3 [ frame ] [ count ] != wtseq [ count ] : newres = AA_seqs3 [ frame ] [ count ] position = count + 1 x , y_junk = self . parent . get_aa_pos_on_screen ( position + ORF_start - 2 , frame + 2 ) colour = 'red' y = ( y_junk - 25 ) * self . parent . y_scale obj = self . parent . seqframe . create_text ( x + 2 , y , text = newres , font = font , anchor = 'w' , fill = colour ) self . primer_objs [ obj ] = 1 self . mutations . append ( ':' + wtseq [ count ] + ':' + str ( count + self . parent . data [ 'ORF_selected' ] [ 'aastart_number' ] ) + ':' + AA_seqs3 [ frame ] [ count ] ) if focus : position = this_primer [ 'startpos' ] if this_primer [ 'startpos' ] < 0 : position = len ( self . parent . data [ 'DNAseq' ] ) - ( abs ( position ) + len ( this_primer [ 'sequence' ] ) ) x , y = self . parent . get_base_pos_on_screen ( position + len ( this_primer [ 'sequence' ] ) / 2 ) center = max ( 0.0 , x - ( self . parent . x_size - self . parent . canvas_border_x ) / 2.0 ) frac = center / self . parent . canvas_x self . parent . seqframe . xview ( 'moveto' , frac ) self . parent . seqframe . yview ( 'moveto' , 0.2 ) return match
Display the primer in the sequence window
Display the primer in the sequence window
"""Display the primer in the sequence window""" # Keep track of the objects # Do we have a primer? # Draw the new primer # Get the restriction map differences # Plot the thing # See if there are any AA changes and show (only if we have an ORF) # Find any differences in the sequence # Get only the part of sequence that's defined in the ORF #print 'position',position # Update the view of the sequence window # We need to center on the aa preferably # Moveto works in fractions of the screen, so get the fraction #middle of scrollregion
self
this_primer
delete
only_delete
focus