Ghost/EM_effect.py
def update_EM_effect_prediction(self,do_yasara=None):
        """Recalculate all EM effects and redraw all"""
        #
        # Should we recolour yasara?
        #
        if self.yasara and do_yasara:
            do_yasara=True
        #
        # First delete the bars from last time
        #
        if not hasattr(self,'graph_bars'):
            self.graph_bars={}
        for bar in self.graph_bars.keys():
            self.tc.delete(bar)
        #
        # Loop over all groups we're looking at
        #
        yascom=[]
        for group_name,group_position,group_titration in self.selected_groups:
            #
            # Get the coordinate center of the charge that it titrating
            #
            print group_position
            resnumber=self.PI.resnum(group_position)
            group_type=self.PI.resname(group_position)
            group=self.PI.titgroups[group_type]
            xpos=0.0
            ypos=0.0
            zpos=0.0
            for atom in group['atoms']:
                xpos=xpos+self.PI.atoms[resnumber+':'+atom]['X']/float(len(group['atoms']))
                ypos=ypos+self.PI.atoms[resnumber+':'+atom]['Y']/float(len(group['atoms']))
                zpos=zpos+self.PI.atoms[resnumber+':'+atom]['Z']/float(len(group['atoms']))
            #
            # Get the properties
            #
            colour=self.group_properties[group_name]['colour']
            eff_diel=self.group_properties[group_name]['diel']
            charge=group['charge']
            display=self.group_properties[group_name]['display']
            if not display:
                continue

            atom_type=self.group_properties[group_name]['atom']
            #
            # Loop over all residues
            #
            residues=self.PI.residues.keys()
            residues.sort()
            import numpy
            #
            # Draw the new bars
            #
            for residue in residues:
                #
                # If not an AA, then skip
                #
                if not self.PI.isaa(residue):
                    continue
                #
                # Get the residue number
                #
                resnum=int(residue.split(':')[1])
                #
                # Get the value of the span
                #
                if self.ele_calc.get()=='Coulomb':
                    span,angle=self.get_dEF(residue,numpy.array([xpos,ypos,zpos]),charge,eff_diel,atom_type=atom_type)
                elif self.ele_calc.get()=='PBE':
                    span=self.get_span_from_PBE(residue,numpy.array([xpos,ypos,zpos]),charge,eff_diel,atom_type)
                    angle=0.0
                elif self.ele_calc.get()=='APBS':
                    span=self.get_span_from_PBE(residue,numpy.array([xpos,ypos,zpos]),charge,eff_diel,atom_type,APBS=True)
                else:
                    raise Exception,'Unknown method for calculating electric field'
                #
                # If we get None back then we could not calculate the value
                #
                if not span and not angle:
                    #
                    # Draw black circle
                    #
                    x,y=self.get_xy(resnum,0.2)
                    x1,y0=self.get_xy(resnum+1,-0.2)
                    handle=self.tc.create_oval(x,y,x1,y0,fill='black',stipple='warning')
                    self.balloon.tagbind(self.tc,handle,'Could not calculate span for %s' %residue)
                    #
                    # colour residue green in yasara
                    #
                    if do_yasara:
                        yascom.append('ColorRes %s,green' %(str(resnum)))
                else:
                    #
                    # value ok, plot it
                    #
                    x,y=self.get_xy(resnum,span)
                    x1,y0=self.get_xy(resnum+1,0)
                    handle=self.tc.create_rectangle(x,y,x1,y0,fill=colour)
                    self.balloon.tagbind(self.tc,handle,'%s, span: %5.3f, angle: %5.2f' %(residue,span,angle))
                    #
                    # colour residue in yasara
                    #
                    if do_yasara:
                        if span>0.0:
                            color=min(50*span,120)
                        else:
                            color=max(50*span,-120)
                        if color<0.0:
                            color=360+color
                        yascom.append('ColorRes(%s,%d)' %(str(resnum),int(color)))
                self.graph_bars[handle]=1
        if do_yasara:
            for com in yascom:
                self.yasara.run(com)
                print com
            self.yasara.Finish()
        return
