PEATDB/DNAtool/primer_database.py
def display_single_primer(self,selection,focus,delete):
        """Display a single primer - focus on it if focus is true, and delete
            previous graphics and text objects if delete is true"""
            
        name_selected=self.primer_order[selection]
        #print 'SELECTION=',selection
        this_primer = self.parent.data['primer_dict'][name_selected]
        self.current_primers_shown.append(this_primer)
        self.parent.primer_displayed=1  #tells DNAtool that a primer is currently shown
        self.details.config(state=NORMAL)
        if delete:
            self.details.delete(1.0,END)

        # Align the primer
        # If we do not have a DNA sequence then we cannot do it

        this_primer['startpos']=None
        if self.parent.data.has_key('DNAseq'):
            if self.parent.data['DNAseq']:

                # Find all possible binding sites for the primer
                sites=self.find_primer_binding_sites(this_primer['sequence'],self.parent.data['DNAseq'])

                # Print the number of binding sites
                best_score=0
                best_position=None
                scores=[]
                first_neg=1
                for position,score in sites:
                    scores.append(score)

                    # Find the best position
                    if score>best_score:
                        best_score=score
                        best_position=position

                # Set the primer start for the primer characteristics
                this_primer['startpos']=best_position
                this_primer['template_DNA']=self.parent.data['DNAseq']

        # Show all the info on the primer
        self.details.tag_config('n', foreground='blue')
        self.details.insert(END,'Primer: %s \n' %name_selected, 'n')
        self.details.insert(END,'Description: %s \n' %(this_primer['description']))
        self.details.insert(END,'Length: %3d bases\n' %(len(this_primer['sequence'])))
        self.details.insert(END,"Forward 5' %s 3'\n\n" %this_primer['sequence'])

        # Show the reverse complementary sequence
        import mutation
        self.details.insert(END,"Reverse complementary: 5' %s 3'\n" %mutation.get_reverse_complementary(this_primer['sequence']))

        # Make sure that we have the updated the characteristics of the primer
        if not this_primer.has_key('template_DNA'):
            return
        import evaluate_primer
        EVAL=evaluate_primer.evaluate_primer()
        hairpin,selfcompl,Tm_inpos,Tm_method_used,mismatches=EVAL.get_characteristics(this_primer,self.parent.Tm_method.get())
        this_primer['hairpin_prop']=hairpin
        this_primer['self-compl']=selfcompl
        this_primer['introduced_sites']='Unknown'

        # Show the characteristics of the primer
        text='-----------------------\nCharacteristics\nTm (in aligned position): %5.2f (%s)\n' %(Tm_inpos,Tm_method_used)
        self.details.insert(END,text)
        text='Hairpin: %s, \nself-sim: %s, \nrestr. site differences: ' %(this_primer['hairpin_prop'],
                                                                        this_primer['self-compl'])
        self.details.insert(END,text)
        
        # Show the recognition sequence for the enzyme(s)        
        self.details.insert(END,'Unique sites are marked with a "*"\n')
        unique_added,unique_removed,non_unique_added,non_unique_removed=self.get_primer_restriction_differences(this_primer)
        enz_specs=self.parent.RS.enzymes_regexs
        inserted=None
        for enz in unique_added.keys():
            if enz_specs.has_key(enz):
                self.details.insert(END,enz+'(+)*, ')
                inserted=1

        for enz in unique_removed.keys():
            if enz_specs.has_key(enz):
                self.details.insert(END,enz+'(-)*, ')
                inserted=1
        for enz in non_unique_added.keys():
            if enz_specs.has_key(enz):
                self.details.insert(END,enz+'(+), ')
                inserted=1

        for enz in non_unique_removed.keys():
            if enz_specs.has_key(enz):
                self.details.insert(END,enz+'(-), ')
                inserted=1

        # If there were no differences in the restriction map, then write that
        if inserted==None:
            self.details.insert(END,'None')

        # Delete all graphic objects from last round
        if delete:
            if not getattr(self.parent,'detailed_objs',None):
                self.parent.detailed_objs = {}
            for obj in self.parent.detailed_objs.keys():
                self.parent.seqframe.delete(obj)
                if getattr(self.parent,'tempsites',None):
                    self.parent.tempsites.remove(obj)

        # Print guidelines for this primer

        scores.sort()
        diff=scores[-1]-scores[-2]
        self.details.insert(END,'\nDifference in # of matches between two best sites: %2d\n' %diff)
        if diff<5:
            self.details.insert(END,'WARNING: Primer is not unique!\n')
        if scores[-1]!=len(this_primer['sequence']):
            self.details.insert(END,'\nWARNING: No perfectly matching binding site.\n')

        # Print the number of mismatches as a control

        if this_primer['startpos']>0:
            self.details.insert(END,'\nDisplaying position: %4d on forward strand\n' %this_primer['startpos'])
        else:
            self.details.insert(END,'\nDisplaying position: %4d on reverse strand\n' %(-this_primer['startpos']))
        self.details.insert(END,'Number of mismatches: %d\n\n' %mismatches)

        # Display the primer

        match=self.display_primer(this_primer,focus)

        # Show the binding site

        self.details.insert(END,'\n==================================\n')
        site=sites[0][0]
        if site<0:
            site=len(this_primer['sequence'])+site
        #
        DNA_stretch=self.parent.data['DNAseq'][site:site+len(this_primer['sequence'])]
        self.details.insert(END,'Primer %s\n       %s\nDNASeq %s\n' %(this_primer['sequence'],match,DNA_stretch))

        # Print summary of all binding sites

        self.details.insert(END,'\n---------------------\nSummary of best binding sites\n')
        self.details.insert(END,'Forward strand:\n')
        first_neg=1
        for site,score in sites:
            if site<0:
                site=site*-1
                if first_neg:
                    first_neg=None
                    self.details.insert(END,'Reverse compl. strand:\n')
            self.details.insert(END,'Position: %4d, matches: %2d\n' %(site,score))


        self.details.insert(END,'\n')
        self.details.config(state=DISABLED)

        # Return the sites for use in highlighting
        start_position=self.get_real_primer_position(this_primer)
        return [start_position,start_position+len(this_primer['sequence'])]
