コード例 #1
0
  def plot(self, axes, labels, restocolor) :
    """
    Plot the fractal on a pie chart

    Parameters
    axes : tuple of Axis object
      the axis to draw the lower and upper leaflet pie chart
    labels : tuple of strings
      the labels to draw next to each axis
    restocolor : list of int
      residues to color
    """

    def draw_pies(axis,fractal,cent,rad,reverseY) :

      c = plt.Circle(cent.T,rad,ec='k',fc=None,fill=False)
      axis.add_patch(c)
      fractal2 = (fractal - self.minval) / (self.maxval - self.minval)
      for val,e1,e2 in zip(fractal2,self.edges[:-1],self.edges[1:]) :
        w = patches.Wedge(cent.T,rad,e1,e2,ec='k',fc='k',alpha=0.1)
        axis.add_patch(w)
        if reverseY :
          x = -rad*np.cos(e1*np.pi/180.0)
          y = rad*np.sin(e1*np.pi/180.0)
          ee2 = 180.0*np.arctan2(y,x)/np.pi
          x = -rad*np.cos(e2*np.pi/180.0)
          y = rad*np.sin(e2*np.pi/180.0)
          ee1 =  180.0*np.arctan2(y,x)/np.pi
          w = patches.Wedge(cent.T,rad,ee1,ee2,ec=plt.cm.RdYlBu_r(val),fc=plt.cm.RdYlBu_r(val),width=5)
        else :
          w = patches.Wedge(cent.T,rad,e1,e2,ec=plt.cm.RdYlBu_r(val),fc=plt.cm.RdYlBu_r(val),width=5)
        axis.add_patch(w)

    if self.fractal_low is None : return

    gpcr_lib.plot_density_xray(axes[0],0,"",0,0,self.xray,"low","Intra.",number=None,plotn=False,drawchol=False, specialres=restocolor)
    gpcr_lib.plot_density_xray(axes[1],0,"",0,0,self.xray,"upp","Extra.",number=None,plotn=False,drawchol=False, specialres=restocolor)

    rad = 30.0
    cent = np.array([0.0,0.0])
    draw_pies(axes[0],self.fractal_low,cent,rad,False)
    draw_pies(axes[1],self.fractal_upp,cent,rad,True)

    for a,l in zip(axes,labels) :
      a.text(-40,38,l)
      a.set_xticklabels([])
      a.set_yticklabels([])
コード例 #2
0
    def plot(self, axes, labels, restocolor):
        """
    Plot the fractal on a pie chart

    Parameters
    axes : tuple of Axis object
      the axis to draw the lower and upper leaflet pie chart
    labels : tuple of strings
      the labels to draw next to each axis
    restocolor : list of int
      residues to color
    """
        def draw_pies(axis, fractal, cent, rad, reverseY):

            c = plt.Circle(cent.T, rad, ec='k', fc=None, fill=False)
            axis.add_patch(c)
            fractal2 = (fractal - self.minval) / (self.maxval - self.minval)
            for val, e1, e2 in zip(fractal2, self.edges[:-1], self.edges[1:]):
                w = patches.Wedge(cent.T,
                                  rad,
                                  e1,
                                  e2,
                                  ec='k',
                                  fc='k',
                                  alpha=0.1)
                axis.add_patch(w)
                if reverseY:
                    x = -rad * np.cos(e1 * np.pi / 180.0)
                    y = rad * np.sin(e1 * np.pi / 180.0)
                    ee2 = 180.0 * np.arctan2(y, x) / np.pi
                    x = -rad * np.cos(e2 * np.pi / 180.0)
                    y = rad * np.sin(e2 * np.pi / 180.0)
                    ee1 = 180.0 * np.arctan2(y, x) / np.pi
                    w = patches.Wedge(cent.T,
                                      rad,
                                      ee1,
                                      ee2,
                                      ec=plt.cm.RdYlBu_r(val),
                                      fc=plt.cm.RdYlBu_r(val),
                                      width=5)
                else:
                    w = patches.Wedge(cent.T,
                                      rad,
                                      e1,
                                      e2,
                                      ec=plt.cm.RdYlBu_r(val),
                                      fc=plt.cm.RdYlBu_r(val),
                                      width=5)
                axis.add_patch(w)

        if self.fractal_low is None: return

        gpcr_lib.plot_density_xray(axes[0],
                                   0,
                                   "",
                                   0,
                                   0,
                                   self.xray,
                                   "low",
                                   "Intra.",
                                   number=None,
                                   plotn=False,
                                   drawchol=False,
                                   specialres=restocolor)
        gpcr_lib.plot_density_xray(axes[1],
                                   0,
                                   "",
                                   0,
                                   0,
                                   self.xray,
                                   "upp",
                                   "Extra.",
                                   number=None,
                                   plotn=False,
                                   drawchol=False,
                                   specialres=restocolor)

        rad = 30.0
        cent = np.array([0.0, 0.0])
        draw_pies(axes[0], self.fractal_low, cent, rad, False)
        draw_pies(axes[1], self.fractal_upp, cent, rad, True)

        for a, l in zip(axes, labels):
            a.text(-40, 38, l)
            a.set_xticklabels([])
            a.set_yticklabels([])