Recalculate all EM effects and redraw all
Recalculate all EM effects and redraw all
Recalculate all EM effects and redraw all
def update_EM_effect_prediction(self,do_yasara=None):
         Should we recolour yasara?
        if self.yasara and do_yasara:
            do_yasara=True
         First delete the bars from last time
        if not hasattr(self,'graph_bars'):
            self.graph_bars={}
        for bar in self.graph_bars.keys():
            self.tc.delete(bar)
         Loop over all groups we're looking at
        yascom=[]
        for group_name,group_position,group_titration in self.selected_groups:
             Get the coordinate center of the charge that it titrating
            print group_position
            resnumber=self.PI.resnum(group_position)
            group_type=self.PI.resname(group_position)
            group=self.PI.titgroups[group_type]
            xpos=0.0
            ypos=0.0
            zpos=0.0
            for atom in group['atoms']:
                xpos=xpos+self.PI.atoms[resnumber+':'+atom]['X']/float(len(group['atoms']))
                ypos=ypos+self.PI.atoms[resnumber+':'+atom]['Y']/float(len(group['atoms']))
                zpos=zpos+self.PI.atoms[resnumber+':'+atom]['Z']/float(len(group['atoms']))
             Get the properties
            colour=self.group_properties[group_name]['colour']
            eff_diel=self.group_properties[group_name]['diel']
            charge=group['charge']
            display=self.group_properties[group_name]['display']
            if not display:
                continue
            atom_type=self.group_properties[group_name]['atom']
             Loop over all residues
            residues=self.PI.residues.keys()
            residues.sort()
            import numpy
             Draw the new bars
            for residue in residues:
                 If not an AA, then skip
                if not self.PI.isaa(residue):
                    continue
                 Get the residue number
                resnum=int(residue.split(':')[1])
                 Get the value of the span
                if self.ele_calc.get()=='Coulomb':
                    span,angle=self.get_dEF(residue,numpy.array([xpos,ypos,zpos]),charge,eff_diel,atom_type=atom_type)
                elif self.ele_calc.get()=='PBE':
                    span=self.get_span_from_PBE(residue,numpy.array([xpos,ypos,zpos]),charge,eff_diel,atom_type)
                    angle=0.0
                elif self.ele_calc.get()=='APBS':
                    span=self.get_span_from_PBE(residue,numpy.array([xpos,ypos,zpos]),charge,eff_diel,atom_type,APBS=True)
                else:
                    raise Exception,'Unknown method for calculating electric field'
                 If we get None back then we could not calculate the value
                if not span and not angle:
                     Draw black circle
                    x,y=self.get_xy(resnum,0.2)
                    x1,y0=self.get_xy(resnum+1,-0.2)
                    handle=self.tc.create_oval(x,y,x1,y0,fill='black',stipple='warning')
                    self.balloon.tagbind(self.tc,handle,'Could not calculate span for %s' %residue)
                     colour residue green in yasara
                    if do_yasara:
                        yascom.append('ColorRes %s,green' %(str(resnum)))
                else:
                     value ok, plot it
                    x,y=self.get_xy(resnum,span)
                    x1,y0=self.get_xy(resnum+1,0)
                    handle=self.tc.create_rectangle(x,y,x1,y0,fill=colour)
                    self.balloon.tagbind(self.tc,handle,'%s, span: %5.3f, angle: %5.2f' %(residue,span,angle))
                     colour residue in yasara
                    if do_yasara:
                        if span>0.0:
                            color=min(50*span,120)
                        else:
                            color=max(50*span,-120)
                        if color<0.0:
                            color=360+color
                        yascom.append('ColorRes(%s,%d)' %(str(resnum),int(color)))
                self.graph_bars[handle]=1
        if do_yasara:
            for com in yascom:
                self.yasara.run(com)
                print com
            self.yasara.Finish()
        return
