PEATDB/DNAtool/primer_alignment.py
def draw_primer(self,this_primer,colour='blue',thetag='primer',seqname=None,lvl=0):
        """This draws a primer OR any comparison sequence above the main sequence"""

        # Draw the primer
        font = self.parent.getCurrentFont()
        objs={}
        mismatches=0
        rev_compl=None
        position=this_primer['startpos']
        primer_sequence=this_primer['sequence']
        if not primer_sequence or primer_sequence=='':
            return
        if position<0:
            rev_compl=1
            position=len(self.parent.data['DNAseq'])-(abs(position)+len(primer_sequence))

            # Reverse
            primer_sequence=''
            for letter in this_primer['sequence']:
                primer_sequence=letter+primer_sequence
        position=position+1
        DNA_stretch=''
        match=''

        # Write the 5' or 3'
        x,y=self.parent.get_base_pos_on_screen(position-2)

        # First find the y value, corrected for scale and no. of sequences etc.
        # This needs to be only done once, so use the dummy ytmp value when doing
        # get_base_pos_on_screen after this

        y=(y-10)/self.parent.y_scale
        #move primer further up, if the comparison DNA sequence is displayed
        if self.parent.show_comp_sequence.get()==1 and thetag=='primer':
            y=(y-10)/self.parent.y_scale
            #raise up primer correct no. of 'levels' os it is just above highest one
            if lvl>0:
                lvl=lvl-1
                y=y-(lvl*15)/self.parent.y_scale
        #raise mutliple levels when many comparison sequences displayed
        if thetag != 'primer':
            y=y-(lvl*15)/self.parent.y_scale

        if this_primer['startpos']<0:
            start_symbol="3'"
            end_symbol="5'"
        else:
            start_symbol="5'"
            end_symbol="3'"

        objs[self.parent.seqframe.create_text(x,y,text=start_symbol,font=font,
                                            fill='blue',anchor='w',tag=thetag)]=1

        # Now draw the primer/seq
        for letter in primer_sequence:
            x,ytmp=self.parent.get_base_pos_on_screen(position)
            # If we are still within the parent sequence then detect differences

            if position-1<len(self.parent.data['DNAseq']):
                org_base=self.parent.data['DNAseq'][position-1]
            else:
                org_base=letter

            identical=None
            if rev_compl:

                if mutation.match(org_base,letter):
                    identical=1
            else:
                if string.upper(org_base)==string.upper(letter):
                    identical=1
            #
            # Draw primer/seq. If the seq has a name then add the tag for that.
            #
            if identical:
                if seqname==None:
                    obj=objs[self.parent.seqframe.create_text(x,y,text=letter,font=font,
                                                        fill=colour,anchor='w',
                                                        tags=thetag)]=1
                else:
                    name=seqname.rstrip('seq.clipped')
                    obj=objs[self.parent.seqframe.create_text(x,y,text=letter,font=font,
                                                        fill=colour,anchor='w',
                                                        tags=(thetag,name))]=1
                match=match+'|'
            else:
                if seqname==None:
                    obj=objs[self.parent.seqframe.create_text(x,y,text=letter,font=font,
                                                        fill='red',anchor='w',
                                                        tags=thetag)]=1
                else:
                    name=seqname.rstrip('seq.clipped')
                    obj=objs[self.parent.seqframe.create_text(x,y,text=letter,font=font,
                                                        fill='red',anchor='w',
                                                        tags=(thetag,name))]=1

                match=match+' '
                mismatches=mismatches+1
            DNA_stretch=DNA_stretch+org_base
            position=position+1

        # Write the end symbol
        x,ytmp=self.parent.get_base_pos_on_screen(position)
        objs[self.parent.seqframe.create_text(x,y,text=end_symbol,font=font,
                                                fill='blue',anchor='w',tags=thetag)]=1
        return mismatches,match,objs
This draws a primer OR any comparison sequence above the main sequence
This draws a primer OR any comparison sequence above the main sequence
This draws a primer OR any comparison sequence above the main sequence
def draw_primer(self,this_primer,colour='blue',thetag='primer',seqname=None,lvl=0):
        font = self.parent.getCurrentFont()
        objs={}
        mismatches=0
        rev_compl=None
        position=this_primer['startpos']
        primer_sequence=this_primer['sequence']
        if not primer_sequence or primer_sequence=='':
            return
        if position<0:
            rev_compl=1
            position=len(self.parent.data['DNAseq'])-(abs(position)+len(primer_sequence))
            primer_sequence=''
            for letter in this_primer['sequence']:
                primer_sequence=letter+primer_sequence
        position=position+1
        DNA_stretch=''
        match=''
        x,y=self.parent.get_base_pos_on_screen(position-2)
        y=(y-10)/self.parent.y_scale
        if self.parent.show_comp_sequence.get()==1 and thetag=='primer':
            y=(y-10)/self.parent.y_scale
            if lvl>0:
                lvl=lvl-1
                y=y-(lvl*15)/self.parent.y_scale
        if thetag != 'primer':
            y=y-(lvl*15)/self.parent.y_scale
        if this_primer['startpos']<0:
            start_symbol="3'"
            end_symbol="5'"
        else:
            start_symbol="5'"
            end_symbol="3'"
        objs[self.parent.seqframe.create_text(x,y,text=start_symbol,font=font,
                                            fill='blue',anchor='w',tag=thetag)]=1
        for letter in primer_sequence:
            x,ytmp=self.parent.get_base_pos_on_screen(position)
            if position-1<len(self.parent.data['DNAseq']):
                org_base=self.parent.data['DNAseq'][position-1]
            else:
                org_base=letter
            identical=None
            if rev_compl:
                if mutation.match(org_base,letter):
                    identical=1
            else:
                if string.upper(org_base)==string.upper(letter):
                    identical=1
             Draw primer/seq. If the seq has a name then add the tag for that.
            if identical:
                if seqname==None:
                    obj=objs[self.parent.seqframe.create_text(x,y,text=letter,font=font,
                                                        fill=colour,anchor='w',
                                                        tags=thetag)]=1
                else:
                    name=seqname.rstrip('seq.clipped')
                    obj=objs[self.parent.seqframe.create_text(x,y,text=letter,font=font,
                                                        fill=colour,anchor='w',
                                                        tags=(thetag,name))]=1
                match=match+'|'
            else:
                if seqname==None:
                    obj=objs[self.parent.seqframe.create_text(x,y,text=letter,font=font,
                                                        fill='red',anchor='w',
                                                        tags=thetag)]=1
                else:
                    name=seqname.rstrip('seq.clipped')
                    obj=objs[self.parent.seqframe.create_text(x,y,text=letter,font=font,
                                                        fill='red',anchor='w',
                                                        tags=(thetag,name))]=1
                match=match+' '
                mismatches=mismatches+1
            DNA_stretch=DNA_stretch+org_base
            position=position+1
         Write the end symbol
        x,ytmp=self.parent.get_base_pos_on_screen(position)
        objs[self.parent.seqframe.create_text(x,y,text=end_symbol,font=font,
                                                fill='blue',anchor='w',tags=thetag)]=1
        return mismatches,match,objs