コード例 #3
0
ファイル: gpcr_plot_density.py プロジェクト: syn2018/Scripts
    minval = min(densities1.min(args.plot),densities2.min(args.plot))
  else :
    minval = args.min
  print "Max = %.2f and min = %E"%(maxval,minval)

  # Convenient arrays to loop over
  # we will use them below to make tighter code
  densities = [densities1,densities2]
  xray = [xray1,xray2]
  sides = ["low","upp"]

  # Lower leaflets
  fig_low = plt.figure(1)
  for i in range(2) : # Plot each density in its own subplot
    a = fig_low.add_subplot(1,2,i+1)
    im = gpcr_lib.plot_density_xray(a,densities[i].low,args.plot,minval,maxval,xray[i],"low",labels[i])
  gpcr_lib.draw_colormap(fig_low,im)
  fig_low.savefig(args.out+"_low.png",format="png")

  # Upper leaflet
  fig_upp = plt.figure(2)
  for i in range(2) :
    a = fig_upp.add_subplot(1,2,i+1)
    im = gpcr_lib.plot_density_xray(a,densities[i].upp,args.plot,minval,maxval,xray[i],"upp",labels[i+2])
  gpcr_lib.draw_colormap(fig_upp,im)
  fig_upp.savefig(args.out+"_upp.png",format="png")

  # Both leaflets
  fig_both = plt.figure(10)
  for i,(dxi,si,label,number) in enumerate(zip([0,1,0,1],[0,0,1,1,],labels[:4],["A)","B)","C)","D)"]),1) :
    # dxi is the index into the densities and xray array, 
コード例 #4
0
  
  # Read Xray structure and densities
  xray      = gpcr_lib.load_xray(args.mol)
  densities = [gpcr_lib.standard_read_and_process(args.files,args.density)]
  for r in args.replacement[1:] :
    filenames = [f.replace(args.replacement[0],r) for f in args.files]
    densities.append(gpcr_lib.standard_read_and_process(filenames,args.density))

  if args.plot == "average" :
    for d in densities : d.cutoff_av(cutoff=0.15)  

  if args.max is None :
    maxval = max(*[d.max(args.plot) for d in densities])
  else :
    maxval = args.max
  if args.min is None :
    minval = min(*[d.min(args.plot) for d in densities])
  else :
    minval = args.min
  print "Max = %.2f and min = %E"%(maxval,minval)

  # Plot the series
  for i,side in enumerate(["low","upp"],1) : # Loop over sides
    f = plt.figure(i)
    for i,(density,label,number) in enumerate(zip(densities,args.label,["A)","B)","C)","D)"]),1) :
      a = f.add_subplot(2,2,i) 
      im = gpcr_lib.plot_density_xray(a,density[side],args.plot,minval,maxval,xray,side,label,number,plotn=True)
    gpcr_lib.draw_colormap(f,im)
    f.savefig("%s_%s_%s.png"%(args.out,args.density,side),format="png",dpi=300)

