Ghost/EM_effect.py
def load_csv(self,filename=None,group=None):
        """Open a file with chem shift data"""
        self.exp_group_selected=group
        #
        # Make sure we have the expdata array
        #
        if not hasattr(self,'expdata'):
            self.expdata={}
        
        #
        # Load data
        #
        import tkFileDialog, os
        savedir=os.getcwd()
        if not filename:
            filename=tkFileDialog.askopenfilename(defaultextension="*.csv",
                                                  initialdir=savedir,
                                                  filetypes=[("Comma separated","*.csv"),("All files","*.*")])
        if filename:
            if os.path.isfile(filename):
                if not self.exp_group_selected:
                    #
                    # Ask which titratable group the data should be associated with
                    #
                    exp_titgroup=Toplevel()
                    exp_titgroup.transient()
                    exp_titgroup.title('Select titratable group for experimental data')
                    self.select_titgrp_frompdb(window=exp_titgroup)
                    chemshift_type=IntVar()
                    Label(exp_titgroup,text='Chemical shift for').grid(row=11,column=0)
                    Radiobutton(exp_titgroup,
                                text='Backbone amide nitrogen',
                                value=0,
                                variable=chemshift_type).grid(row=11,column=1)
                    Radiobutton(exp_titgroup,
                                text='Backbone amide hydrogen',
                                value=1,
                                variable=chemshift_type).grid(row=11,column=2)
                    chemshift_type.set(0)
                    def select_groups():
                        self.exp_group_selected=self.titgroups_inPDB[int(self.LB_groups.curselection()[0])]
                        if chemshift_type.get()==1:
                            self.exp_group_selected=self.exp_group_selected+' - H'
                        else:
                            self.exp_group_selected=self.exp_group_selected+' - N'
                        exp_titgroup.destroy()
                        return
                    Button(exp_titgroup,text='Select Group(s)',command=select_groups).grid(row=10,column=0)
                    self.EM_window.wait_window(exp_titgroup)
                #
                # Read the data
                #
                fd = open(filename,'r')
                lines=fd.readlines()
                fd.close()
                self.expdata[self.exp_group_selected]=[]
                for line in lines[1:]:
                    import string
                    line=string.strip(line)
                    sp=line.split(',')
                    resnum=int(sp[0][1:-4])
                    span=float(sp[1])
                    self.expdata[self.exp_group_selected].append([resnum,span])
                    x,y=self.get_xy(resnum,span)
                    x1,y0=self.get_xy(resnum+1,0)
                    handle=self.tc.create_rectangle(x,y,x1-2,y0,fill='green',stipple='gray50')
                #
                # Add it to the listbox
                #
                self.LB_exp_data.insert(END,self.exp_group_selected)
            else:
                import tkMessageBox
                tkMessageBox.showwarning('Cannot load experimental data file',
                                         'File: %s not found' %filename, parent=self.EM_window)
                return
        return
Open a file with chem shift data
Open a file with chem shift data
Open a file with chem shift data
def load_csv(self,filename=None,group=None):
        self.exp_group_selected=group
         Make sure we have the expdata array
        if not hasattr(self,'expdata'):
            self.expdata={}
         Load data
        import tkFileDialog, os
        savedir=os.getcwd()
        if not filename:
            filename=tkFileDialog.askopenfilename(defaultextension="*.csv",
                                                  initialdir=savedir,
                                                  filetypes=[("Comma separated","*.csv"),("All files","*.*")])
        if filename:
            if os.path.isfile(filename):
                if not self.exp_group_selected:
                     Ask which titratable group the data should be associated with
                    exp_titgroup=Toplevel()
                    exp_titgroup.transient()
                    exp_titgroup.title('Select titratable group for experimental data')
                    self.select_titgrp_frompdb(window=exp_titgroup)
                    chemshift_type=IntVar()
                    Label(exp_titgroup,text='Chemical shift for').grid(row=11,column=0)
                    Radiobutton(exp_titgroup,
                                text='Backbone amide nitrogen',
                                value=0,
                                variable=chemshift_type).grid(row=11,column=1)
                    Radiobutton(exp_titgroup,
                                text='Backbone amide hydrogen',
                                value=1,
                                variable=chemshift_type).grid(row=11,column=2)
                    chemshift_type.set(0)
                    def select_groups():
                        self.exp_group_selected=self.titgroups_inPDB[int(self.LB_groups.curselection()[0])]
                        if chemshift_type.get()==1:
                            self.exp_group_selected=self.exp_group_selected+' - H'
                        else:
                            self.exp_group_selected=self.exp_group_selected+' - N'
                        exp_titgroup.destroy()
                        return
                    Button(exp_titgroup,text='Select Group(s)',command=select_groups).grid(row=10,column=0)
                    self.EM_window.wait_window(exp_titgroup)
                 Read the data
                fd = open(filename,'r')
                lines=fd.readlines()
                fd.close()
                self.expdata[self.exp_group_selected]=[]
                for line in lines[1:]:
                    import string
                    line=string.strip(line)
                    sp=line.split(',')
                    resnum=int(sp[0][1:-4])
                    span=float(sp[1])
                    self.expdata[self.exp_group_selected].append([resnum,span])
                    x,y=self.get_xy(resnum,span)
                    x1,y0=self.get_xy(resnum+1,0)
                    handle=self.tc.create_rectangle(x,y,x1-2,y0,fill='green',stipple='gray50')
                 Add it to the listbox
                self.LB_exp_data.insert(END,self.exp_group_selected)
            else:
                import tkMessageBox
                tkMessageBox.showwarning('Cannot load experimental data file',
                                         'File: %s not found' %filename, parent=self.EM_window)
                return
        return
