Esempio n. 1
0
def plot_chem_shift_dist(title,residues, amino_acids):
    three_lets = [aa.three_let for aa in amino_acids]
    nuclei = ['CO', 'CA', 'CB', 'CG', 'CG1', 'CG2',
              'CD', 'CD1', 'CD2', 'CE', 'CE1', 'CE2',
              'CE3', 'CZ', 'CZ2', 'CZ3', 'CH2']
    colors = ['b','g','r','c','c','c',
              'm','m','m','y','y','y',
              'y','gray','gray','gray','k']
    
    means, stds = data_array(amino_acids, nuclei)
    fig = pl.figure()
    ax = Subplot(fig,111)
    ax = pl.gca()
    fig.add_subplot(ax)
    
    x = means
#    print nan_to_num(x)
    y = ones(x.shape)
    for i in range(0,x.shape[0]):
        y[i]*=i
        
    for j in range(0,x.shape[1]):
        ax.errorbar(x.T[j], y.T[j], xerr=nan_to_num(stds.T[j]), 
                    linestyle='None',marker='o', color=colors[j], 
                    label=(nuclei[j]), linewidth=4, capsize=20)
    
    for r in residues:
        x = ones_like(means)*nan
        name = r.name
        shifts, atoms = r.get_carbons(previous=False)
        for shift,atom in zip(shifts,atoms):
            if atom in nuclei:
                j = nuclei.index(atom)
#                if name != "NAA":
#                    name = one2Three(r.name[0])
                i = three_lets.index(name)
                x[i][j] = shift
        for j in range(0,x.shape[1]):
            ax.plot(x.T[j],y.T[j], marker="x",linestyle="None", color=colors[j],markersize=15)
    
    pl.yticks(arange(0,20), three_lets)
    pl.ylim(-1,20)
    pl.title('Verteilung chemischer Verschiebungen\n %s'%title)
    pl.ylabel('Aminosaeure')
    pl.xlabel('ppm')
    pl.rcParams.update({'font.size': 22})
    # Shink current axis by 20%
    box = ax.get_position()
    ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    
    # Put a legend to the right of the current axis
    ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
    pl.show()