def update_EM_effect_prediction ( self , do_yasara = None ) : if self . yasara and do_yasara : do_yasara = True if not hasattr ( self , 'graph_bars' ) : self . graph_bars = { } for bar in self . graph_bars . keys ( ) : self . tc . delete ( bar ) yascom = [ ] for group_name , group_position , group_titration in self . selected_groups : print group_position resnumber = self . PI . resnum ( group_position ) group_type = self . PI . resname ( group_position ) group = self . PI . titgroups [ group_type ] xpos = 0.0 ypos = 0.0 zpos = 0.0 for atom in group [ 'atoms' ] : xpos = xpos + self . PI . atoms [ resnumber + ':' + atom ] [ 'X' ] / float ( len ( group [ 'atoms' ] ) ) ypos = ypos + self . PI . atoms [ resnumber + ':' + atom ] [ 'Y' ] / float ( len ( group [ 'atoms' ] ) ) zpos = zpos + self . PI . atoms [ resnumber + ':' + atom ] [ 'Z' ] / float ( len ( group [ 'atoms' ] ) ) colour = self . group_properties [ group_name ] [ 'colour' ] eff_diel = self . group_properties [ group_name ] [ 'diel' ] charge = group [ 'charge' ] display = self . group_properties [ group_name ] [ 'display' ] if not display : continue atom_type = self . group_properties [ group_name ] [ 'atom' ] residues = self . PI . residues . keys ( ) residues . sort ( ) import numpy for residue in residues : if not self . PI . isaa ( residue ) : continue resnum = int ( residue . split ( ':' ) [ 1 ] ) if self . ele_calc . get ( ) == 'Coulomb' : span , angle = self . get_dEF ( residue , numpy . array ( [ xpos , ypos , zpos ] ) , charge , eff_diel , atom_type = atom_type ) elif self . ele_calc . get ( ) == 'PBE' : span = self . get_span_from_PBE ( residue , numpy . array ( [ xpos , ypos , zpos ] ) , charge , eff_diel , atom_type ) angle = 0.0 elif self . ele_calc . get ( ) == 'APBS' : span = self . get_span_from_PBE ( residue , numpy . array ( [ xpos , ypos , zpos ] ) , charge , eff_diel , atom_type , APBS = True ) else : raise Exception , 'Unknown method for calculating electric field' if not span and not angle : x , y = self . get_xy ( resnum , 0.2 ) x1 , y0 = self . get_xy ( resnum + 1 , - 0.2 ) handle = self . tc . create_oval ( x , y , x1 , y0 , fill = 'black' , stipple = 'warning' ) self . balloon . tagbind ( self . tc , handle , 'Could not calculate span for %s' % residue ) if do_yasara : yascom . append ( 'ColorRes %s,green' % ( str ( resnum ) ) ) else : x , y = self . get_xy ( resnum , span ) x1 , y0 = self . get_xy ( resnum + 1 , 0 ) handle = self . tc . create_rectangle ( x , y , x1 , y0 , fill = colour ) self . balloon . tagbind ( self . tc , handle , '%s, span: %5.3f, angle: %5.2f' % ( residue , span , angle ) ) if do_yasara : if span > 0.0 : color = min ( 50 * span , 120 ) else : color = max ( 50 * span , - 120 ) if color < 0.0 : color = 360 + color yascom . append ( 'ColorRes(%s,%d)' % ( str ( resnum ) , int ( color ) ) ) self . graph_bars [ handle ] = 1 if do_yasara : for com in yascom : self . yasara . run ( com ) print com self . yasara . Finish ( ) return
Recalculate all EM effects and redraw all
Recalculate all EM effects and redraw all
"""Recalculate all EM effects and redraw all""" # # Should we recolour yasara? # # # First delete the bars from last time # # # Loop over all groups we're looking at # # # Get the coordinate center of the charge that it titrating # # # Get the properties # # # Loop over all residues # # # Draw the new bars # # # If not an AA, then skip # # # Get the residue number # # # Get the value of the span # # # If we get None back then we could not calculate the value # # # Draw black circle # # # colour residue green in yasara # # # value ok, plot it # # # colour residue in yasara #
self
do_yasara