def load_csv ( self , filename = None , group = None ) : self . exp_group_selected = group if not hasattr ( self , 'expdata' ) : self . expdata = { } import tkFileDialog , os savedir = os . getcwd ( ) if not filename : filename = tkFileDialog . askopenfilename ( defaultextension = "*.csv" , initialdir = savedir , filetypes = [ ( "Comma separated" , "*.csv" ) , ( "All files" , "*.*" ) ] ) if filename : if os . path . isfile ( filename ) : if not self . exp_group_selected : exp_titgroup = Toplevel ( ) exp_titgroup . transient ( ) exp_titgroup . title ( 'Select titratable group for experimental data' ) self . select_titgrp_frompdb ( window = exp_titgroup ) chemshift_type = IntVar ( ) Label ( exp_titgroup , text = 'Chemical shift for' ) . grid ( row = 11 , column = 0 ) Radiobutton ( exp_titgroup , text = 'Backbone amide nitrogen' , value = 0 , variable = chemshift_type ) . grid ( row = 11 , column = 1 ) Radiobutton ( exp_titgroup , text = 'Backbone amide hydrogen' , value = 1 , variable = chemshift_type ) . grid ( row = 11 , column = 2 ) chemshift_type . set ( 0 ) def select_groups ( ) : self . exp_group_selected = self . titgroups_inPDB [ int ( self . LB_groups . curselection ( ) [ 0 ] ) ] if chemshift_type . get ( ) == 1 : self . exp_group_selected = self . exp_group_selected + ' - H' else : self . exp_group_selected = self . exp_group_selected + ' - N' exp_titgroup . destroy ( ) return Button ( exp_titgroup , text = 'Select Group(s)' , command = select_groups ) . grid ( row = 10 , column = 0 ) self . EM_window . wait_window ( exp_titgroup ) fd = open ( filename , 'r' ) lines = fd . readlines ( ) fd . close ( ) self . expdata [ self . exp_group_selected ] = [ ] for line in lines [ 1 : ] : import string line = string . strip ( line ) sp = line . split ( ',' ) resnum = int ( sp [ 0 ] [ 1 : - 4 ] ) span = float ( sp [ 1 ] ) self . expdata [ self . exp_group_selected ] . append ( [ resnum , span ] ) x , y = self . get_xy ( resnum , span ) x1 , y0 = self . get_xy ( resnum + 1 , 0 ) handle = self . tc . create_rectangle ( x , y , x1 - 2 , y0 , fill = 'green' , stipple = 'gray50' ) self . LB_exp_data . insert ( END , self . exp_group_selected ) else : import tkMessageBox tkMessageBox . showwarning ( 'Cannot load experimental data file' , 'File: %s not found' % filename , parent = self . EM_window ) return return
Open a file with chem shift data
Open a file with chem shift data
"""Open a file with chem shift data""" # # Make sure we have the expdata array # # # Load data # # # Ask which titratable group the data should be associated with # # # Read the data # # # Add it to the listbox #
self
filename
group