def draw_primer ( self , this_primer , colour = 'blue' , thetag = 'primer' , seqname = None , lvl = 0 ) : font = self . parent . getCurrentFont ( ) objs = { } mismatches = 0 rev_compl = None position = this_primer [ 'startpos' ] primer_sequence = this_primer [ 'sequence' ] if not primer_sequence or primer_sequence == '' : return if position < 0 : rev_compl = 1 position = len ( self . parent . data [ 'DNAseq' ] ) - ( abs ( position ) + len ( primer_sequence ) ) primer_sequence = '' for letter in this_primer [ 'sequence' ] : primer_sequence = letter + primer_sequence position = position + 1 DNA_stretch = '' match = '' x , y = self . parent . get_base_pos_on_screen ( position - 2 ) y = ( y - 10 ) / self . parent . y_scale if self . parent . show_comp_sequence . get ( ) == 1 and thetag == 'primer' : y = ( y - 10 ) / self . parent . y_scale if lvl > 0 : lvl = lvl - 1 y = y - ( lvl * 15 ) / self . parent . y_scale if thetag != 'primer' : y = y - ( lvl * 15 ) / self . parent . y_scale if this_primer [ 'startpos' ] < 0 : start_symbol = "3'" end_symbol = "5'" else : start_symbol = "5'" end_symbol = "3'" objs [ self . parent . seqframe . create_text ( x , y , text = start_symbol , font = font , fill = 'blue' , anchor = 'w' , tag = thetag ) ] = 1 for letter in primer_sequence : x , ytmp = self . parent . get_base_pos_on_screen ( position ) if position - 1 < len ( self . parent . data [ 'DNAseq' ] ) : org_base = self . parent . data [ 'DNAseq' ] [ position - 1 ] else : org_base = letter identical = None if rev_compl : if mutation . match ( org_base , letter ) : identical = 1 else : if string . upper ( org_base ) == string . upper ( letter ) : identical = 1 if identical : if seqname == None : obj = objs [ self . parent . seqframe . create_text ( x , y , text = letter , font = font , fill = colour , anchor = 'w' , tags = thetag ) ] = 1 else : name = seqname . rstrip ( 'seq.clipped' ) obj = objs [ self . parent . seqframe . create_text ( x , y , text = letter , font = font , fill = colour , anchor = 'w' , tags = ( thetag , name ) ) ] = 1 match = match + '|' else : if seqname == None : obj = objs [ self . parent . seqframe . create_text ( x , y , text = letter , font = font , fill = 'red' , anchor = 'w' , tags = thetag ) ] = 1 else : name = seqname . rstrip ( 'seq.clipped' ) obj = objs [ self . parent . seqframe . create_text ( x , y , text = letter , font = font , fill = 'red' , anchor = 'w' , tags = ( thetag , name ) ) ] = 1 match = match + ' ' mismatches = mismatches + 1 DNA_stretch = DNA_stretch + org_base position = position + 1 x , ytmp = self . parent . get_base_pos_on_screen ( position ) objs [ self . parent . seqframe . create_text ( x , y , text = end_symbol , font = font , fill = 'blue' , anchor = 'w' , tags = thetag ) ] = 1 return mismatches , match , objs
This draws a primer OR any comparison sequence above the main sequence
This draws a primer OR any comparison sequence above the main sequence
"""This draws a primer OR any comparison sequence above the main sequence""" # Draw the primer # Reverse # Write the 5' or 3' # First find the y value, corrected for scale and no. of sequences etc. # This needs to be only done once, so use the dummy ytmp value when doing # get_base_pos_on_screen after this #move primer further up, if the comparison DNA sequence is displayed #raise up primer correct no. of 'levels' os it is just above highest one #raise mutliple levels when many comparison sequences displayed # Now draw the primer/seq # If we are still within the parent sequence then detect differences # # Draw primer/seq. If the seq has a name then add the tag for that. # # Write the end symbol
self
this_primer
colour
thetag
seqname
lvl