Display a single primer - focus on it if focus is true, and delete
            previous graphics and text objects if delete is true
Display a single primer - focus on it if focus is true, and delete
previous graphics and text objects if delete is true
Display a single primer - focus on it if focus is true and delete previous graphics and text objects if delete is true
def display_single_primer(self,selection,focus,delete):
        name_selected=self.primer_order[selection]
        this_primer = self.parent.data['primer_dict'][name_selected]
        self.current_primers_shown.append(this_primer)
        self.parent.primer_displayed=1  
        self.details.config(state=NORMAL)
        if delete:
            self.details.delete(1.0,END)
        this_primer['startpos']=None
        if self.parent.data.has_key('DNAseq'):
            if self.parent.data['DNAseq']:
                sites=self.find_primer_binding_sites(this_primer['sequence'],self.parent.data['DNAseq'])
                best_score=0
                best_position=None
                scores=[]
                first_neg=1
                for position,score in sites:
                    scores.append(score)
                    if score>best_score:
                        best_score=score
                        best_position=position
                this_primer['startpos']=best_position
                this_primer['template_DNA']=self.parent.data['DNAseq']
        self.details.tag_config('n', foreground='blue')
        self.details.insert(END,'Primer: %s \n' %name_selected, 'n')
        self.details.insert(END,'Description: %s \n' %(this_primer['description']))
        self.details.insert(END,'Length: %3d bases\n' %(len(this_primer['sequence'])))
        self.details.insert(END,"Forward 5' %s 3'\n\n" %this_primer['sequence'])
        import mutation
        self.details.insert(END,"Reverse complementary: 5' %s 3'\n" %mutation.get_reverse_complementary(this_primer['sequence']))
        if not this_primer.has_key('template_DNA'):
            return
        import evaluate_primer
        EVAL=evaluate_primer.evaluate_primer()
        hairpin,selfcompl,Tm_inpos,Tm_method_used,mismatches=EVAL.get_characteristics(this_primer,self.parent.Tm_method.get())
        this_primer['hairpin_prop']=hairpin
        this_primer['self-compl']=selfcompl
        this_primer['introduced_sites']='Unknown'
        text='-----------------------\nCharacteristics\nTm (in aligned position): %5.2f (%s)\n' %(Tm_inpos,Tm_method_used)
        self.details.insert(END,text)
        text='Hairpin: %s, \nself-sim: %s, \nrestr. site differences: ' %(this_primer['hairpin_prop'],
                                                                        this_primer['self-compl'])
        self.details.insert(END,text)
        self.details.insert(END,'Unique sites are marked with a "*"\n')
        unique_added,unique_removed,non_unique_added,non_unique_removed=self.get_primer_restriction_differences(this_primer)
        enz_specs=self.parent.RS.enzymes_regexs
        inserted=None
        for enz in unique_added.keys():
            if enz_specs.has_key(enz):
                self.details.insert(END,enz+'(+)*, ')
                inserted=1
        for enz in unique_removed.keys():
            if enz_specs.has_key(enz):
                self.details.insert(END,enz+'(-)*, ')
                inserted=1
        for enz in non_unique_added.keys():
            if enz_specs.has_key(enz):
                self.details.insert(END,enz+'(+), ')
                inserted=1
        for enz in non_unique_removed.keys():
            if enz_specs.has_key(enz):
                self.details.insert(END,enz+'(-), ')
                inserted=1
        if inserted==None:
            self.details.insert(END,'None')
        if delete:
            if not getattr(self.parent,'detailed_objs',None):
                self.parent.detailed_objs = {}
            for obj in self.parent.detailed_objs.keys():
                self.parent.seqframe.delete(obj)
                if getattr(self.parent,'tempsites',None):
                    self.parent.tempsites.remove(obj)
        scores.sort()
        diff=scores[-1]-scores[-2]
        self.details.insert(END,'\nDifference in  of matches between two best sites: %2d\n' %diff)
        if diff<5:
            self.details.insert(END,'WARNING: Primer is not unique!\n')
        if scores[-1]!=len(this_primer['sequence']):
            self.details.insert(END,'\nWARNING: No perfectly matching binding site.\n')
        if this_primer['startpos']>0:
            self.details.insert(END,'\nDisplaying position: %4d on forward strand\n' %this_primer['startpos'])
        else:
            self.details.insert(END,'\nDisplaying position: %4d on reverse strand\n' %(-this_primer['startpos']))
        self.details.insert(END,'Number of mismatches: %d\n\n' %mismatches)
        match=self.display_primer(this_primer,focus)
        self.details.insert(END,'\n==================================\n')
        site=sites[0][0]
        if site<0:
            site=len(this_primer['sequence'])+site
        DNA_stretch=self.parent.data['DNAseq'][site:site+len(this_primer['sequence'])]
        self.details.insert(END,'Primer %s\n       %s\nDNASeq %s\n' %(this_primer['sequence'],match,DNA_stretch))
         Print summary of all binding sites
        self.details.insert(END,'\n---------------------\nSummary of best binding sites\n')
        self.details.insert(END,'Forward strand:\n')
        first_neg=1
        for site,score in sites:
            if site<0:
                site=site*-1
                if first_neg:
                    first_neg=None
                    self.details.insert(END,'Reverse compl. strand:\n')
            self.details.insert(END,'Position: %4d, matches: %2d\n' %(site,score))
        self.details.insert(END,'\n')
        self.details.config(state=DISABLED)
         Return the sites for use in highlighting
        start_position=self.get_real_primer_position(this_primer)
        return [start_position,start_position+len(this_primer['sequence'])]
