Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
xbb_search.XDNAsearch Class Reference
Inheritance diagram for xbb_search.XDNAsearch:
Inheritance graph
[legend]
Collaboration diagram for xbb_search.XDNAsearch:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def init_graphics
def config_color
def change_color
def get_pattern
def do_search
def exit
def showcolor
def init_alphabet
def SetSeq
def SetPattern
def IUPAC2regex
def Search
def SearchAll

Public Attributes

 master
 highlight
 colors
 sequence
 cur_pos
 frame
 search_entry
 forward
 cancel
 current_color
 colorb
 current_tag
 alphabet
 pattern
 rx_pattern
 rx

Detailed Description

Definition at line 74 of file xbb_search.py.


Constructor & Destructor Documentation

def xbb_search.XDNAsearch.__init__ (   self,
  seq = '',
  master = None,
  highlight = 0 
)

Definition at line 75 of file xbb_search.py.

00075 
00076     def __init__(self, seq= '', master= None, highlight = 0):
00077         DNAsearch.__init__(self)
00078         self.master = master
00079         self.highlight = highlight
00080         self.colors = []
00081         self.init_graphics()
00082         self.sequence = seq
00083         self.cur_pos = 0
        

Member Function Documentation

Definition at line 124 of file xbb_search.py.

00124 
00125     def change_color(self):
00126         self.config_color()
00127         self.colorb.configure(foreground = self.current_color)
00128         self.colorb.update()
            

Here is the call graph for this function:

def xbb_search.XDNAsearch.config_color (   self,
  color = None 
)

Definition at line 111 of file xbb_search.py.

00111 
00112     def config_color(self, color = None):
00113         if not self.highlight: return
00114         if not color:
00115             try:
00116                 color = askcolor()[1]
00117             except:
00118                 color = 'cyan'
00119         self.current_color = color
00120         self.current_tag = 'searched_%s' % self.current_color
00121         self.master.tag_config(self.current_tag, background=self.current_color)
00122         self.master.tag_config(self.current_tag+'R', background=self.current_color, underline = 1)
00123         self.colors.append(color)
        

Here is the caller graph for this function:

def xbb_search.XDNAsearch.do_search (   self,
  other_strand = 0 
)

Definition at line 133 of file xbb_search.py.

00133 
00134     def do_search(self, other_strand = 0):
00135         pattern = self.get_pattern()
00136         if other_strand: pattern = reverse_complement(pattern)
00137         self.SetPattern(pattern)
00138         pos = self.Search(self.cur_pos)
00139         self.cur_pos = pos +1
00140         w = self.master
00141         if pos != -1:
00142             if self.highlight:
00143                 start, stop = pos, pos + len(self.pattern)
00144                 if other_strand:
00145                     w.tag_add(self.current_tag+'R', '1.%d' % start, '1.%s' % stop)
00146                 else:
00147                     w.tag_add(self.current_tag, '1.%d' % start, '1.%s' % stop)
00148                 w.see('1.%d' % start)
00149 
00150 
    

Here is the call graph for this function:

Definition at line 151 of file xbb_search.py.

00151 
00152     def exit(self):
00153         for c in self.colors:
00154             self.master.tag_remove('searched_%s' % c, 1.0, END)
00155             self.master.tag_remove('searched_%sR' % c, 1.0, END)
00156         self.destroy()
00157         del(self)
    

Definition at line 129 of file xbb_search.py.

00129 
00130     def get_pattern(self):
00131         pattern = self.search_entry.get()
00132         return pattern
        

Here is the caller graph for this function:

def xbb_search.DNAsearch.init_alphabet (   self) [inherited]

Definition at line 22 of file xbb_search.py.

00022 
00023     def init_alphabet(self):
00024         self.alphabet = ambiguous_dna_values
00025         other = ''.join(self.alphabet.keys())
00026         self.alphabet['N'] = self.alphabet['N'] + other
00027         for key in self.alphabet.keys():
00028             if key == 'N': continue
00029             if key in self.alphabet[key]: continue
00030             self.alphabet[key] = self.alphabet[key] + key

Here is the caller graph for this function:

Definition at line 84 of file xbb_search.py.

00084 
00085     def init_graphics(self):
00086         Toplevel.__init__(self, self.master)
00087         self.frame = Frame(self)
00088         self.frame.pack(fill = BOTH, expand = 1)
00089 
00090         self.search_entry = Entry(self.frame)
00091         self.search_entry.pack(fill = BOTH, expand = 1)
00092 
00093         f2 = Frame(self.frame)
00094         f2.pack(side = TOP, fill = BOTH, expand = 1)
00095         
00096         f = f2
00097         self.forward = Button(f, text = 'Search +', command = self.do_search)
00098         self.forward.pack(side = LEFT)
00099         self.forward = Button(f, text = 'Search -',
00100                               command = lambda x=self.do_search: x(other_strand=1))
00101         self.forward.pack(side = LEFT)
00102         self.cancel = Button(f, text = 'Cancel', command = self.exit)
00103         self.cancel.pack(side = LEFT)
00104         self.current_color = 'cyan'
00105         self.colorb = Button(f, text = 'Color', command = self.change_color, foreground = self.current_color)
00106         self.colorb.pack(side = LEFT)
00107         self.config_color(self.current_color)
00108 
00109         
00110 
        
def xbb_search.DNAsearch.IUPAC2regex (   self,
  s 
) [inherited]

Definition at line 38 of file xbb_search.py.

00038 
00039     def IUPAC2regex(self, s):
00040         rx = ''
00041         for i in s:
00042             r = self.alphabet.get(i,i)
00043             if len(r) > 1:
00044                 rx = '%s[%s]' % (rx, r)
00045             else:
00046                 rx += r
00047         return rx
    
def xbb_search.DNAsearch.Search (   self,
  start = 0 
) [inherited]

Definition at line 52 of file xbb_search.py.

00052 
00053     def Search(self, start = 0):
00054         pos = self.rx.search(self.sequence, start)
00055         if pos:
00056             return pos.start()
00057         else:
00058             return -1
00059         

Here is the caller graph for this function:

def xbb_search.DNAsearch.SearchAll (   self) [inherited]

Definition at line 60 of file xbb_search.py.

00060 
00061     def SearchAll(self):
00062         pos = -1
00063         positions = []
00064         while 1:
00065             m   = self._Search(pos+1)
00066             if not m: break
00067             pos = m.start()
00068             if pos == -1:
00069                 break
00070             
00071             positions.append(pos)
00072         return positions
00073     
        

Here is the call graph for this function:

def xbb_search.DNAsearch.SetPattern (   self,
  pattern 
) [inherited]

Definition at line 33 of file xbb_search.py.

00033 
00034     def SetPattern(self, pattern):
00035         self.pattern = pattern
00036         self.rx_pattern = self.IUPAC2regex(pattern)
00037         self.rx = re.compile(self.rx_pattern)
    

Here is the caller graph for this function:

def xbb_search.DNAsearch.SetSeq (   self,
  seq 
) [inherited]

Definition at line 31 of file xbb_search.py.

00031 
00032     def SetSeq(self, seq): self.sequence = seq
    

Definition at line 158 of file xbb_search.py.

00158 
00159     def showcolor(self):
00160         pass
00161 
00162     


Member Data Documentation

Definition at line 23 of file xbb_search.py.

Definition at line 101 of file xbb_search.py.

Definition at line 104 of file xbb_search.py.

Definition at line 79 of file xbb_search.py.

Definition at line 82 of file xbb_search.py.

Definition at line 103 of file xbb_search.py.

Definition at line 119 of file xbb_search.py.

Definition at line 96 of file xbb_search.py.

Definition at line 86 of file xbb_search.py.

Definition at line 78 of file xbb_search.py.

Definition at line 77 of file xbb_search.py.

Definition at line 34 of file xbb_search.py.

Definition at line 36 of file xbb_search.py.

Definition at line 35 of file xbb_search.py.

Definition at line 89 of file xbb_search.py.

Reimplemented from xbb_search.DNAsearch.

Definition at line 81 of file xbb_search.py.


The documentation for this class was generated from the following file: