pKa/analyse_pKa_values.py
def select_interface(self):
        """
        # Little interface to select the group(s) we're interested in
        """
        Frame.__init__(self)
        self.master.title('Analysing pKa value decomposition')
        rowspan=8
        Label(self.master,text='Select groups to see decomposition analysis').grid(row=0,column=0)
        row=1
        yscrollbar=Scrollbar(self.master,orient='vertical',width=10)
        yscrollbar.grid(row=row,column=2,rowspan=rowspan,sticky='nws')
        #
        height=10
        self.group_disp=Listbox(self.master,bg='white',
                            fg='black',
                            height=height,width=25,
                            yscrollcommand= yscrollbar.set,
                            selectmode=EXTENDED)
        self.group_disp.grid(row=row,column=0,columnspan=2,rowspan=rowspan,sticky='news')
        yscrollbar.config(command=self.group_disp.yview)
        self.group_disp.delete(0, END)
        for group in self.groups:
            self.group_disp.insert(END,group)
        #
        # Do the two canvases
        #
        sizex=600
        sizey=500
        self.insystem_canv=make_canvas('In_system',xmax=sizex,ymax=sizey,window=self.master,x_padding=125,y_padding=125)
        self.insystem_canv.canv.grid(row=0,rowspan=10,column=10,sticky='news')
        self.exsystem_canv=make_canvas('Ex_system',xmax=sizex,ymax=sizey,window=self.master,x_padding=125,y_padding=125)
        self.exsystem_canv.canv.grid(row=0,rowspan=10,column=21,sticky='news')
        self.diff_canv=make_canvas('ABS(In_system / Ex_system)',xmax=sizex,ymax=sizey,window=self.master,x_padding=125,y_padding=125)
        self.diff_canv.canv.grid(row=11,rowspan=10,column=10,sticky='news')
        #
        # Plot the two first matrices
        #
        self.plot_matrix(self.in_data,self.insystem_canv,tagname='insystem')
        self.plot_matrix(self.ex_data,self.exsystem_canv,tagname='exsystem')
        #
        # Construct the diff matrix
        #
        diff={}
        for group1 in self.groups:
            diff[group1]={}
            for group2 in self.groups:
                if group1==group2:
                    diff[group1][group2]=None
                elif self.ex_data[group1][group2]!=0.0:
                    ratio=self.in_data[group1][group2]/self.ex_data[group1][group2]
                    if ratio<0.0:
                        print '%10s-%10s in: %5.3f, ex: %5.3f, ratio: %5.3f' %(group1,group2,
                                                                           self.in_data[group1][group2],
                                                                           self.ex_data[group1][group2],
                                                                           ratio)
                                                                           
                        diff[group1][group2]='yellow'
                    else:
                        diff[group1][group2]=ratio
                elif self.in_data[group1][group2]!=0.0:
                    diff[group1][group2]='green'
                    print '%10s-%10s in: %5.3f, ex: %5.3f' %(group1,group2,
                                                                           self.in_data[group1][group2],
                                                                           self.ex_data[group1][group2])
                else:
                    diff[group1][group2]='grey'
        #
        # Plot it
        #
        print 'General legend'
        print '---------------'
        print '-1.0: red, 0.0: white, 1.0: blue'
        print
        print 'Additional legend for ratio plot'
        print 'Yellow: Ratio < 0.0'
        print 'White: Ratio = 1.0'
        print 'Red: ratio 0.0 -> 1.0 (white) -> 2.0 (blue)'
        print 'Grey: no dpKa'
        print 'Green: in_system value is 0.0, but ex_system value is not! - very interesting!!'
        print

        self.diff_canv.set_scale(val_mid=1.0,val_min=0.0,val_max=2.0)
        self.plot_matrix(diff,self.diff_canv,tagname='diff',diffmode=1)
        #
        # Write the CSV files
        #
        import os
        filename=os.path.join(self.topdir,'autonomy_result.csv')
        fd=open(filename,'w')
        fd.write('Removed group, Monitored group, dpKa_in, dpKa_ex\n')
        for r_group in self.groups:
            for m_group in self.groups:
                if r_group==m_group:
                    continue
                fd.write('%10s, %10s, %5.3f, %5.3f\n' %(r_group,m_group,self.in_data[r_group][m_group],self.ex_data[r_group][m_group]))
        fd.close()
        #
        # All Done
        #
        return

        # Little interface to select the group(s) we're interested in
        
Little interface to select the group(s) we're interested in
Little interface to select the group ( s ) we ' re interested in
def select_interface(self):
        Frame.__init__(self)
        self.master.title('Analysing pKa value decomposition')
        rowspan=8
        Label(self.master,text='Select groups to see decomposition analysis').grid(row=0,column=0)
        row=1
        yscrollbar=Scrollbar(self.master,orient='vertical',width=10)
        yscrollbar.grid(row=row,column=2,rowspan=rowspan,sticky='nws')
        height=10
        self.group_disp=Listbox(self.master,bg='white',
                            fg='black',
                            height=height,width=25,
                            yscrollcommand= yscrollbar.set,
                            selectmode=EXTENDED)
        self.group_disp.grid(row=row,column=0,columnspan=2,rowspan=rowspan,sticky='news')
        yscrollbar.config(command=self.group_disp.yview)
        self.group_disp.delete(0, END)
        for group in self.groups:
            self.group_disp.insert(END,group)
         Do the two canvases
        sizex=600
        sizey=500
        self.insystem_canv=make_canvas('In_system',xmax=sizex,ymax=sizey,window=self.master,x_padding=125,y_padding=125)
        self.insystem_canv.canv.grid(row=0,rowspan=10,column=10,sticky='news')
        self.exsystem_canv=make_canvas('Ex_system',xmax=sizex,ymax=sizey,window=self.master,x_padding=125,y_padding=125)
        self.exsystem_canv.canv.grid(row=0,rowspan=10,column=21,sticky='news')
        self.diff_canv=make_canvas('ABS(In_system / Ex_system)',xmax=sizex,ymax=sizey,window=self.master,x_padding=125,y_padding=125)
        self.diff_canv.canv.grid(row=11,rowspan=10,column=10,sticky='news')
         Plot the two first matrices
        self.plot_matrix(self.in_data,self.insystem_canv,tagname='insystem')
        self.plot_matrix(self.ex_data,self.exsystem_canv,tagname='exsystem')
         Construct the diff matrix
        diff={}
        for group1 in self.groups:
            diff[group1]={}
            for group2 in self.groups:
                if group1==group2:
                    diff[group1][group2]=None
                elif self.ex_data[group1][group2]!=0.0:
                    ratio=self.in_data[group1][group2]/self.ex_data[group1][group2]
                    if ratio<0.0:
                        print '%10s-%10s in: %5.3f, ex: %5.3f, ratio: %5.3f' %(group1,group2,
                                                                           self.in_data[group1][group2],
                                                                           self.ex_data[group1][group2],
                                                                           ratio)
                        diff[group1][group2]='yellow'
                    else:
                        diff[group1][group2]=ratio
                elif self.in_data[group1][group2]!=0.0:
                    diff[group1][group2]='green'
                    print '%10s-%10s in: %5.3f, ex: %5.3f' %(group1,group2,
                                                                           self.in_data[group1][group2],
                                                                           self.ex_data[group1][group2])
                else:
                    diff[group1][group2]='grey'
         Plot it
        print 'General legend'
        print '---------------'
        print '-1.0: red, 0.0: white, 1.0: blue'
        print
        print 'Additional legend for ratio plot'
        print 'Yellow: Ratio < 0.0'
        print 'White: Ratio = 1.0'
        print 'Red: ratio 0.0 -> 1.0 (white) -> 2.0 (blue)'
        print 'Grey: no dpKa'
        print 'Green: in_system value is 0.0, but ex_system value is not! - very interesting!!'
        print
        self.diff_canv.set_scale(val_mid=1.0,val_min=0.0,val_max=2.0)
        self.plot_matrix(diff,self.diff_canv,tagname='diff',diffmode=1)
         Write the CSV files
        import os
        filename=os.path.join(self.topdir,'autonomy_result.csv')
        fd=open(filename,'w')
        fd.write('Removed group, Monitored group, dpKa_in, dpKa_ex\n')
        for r_group in self.groups:
            for m_group in self.groups:
                if r_group==m_group:
                    continue
                fd.write('%10s, %10s, %5.3f, %5.3f\n' %(r_group,m_group,self.in_data[r_group][m_group],self.ex_data[r_group][m_group]))
        fd.close()
         All Done
        return
def select_interface ( self ) : Frame . __init__ ( self ) self . master . title ( 'Analysing pKa value decomposition' ) rowspan = 8 Label ( self . master , text = 'Select groups to see decomposition analysis' ) . grid ( row = 0 , column = 0 ) row = 1 yscrollbar = Scrollbar ( self . master , orient = 'vertical' , width = 10 ) yscrollbar . grid ( row = row , column = 2 , rowspan = rowspan , sticky = 'nws' ) height = 10 self . group_disp = Listbox ( self . master , bg = 'white' , fg = 'black' , height = height , width = 25 , yscrollcommand = yscrollbar . set , selectmode = EXTENDED ) self . group_disp . grid ( row = row , column = 0 , columnspan = 2 , rowspan = rowspan , sticky = 'news' ) yscrollbar . config ( command = self . group_disp . yview ) self . group_disp . delete ( 0 , END ) for group in self . groups : self . group_disp . insert ( END , group ) sizex = 600 sizey = 500 self . insystem_canv = make_canvas ( 'In_system' , xmax = sizex , ymax = sizey , window = self . master , x_padding = 125 , y_padding = 125 ) self . insystem_canv . canv . grid ( row = 0 , rowspan = 10 , column = 10 , sticky = 'news' ) self . exsystem_canv = make_canvas ( 'Ex_system' , xmax = sizex , ymax = sizey , window = self . master , x_padding = 125 , y_padding = 125 ) self . exsystem_canv . canv . grid ( row = 0 , rowspan = 10 , column = 21 , sticky = 'news' ) self . diff_canv = make_canvas ( 'ABS(In_system / Ex_system)' , xmax = sizex , ymax = sizey , window = self . master , x_padding = 125 , y_padding = 125 ) self . diff_canv . canv . grid ( row = 11 , rowspan = 10 , column = 10 , sticky = 'news' ) self . plot_matrix ( self . in_data , self . insystem_canv , tagname = 'insystem' ) self . plot_matrix ( self . ex_data , self . exsystem_canv , tagname = 'exsystem' ) diff = { } for group1 in self . groups : diff [ group1 ] = { } for group2 in self . groups : if group1 == group2 : diff [ group1 ] [ group2 ] = None elif self . ex_data [ group1 ] [ group2 ] != 0.0 : ratio = self . in_data [ group1 ] [ group2 ] / self . ex_data [ group1 ] [ group2 ] if ratio < 0.0 : print '%10s-%10s in: %5.3f, ex: %5.3f, ratio: %5.3f' % ( group1 , group2 , self . in_data [ group1 ] [ group2 ] , self . ex_data [ group1 ] [ group2 ] , ratio ) diff [ group1 ] [ group2 ] = 'yellow' else : diff [ group1 ] [ group2 ] = ratio elif self . in_data [ group1 ] [ group2 ] != 0.0 : diff [ group1 ] [ group2 ] = 'green' print '%10s-%10s in: %5.3f, ex: %5.3f' % ( group1 , group2 , self . in_data [ group1 ] [ group2 ] , self . ex_data [ group1 ] [ group2 ] ) else : diff [ group1 ] [ group2 ] = 'grey' print 'General legend' print '---------------' print '-1.0: red, 0.0: white, 1.0: blue' print print 'Additional legend for ratio plot' print 'Yellow: Ratio < 0.0' print 'White: Ratio = 1.0' print 'Red: ratio 0.0 -> 1.0 (white) -> 2.0 (blue)' print 'Grey: no dpKa' print 'Green: in_system value is 0.0, but ex_system value is not! - very interesting!!' print self . diff_canv . set_scale ( val_mid = 1.0 , val_min = 0.0 , val_max = 2.0 ) self . plot_matrix ( diff , self . diff_canv , tagname = 'diff' , diffmode = 1 ) import os filename = os . path . join ( self . topdir , 'autonomy_result.csv' ) fd = open ( filename , 'w' ) fd . write ( 'Removed group, Monitored group, dpKa_in, dpKa_ex\n' ) for r_group in self . groups : for m_group in self . groups : if r_group == m_group : continue fd . write ( '%10s, %10s, %5.3f, %5.3f\n' % ( r_group , m_group , self . in_data [ r_group ] [ m_group ] , self . ex_data [ r_group ] [ m_group ] ) ) fd . close ( ) return
Little interface to select the group(s) we're interested in
Little interface to select the group ( s ) we ' re interested in
"""
        # Little interface to select the group(s) we're interested in
        """ # # # Do the two canvases # # # Plot the two first matrices # # # Construct the diff matrix # # # Plot it # # # Write the CSV files # # # All Done #
self