def save_primer_indesign(self): """Save the selected primer to the primer database""" if self.primer_result.curselection(): selection = int(str(self.primer_result.curselection()[0])) name_selected = self.primer_order[selection] this_primer = self.foundprimers[name_selected] if getattr(self,'pDB_open',None): #pass a reference to the current primer db window primerdbwin = self.pDB_open self.save_primer(self.primer_win,primerdbwin,this_primer,'from design') else: #If the pDB was not found open the window and lower it self.pDB_open = primer_database.primer_database(i_parent=self) self.pDB_open.pDB_win.lower() primerdbwin = self.pDB_open self.save_primer(self.primer_win,primerdbwin,this_primer,'from design') else: tkMessageBox.showwarning("No Selection",'Please create or select your primer', parent=self.primer_win) return
def save_primer_indesign(self): """Save the selected primer to the primer database""" if self.primer_result.curselection(): selection = int(str(self.primer_result.curselection()[0])) name_selected = self.primer_order[selection] this_primer = self.foundprimers[name_selected] if getattr(self, 'pDB_open', None): #pass a reference to the current primer db window primerdbwin = self.pDB_open self.save_primer(self.primer_win, primerdbwin, this_primer, 'from design') else: #If the pDB was not found open the window and lower it self.pDB_open = primer_database.primer_database(i_parent=self) self.pDB_open.pDB_win.lower() primerdbwin = self.pDB_open self.save_primer(self.primer_win, primerdbwin, this_primer, 'from design') else: tkMessageBox.showwarning("No Selection", 'Please create or select your primer', parent=self.primer_win) return
def do_evaluate_primer(self,parent=None,i_parent=None,edit_primer_seq=None, edit_primer_descr=None, edit_primer_name=None): # Import functions from primer_database self.pDB=primer_database.primer_database(i_parent=self,no_window=1) # Who is the parent? if not parent: parent=self.master self.i_parent=None else: self.i_parent=i_parent # # Open a window for entering primer data # self.eval_win=Toplevel() if edit_primer_seq: self.eval_win.title('Edit primer') else: self.eval_win.title('Add primer') self.eval_win.geometry('+%d+%d' %(parent.winfo_rootx()+50, parent.winfo_rooty()+50)) # Create the string variables and attach them to entry widgets self.primername_var=StringVar() lab=Label(self.eval_win,text='Primer Name:') lab.grid(row=0,column=0,sticky='news') Ebox=Entry(self.eval_win,textvariable=self.primername_var,width=50) Ebox.grid(row=0,column=1,columnspan=2,sticky='news') self.eval_var=StringVar() lab=Label(self.eval_win,text='Sequence:') lab.grid(row=1,column=0,sticky='news') Ebox=Entry(self.eval_win,textvariable=self.eval_var,width=50) Ebox.grid(row=1,column=1,columnspan=2,sticky='news') self.descr_var=StringVar() desclab=Label(self.eval_win,text='Description:') desclab.grid(row=2,column=0,sticky='news') Ebox=Entry(self.eval_win,textvariable=self.descr_var,width=50) Ebox.grid(row=2,column=1,columnspan=2,sticky='news') # # Do recalculate and close buttons # row=3 recalc=Button(self.eval_win,text='Recalculate',command=self.update_eval) recalc.grid(row=row,column=0,sticky='news') close=Button(self.eval_win,text='Close',command=self.close_eval) close.grid(row=row,column=1,sticky='news') # # Create button for adding to the primer library and set entry values if editing # a primer that is already present in the database # if edit_primer_seq: addp=Button(self.eval_win,text='Save primer',command=self.save_primer_from_edit) self.eval_var.set(edit_primer_seq) self.primername_var.set(edit_primer_name) self.descr_var.set(edit_primer_descr) self.edit_primer_name=edit_primer_name else: addp=Button(self.eval_win,text='Save primer',command=self.save_primer) addp.grid(row=row,column=2,sticky='news') # # Hairpin propensity row=row+1 self.eval_hairpin=StringVar() self.eval_hairpin.set('No primer entered') l2=Label(self.eval_win,text='Hairpin propensity:') l2.grid(row=row,column=0,sticky='w') stat=Label(self.eval_win,textvariable=self.eval_hairpin) stat.grid(row=row,column=1,sticky='news') # # Primer-dimer # row=row+1 self.eval_primerdimer=StringVar() self.eval_primerdimer.set('No primer entered') l2=Label(self.eval_win,text='Self complementarity:') l2.grid(row=row,column=0,sticky='w') stat=Label(self.eval_win,textvariable=self.eval_primerdimer) stat.grid(row=row,column=1,sticky='news') # # Tm # row=row+1 self.eval_Tm=StringVar() self.eval_Tm.set('No primer entered') l2=Label(self.eval_win,text='Tm:') l2.grid(row=row,column=0,sticky='w') stat=Label(self.eval_win,textvariable=self.eval_Tm) stat.grid(row=row,column=1,sticky='news') # # Tm calculation method # self.eval_Tm_method=StringVar() self.eval_Tm_method.set(self.Tm_method) stat=Label(self.eval_win,textvariable=self.eval_Tm_method) stat.grid(row=row,column=2,sticky='news') # # # self.eval_win.bind('<KeyPress>',self.update_eval) self.eval_win.grab_set() Ebox.focus_set() self.update_eval() return self.eval_win
def __init__(self): """Dummy constructor""" import primer_database self.pDB=primer_database.primer_database(self,1) return
def _design_primer(self): # Clear text boxes self.detailed_results.delete(1.0,END) self.primer_result.delete(0, END) # Get an instance of the primer DB if not getattr(self,'pDB',None): import primer_database self.pDB=primer_database.primer_database(self,1) # Clear any previous details shown in the sequence window self.pDB.clear_pDB_objects() #self.pDB.display_primer([],delete=1,only_delete=1) # Get the melting temp try: Tm_des=self.TM_desired.get() if Tm_des<40 or Tm_des>85: import tkMessageBox tkMessageBox.showwarning("Invalid Tm",'Please give a temperature in Celcius from 40 - 85', parent=self.primer_win) return except: tkMessageBox.showwarning("Invalid Tm",'Please give a temperature in Celcius from 40 - 85', parent=self.primer_win) return # Get start and stop try: AA_number=self.resnum.get()-self.data['ORF_selected']['aastart_number'] except: tkMessageBox.showwarning("Invalid AA number",'Please give a number from %d to %d' %(self.data['ORF_selected']['aastart_number'], self.data['ORF_selected']['aastart_number']+self.data['ORF_selected']['length']-1), parent=self.primer_win) return # Check for out of range if AA_number>self.data['ORF_selected']['length']-1 or AA_number<0: import tkMessageBox print self.data['ORF_selected'] tkMessageBox.showwarning("AA number out of range",'Please give a number from %d to %d' %(self.data['ORF_selected']['aastart_number'], self.data['ORF_selected']['aastart_number']+self.data['ORF_selected']['length']-1), parent=self.primer_win) return # Modify AA_number to get correct number in DNA sequence AA_number_inORF=AA_number AA_number=AA_number+self.data['ORF_selected']['start'] new_AA=self.new_res.get() # check that the user selected a new AA if new_AA=='Select': import tkMessageBox tkMessageBox.showwarning("No new AA type selected",'You have to select a new residue type', parent=self.primer_win) return # Warn if the new and old AA type are the same old_AA=self.data['ORF_selected']['aaseq3'][AA_number_inORF] if new_AA==old_AA: import tkMessageBox if not tkMessageBox.askyesno("No AA change", "This mutation will not make a change in the amino acid sequence.\nContinue anyway?", parent=self.primer_win): return # Should we look for a restriction site? if self.silent_mut.get()==1: find_restriction_site=1 else: find_restriction_site=None # Adjust the DNA sequence according to frame offset=self.data['ORF_selected']['frame']-1 DNA_seq=self.data['DNAseq'][offset:] # Open a progress window self.progress_win=Toplevel() self.progress_win.transient(self.primer_win) self.progress_win.focus_set() self.progress_win.title('Primer design progress') self.progress_win.geometry('+300+150') self.prog_x=300 self.prog_can=Canvas(self.progress_win,bg='white',width=self.prog_x,height=180) self.prog_can.grid(row=0,column=0) self.progress=IntVar() self.xl=Label(self.progress_win,textvariable=self.progress) self.xl.grid(row=1,column=0) self.box=None self.master.update() # Start the generation of primers self.cancelled=None print 'AA_number',AA_number import mutation primers_results_dict, new_enzymes, enzymes_that_already_cut=mutation.exhaustive_research(DNA_seq,AA_number, new_AA,Tm_des,self.Tm_meth, enzyme_list=self.data['used_enzymes'], parent=self) if not primers_results_dict: self.progress_win.destroy() return # Insert primers in the listbox self.prog_can.create_text(5,105,text="Removing useless primers",anchor='nw') self.master.update() self.foundprimers = {} count=0 for primer_seq in primers_results_dict.keys(): # Filter the primers without new restriction sites if so specified count=count+1 name='Primer %4d' %count if not new_enzymes.has_key(primer_seq) and find_restriction_site: continue elif not new_enzymes.has_key(primer_seq): self.foundprimers[name]={} self.foundprimers[name]['introduced_sites']=[] else: self.foundprimers[name]={} self.foundprimers[name]['introduced_sites']=new_enzymes[primer_seq] # Add the rest self.foundprimers[name]['sequence']=primer_seq self.foundprimers[name]['Tm']=primers_results_dict[primer_seq]['Tm'] # Copy the other properties for property in primers_results_dict[primer_seq].keys(): self.foundprimers[name][property]=primers_results_dict[primer_seq][property] # Delete primers that are not bringing any benefit to_delete={} count=0 for primer in self.foundprimers.keys(): frac_done=float(count)/float(len(self.foundprimers.keys())) self.update_primer_progress(frac_done,4) count=count+1 cuts=self.foundprimers[primer]['introduced_sites'] mism1=self.foundprimers[primer]['mismatches'] for primer2 in self.foundprimers.keys(): if primer==primer2: continue # Compare with Other primer if cuts==self.foundprimers[primer2]['introduced_sites']: mism2=self.foundprimers[primer2]['mismatches'] if mism2<mism1: to_delete[primer]=1 # Delete all primer that have been tagged for delete in to_delete.keys(): del self.foundprimers[delete] # Fill the listbox, sort by number of mismatches self.primer_result.delete(0, END) self.primer_names=self.foundprimers.keys() self.primer_names.sort() self.primer_order=[] for mismatch in range(20): for primer_name in self.primer_names: if self.foundprimers[primer_name]['mismatches']==mismatch: self.primer_result.insert(END,primer_name+': %2d mism, Tm: %4.1f' %(mismatch, self.foundprimers[primer_name]['Tm'])) self.primer_order.append(primer_name) # Close the progress window self.progress_win.destroy() self.master.update() # Did we find any primers? if len(self.primer_order)==0: import tkMessageBox tkMessageBox.showwarning('No primers found','I could not find any primers that match your criteria.\nAlter the query and try again.') return # Bind button-1 presses to action #self.primer_result.bind("<Double-Button-1>",self.display_detailed_results) self.primer_result.bind("<ButtonRelease-1>",self.display_detailed_results) return
def _design_primer(self): # Clear text boxes self.detailed_results.delete(1.0, END) self.primer_result.delete(0, END) # Get an instance of the primer DB if not getattr(self, 'pDB', None): import primer_database self.pDB = primer_database.primer_database(self, 1) # Clear any previous details shown in the sequence window self.pDB.clear_pDB_objects() #self.pDB.display_primer([],delete=1,only_delete=1) # Get the melting temp try: Tm_des = self.TM_desired.get() if Tm_des < 40 or Tm_des > 85: import tkMessageBox tkMessageBox.showwarning( "Invalid Tm", 'Please give a temperature in Celcius from 40 - 85', parent=self.primer_win) return except: tkMessageBox.showwarning( "Invalid Tm", 'Please give a temperature in Celcius from 40 - 85', parent=self.primer_win) return # Get start and stop try: AA_number = self.resnum.get( ) - self.data['ORF_selected']['aastart_number'] except: tkMessageBox.showwarning( "Invalid AA number", 'Please give a number from %d to %d' % (self.data['ORF_selected']['aastart_number'], self.data['ORF_selected']['aastart_number'] + self.data['ORF_selected']['length'] - 1), parent=self.primer_win) return # Check for out of range if AA_number > self.data['ORF_selected']['length'] - 1 or AA_number < 0: import tkMessageBox print self.data['ORF_selected'] tkMessageBox.showwarning( "AA number out of range", 'Please give a number from %d to %d' % (self.data['ORF_selected']['aastart_number'], self.data['ORF_selected']['aastart_number'] + self.data['ORF_selected']['length'] - 1), parent=self.primer_win) return # Modify AA_number to get correct number in DNA sequence AA_number_inORF = AA_number AA_number = AA_number + self.data['ORF_selected']['start'] new_AA = self.new_res.get() # check that the user selected a new AA if new_AA == 'Select': import tkMessageBox tkMessageBox.showwarning("No new AA type selected", 'You have to select a new residue type', parent=self.primer_win) return # Warn if the new and old AA type are the same old_AA = self.data['ORF_selected']['aaseq3'][AA_number_inORF] if new_AA == old_AA: import tkMessageBox if not tkMessageBox.askyesno( "No AA change", "This mutation will not make a change in the amino acid sequence.\nContinue anyway?", parent=self.primer_win): return # Should we look for a restriction site? if self.silent_mut.get() == 1: find_restriction_site = 1 else: find_restriction_site = None # Adjust the DNA sequence according to frame offset = self.data['ORF_selected']['frame'] - 1 DNA_seq = self.data['DNAseq'][offset:] # Open a progress window self.progress_win = Toplevel() self.progress_win.transient(self.primer_win) self.progress_win.focus_set() self.progress_win.title('Primer design progress') self.progress_win.geometry('+300+150') self.prog_x = 300 self.prog_can = Canvas(self.progress_win, bg='white', width=self.prog_x, height=180) self.prog_can.grid(row=0, column=0) self.progress = IntVar() self.xl = Label(self.progress_win, textvariable=self.progress) self.xl.grid(row=1, column=0) self.box = None self.master.update() # Start the generation of primers self.cancelled = None print 'AA_number', AA_number import mutation primers_results_dict, new_enzymes, enzymes_that_already_cut = mutation.exhaustive_research( DNA_seq, AA_number, new_AA, Tm_des, self.Tm_meth, enzyme_list=self.data['used_enzymes'], parent=self) if not primers_results_dict: self.progress_win.destroy() return # Insert primers in the listbox self.prog_can.create_text(5, 105, text="Removing useless primers", anchor='nw') self.master.update() self.foundprimers = {} count = 0 for primer_seq in primers_results_dict.keys(): # Filter the primers without new restriction sites if so specified count = count + 1 name = 'Primer %4d' % count if not new_enzymes.has_key(primer_seq) and find_restriction_site: continue elif not new_enzymes.has_key(primer_seq): self.foundprimers[name] = {} self.foundprimers[name]['introduced_sites'] = [] else: self.foundprimers[name] = {} self.foundprimers[name]['introduced_sites'] = new_enzymes[ primer_seq] # Add the rest self.foundprimers[name]['sequence'] = primer_seq self.foundprimers[name]['Tm'] = primers_results_dict[primer_seq][ 'Tm'] # Copy the other properties for property in primers_results_dict[primer_seq].keys(): self.foundprimers[name][property] = primers_results_dict[ primer_seq][property] # Delete primers that are not bringing any benefit to_delete = {} count = 0 for primer in self.foundprimers.keys(): frac_done = float(count) / float(len(self.foundprimers.keys())) self.update_primer_progress(frac_done, 4) count = count + 1 cuts = self.foundprimers[primer]['introduced_sites'] mism1 = self.foundprimers[primer]['mismatches'] for primer2 in self.foundprimers.keys(): if primer == primer2: continue # Compare with Other primer if cuts == self.foundprimers[primer2]['introduced_sites']: mism2 = self.foundprimers[primer2]['mismatches'] if mism2 < mism1: to_delete[primer] = 1 # Delete all primer that have been tagged for delete in to_delete.keys(): del self.foundprimers[delete] # Fill the listbox, sort by number of mismatches self.primer_result.delete(0, END) self.primer_names = self.foundprimers.keys() self.primer_names.sort() self.primer_order = [] for mismatch in range(20): for primer_name in self.primer_names: if self.foundprimers[primer_name]['mismatches'] == mismatch: self.primer_result.insert( END, primer_name + ': %2d mism, Tm: %4.1f' % (mismatch, self.foundprimers[primer_name]['Tm'])) self.primer_order.append(primer_name) # Close the progress window self.progress_win.destroy() self.master.update() # Did we find any primers? if len(self.primer_order) == 0: import tkMessageBox tkMessageBox.showwarning( 'No primers found', 'I could not find any primers that match your criteria.\nAlter the query and try again.' ) return # Bind button-1 presses to action #self.primer_result.bind("<Double-Button-1>",self.display_detailed_results) self.primer_result.bind("<ButtonRelease-1>", self.display_detailed_results) return
def do_evaluate_primer(self, parent=None, i_parent=None, edit_primer_seq=None, edit_primer_descr=None, edit_primer_name=None): # Import functions from primer_database self.pDB = primer_database.primer_database(i_parent=self, no_window=1) # Who is the parent? if not parent: parent = self.master self.i_parent = None else: self.i_parent = i_parent # # Open a window for entering primer data # self.eval_win = Toplevel() if edit_primer_seq: self.eval_win.title('Edit primer') else: self.eval_win.title('Add primer') self.eval_win.geometry( '+%d+%d' % (parent.winfo_rootx() + 50, parent.winfo_rooty() + 50)) # Create the string variables and attach them to entry widgets self.primername_var = StringVar() lab = Label(self.eval_win, text='Primer Name:') lab.grid(row=0, column=0, sticky='news') Ebox = Entry(self.eval_win, textvariable=self.primername_var, width=50) Ebox.grid(row=0, column=1, columnspan=2, sticky='news') self.eval_var = StringVar() lab = Label(self.eval_win, text='Sequence:') lab.grid(row=1, column=0, sticky='news') Ebox = Entry(self.eval_win, textvariable=self.eval_var, width=50) Ebox.grid(row=1, column=1, columnspan=2, sticky='news') self.descr_var = StringVar() desclab = Label(self.eval_win, text='Description:') desclab.grid(row=2, column=0, sticky='news') Ebox = Entry(self.eval_win, textvariable=self.descr_var, width=50) Ebox.grid(row=2, column=1, columnspan=2, sticky='news') # # Do recalculate and close buttons # row = 3 recalc = Button(self.eval_win, text='Recalculate', command=self.update_eval) recalc.grid(row=row, column=0, sticky='news') close = Button(self.eval_win, text='Close', command=self.close_eval) close.grid(row=row, column=1, sticky='news') # # Create button for adding to the primer library and set entry values if editing # a primer that is already present in the database # if edit_primer_seq: addp = Button(self.eval_win, text='Save primer', command=self.save_primer_from_edit) self.eval_var.set(edit_primer_seq) self.primername_var.set(edit_primer_name) self.descr_var.set(edit_primer_descr) self.edit_primer_name = edit_primer_name else: addp = Button(self.eval_win, text='Save primer', command=self.save_primer) addp.grid(row=row, column=2, sticky='news') # # Hairpin propensity row = row + 1 self.eval_hairpin = StringVar() self.eval_hairpin.set('No primer entered') l2 = Label(self.eval_win, text='Hairpin propensity:') l2.grid(row=row, column=0, sticky='w') stat = Label(self.eval_win, textvariable=self.eval_hairpin) stat.grid(row=row, column=1, sticky='news') # # Primer-dimer # row = row + 1 self.eval_primerdimer = StringVar() self.eval_primerdimer.set('No primer entered') l2 = Label(self.eval_win, text='Self complementarity:') l2.grid(row=row, column=0, sticky='w') stat = Label(self.eval_win, textvariable=self.eval_primerdimer) stat.grid(row=row, column=1, sticky='news') # # Tm # row = row + 1 self.eval_Tm = StringVar() self.eval_Tm.set('No primer entered') l2 = Label(self.eval_win, text='Tm:') l2.grid(row=row, column=0, sticky='w') stat = Label(self.eval_win, textvariable=self.eval_Tm) stat.grid(row=row, column=1, sticky='news') # # Tm calculation method # self.eval_Tm_method = StringVar() self.eval_Tm_method.set(self.Tm_method) stat = Label(self.eval_win, textvariable=self.eval_Tm_method) stat.grid(row=row, column=2, sticky='news') # # # self.eval_win.bind('<KeyPress>', self.update_eval) self.eval_win.grab_set() Ebox.focus_set() self.update_eval() return self.eval_win
def __init__(self): """Dummy constructor""" import primer_database self.pDB = primer_database.primer_database(self, 1) return