def display_single_primer ( self , selection , focus , delete ) : name_selected = self . primer_order [ selection ] this_primer = self . parent . data [ 'primer_dict' ] [ name_selected ] self . current_primers_shown . append ( this_primer ) self . parent . primer_displayed = 1 self . details . config ( state = NORMAL ) if delete : self . details . delete ( 1.0 , END ) this_primer [ 'startpos' ] = None if self . parent . data . has_key ( 'DNAseq' ) : if self . parent . data [ 'DNAseq' ] : sites = self . find_primer_binding_sites ( this_primer [ 'sequence' ] , self . parent . data [ 'DNAseq' ] ) best_score = 0 best_position = None scores = [ ] first_neg = 1 for position , score in sites : scores . append ( score ) if score > best_score : best_score = score best_position = position this_primer [ 'startpos' ] = best_position this_primer [ 'template_DNA' ] = self . parent . data [ 'DNAseq' ] self . details . tag_config ( 'n' , foreground = 'blue' ) self . details . insert ( END , 'Primer: %s \n' % name_selected , 'n' ) self . details . insert ( END , 'Description: %s \n' % ( this_primer [ 'description' ] ) ) self . details . insert ( END , 'Length: %3d bases\n' % ( len ( this_primer [ 'sequence' ] ) ) ) self . details . insert ( END , "Forward 5' %s 3'\n\n" % this_primer [ 'sequence' ] ) import mutation self . details . insert ( END , "Reverse complementary: 5' %s 3'\n" % mutation . get_reverse_complementary ( this_primer [ 'sequence' ] ) ) if not this_primer . has_key ( 'template_DNA' ) : return import evaluate_primer EVAL = evaluate_primer . evaluate_primer ( ) hairpin , selfcompl , Tm_inpos , Tm_method_used , mismatches = EVAL . get_characteristics ( this_primer , self . parent . Tm_method . get ( ) ) this_primer [ 'hairpin_prop' ] = hairpin this_primer [ 'self-compl' ] = selfcompl this_primer [ 'introduced_sites' ] = 'Unknown' text = '-----------------------\nCharacteristics\nTm (in aligned position): %5.2f (%s)\n' % ( Tm_inpos , Tm_method_used ) self . details . insert ( END , text ) text = 'Hairpin: %s, \nself-sim: %s, \nrestr. site differences: ' % ( this_primer [ 'hairpin_prop' ] , this_primer [ 'self-compl' ] ) self . details . insert ( END , text ) self . details . insert ( END , 'Unique sites are marked with a "*"\n' ) unique_added , unique_removed , non_unique_added , non_unique_removed = self . get_primer_restriction_differences ( this_primer ) enz_specs = self . parent . RS . enzymes_regexs inserted = None for enz in unique_added . keys ( ) : if enz_specs . has_key ( enz ) : self . details . insert ( END , enz + '(+)*, ' ) inserted = 1 for enz in unique_removed . keys ( ) : if enz_specs . has_key ( enz ) : self . details . insert ( END , enz + '(-)*, ' ) inserted = 1 for enz in non_unique_added . keys ( ) : if enz_specs . has_key ( enz ) : self . details . insert ( END , enz + '(+), ' ) inserted = 1 for enz in non_unique_removed . keys ( ) : if enz_specs . has_key ( enz ) : self . details . insert ( END , enz + '(-), ' ) inserted = 1 if inserted == None : self . details . insert ( END , 'None' ) if delete : if not getattr ( self . parent , 'detailed_objs' , None ) : self . parent . detailed_objs = { } for obj in self . parent . detailed_objs . keys ( ) : self . parent . seqframe . delete ( obj ) if getattr ( self . parent , 'tempsites' , None ) : self . parent . tempsites . remove ( obj ) scores . sort ( ) diff = scores [ - 1 ] - scores [ - 2 ] self . details . insert ( END , '\nDifference in # of matches between two best sites: %2d\n' % diff ) if diff < 5 : self . details . insert ( END , 'WARNING: Primer is not unique!\n' ) if scores [ - 1 ] != len ( this_primer [ 'sequence' ] ) : self . details . insert ( END , '\nWARNING: No perfectly matching binding site.\n' ) if this_primer [ 'startpos' ] > 0 : self . details . insert ( END , '\nDisplaying position: %4d on forward strand\n' % this_primer [ 'startpos' ] ) else : self . details . insert ( END , '\nDisplaying position: %4d on reverse strand\n' % ( - this_primer [ 'startpos' ] ) ) self . details . insert ( END , 'Number of mismatches: %d\n\n' % mismatches ) match = self . display_primer ( this_primer , focus ) self . details . insert ( END , '\n==================================\n' ) site = sites [ 0 ] [ 0 ] if site < 0 : site = len ( this_primer [ 'sequence' ] ) + site DNA_stretch = self . parent . data [ 'DNAseq' ] [ site : site + len ( this_primer [ 'sequence' ] ) ] self . details . insert ( END , 'Primer %s\n       %s\nDNASeq %s\n' % ( this_primer [ 'sequence' ] , match , DNA_stretch ) ) self . details . insert ( END , '\n---------------------\nSummary of best binding sites\n' ) self . details . insert ( END , 'Forward strand:\n' ) first_neg = 1 for site , score in sites : if site < 0 : site = site * - 1 if first_neg : first_neg = None self . details . insert ( END , 'Reverse compl. strand:\n' ) self . details . insert ( END , 'Position: %4d, matches: %2d\n' % ( site , score ) ) self . details . insert ( END , '\n' ) self . details . config ( state = DISABLED ) start_position = self . get_real_primer_position ( this_primer ) return [ start_position , start_position + len ( this_primer [ 'sequence' ] ) ]
Display a single primer - focus on it if focus is true, and delete
previous graphics and text objects if delete is true
Display a single primer - focus on it if focus is true and delete previous graphics and text objects if delete is true
"""Display a single primer - focus on it if focus is true, and delete
            previous graphics and text objects if delete is true""" #print 'SELECTION=',selection #tells DNAtool that a primer is currently shown # Align the primer # If we do not have a DNA sequence then we cannot do it # Find all possible binding sites for the primer # Print the number of binding sites # Find the best position # Set the primer start for the primer characteristics # Show all the info on the primer # Show the reverse complementary sequence # Make sure that we have the updated the characteristics of the primer # Show the characteristics of the primer # Show the recognition sequence for the enzyme(s)         # If there were no differences in the restriction map, then write that # Delete all graphic objects from last round # Print guidelines for this primer # Print the number of mismatches as a control # Display the primer # Show the binding site # # Print summary of all binding sites # Return the sites for use in highlighting
self
selection
focus
delete