コード例 #5
0
    for i, (grid,
            leaflet) in enumerate(zip([grid_low, grid_upp], ["low", "upp"]),
                                  1):
        a = fig.add_subplot(1, 2, i)
        gridrm = np.ones([70, 70, 4])
        gridrm[grid < 0.0, 3] = 0.0
        if leaflet == "upp":
            grid = grid[:, ::-1]
            gridrm = gridrm[:, ::-1]
        im = a.imshow(grid,
                      extent=[-35, 35, -35, 35],
                      origin="lower",
                      cmap=plt.cm.YlOrRd_r)
        a.imshow(gridrm, extent=[-35, 35, -35, 35], origin="lower")
        gpcr_lib.plot_density_xray(a,
                                   None,
                                   "",
                                   0,
                                   0,
                                   xray,
                                   leaflet,
                                   gpcr_lib.side_name[leaflet].capitalize(),
                                   number=None,
                                   plotn=False,
                                   drawchol=False)

    ax = gpcr_lib.draw_colormap(fig, im, text='[kJ/mol]')
    ax.text(1.03, 0.80, 'Energy')

    fig.savefig("gridenergy.png", format="png")
コード例 #6
0
    if args.max is None:
        maxval = max(*[d.max(args.plot) for d in densities])
    else:
        maxval = args.max
    if args.min is None:
        minval = min(*[d.min(args.plot) for d in densities])
    else:
        minval = args.min
    print "Max = %.2f and min = %E" % (maxval, minval)

    # Plot the series
    for i, side in enumerate(["low", "upp"], 1):  # Loop over sides
        f = plt.figure(i)
        for i, (density, label, number) in enumerate(
                zip(densities, args.label, ["A)", "B)", "C)", "D)"]), 1):
            a = f.add_subplot(2, 2, i)
            im = gpcr_lib.plot_density_xray(a,
                                            density[side],
                                            args.plot,
                                            minval,
                                            maxval,
                                            xray,
                                            side,
                                            label,
                                            number,
                                            plotn=True)
        gpcr_lib.draw_colormap(f, im)
        f.savefig("%s_%s_%s.png" % (args.out, args.density, side),
                  format="png",
                  dpi=300)
コード例 #7
0
         lj[diff2>(1.2*1.2)] = 0.0
         grid[x+xylen/2-1,y+xylen/2-1,z+zlen/2-1] = lj.sum()
         #print gridcoord*10.0,lj.sum()

  grid[grid>0.0] = 0.0

  # Write out the 3D grid
  origin = midcoord + np.array([-xylen/2,-xylen/2,-zlen/2])
  _writeDX(grid,origin,1.0,"gridenergy.dx")

  # Plot 2D plot as average over z-dim
  grid_low = grid[:,:,:zlen/2].mean(axis=2)
  grid_upp = grid[:,:,zlen/2:].mean(axis=2)

  fig = plt.figure(1)
  for i,(grid,leaflet) in enumerate(zip([grid_low,grid_upp],["low","upp"]),1) :
    a = fig.add_subplot(1,2,i)
    gridrm = np.ones([70,70,4])
    gridrm[grid<0.0,3] = 0.0
    if leaflet == "upp" :
      grid = grid[:,::-1]
      gridrm = gridrm[:,::-1]
    im = a.imshow(grid,extent=[-35,35,-35,35],origin="lower",cmap=plt.cm.YlOrRd_r)
    a.imshow(gridrm,extent=[-35,35,-35,35],origin="lower")
    gpcr_lib.plot_density_xray(a,None,"",0,0,xray,leaflet,gpcr_lib.side_name[leaflet].capitalize(),number=None,plotn=False,drawchol=False)

  ax = gpcr_lib.draw_colormap(fig,im, text='')
  ax.text(1.03,0.80,'$\mathrm{Energy}$')

  fig.savefig("gridenergy.png",format="png")