filtered_contact_residue_labels =  filter_less_contacts_than(THRESHOLD, 
                                                                      contact_residue_labels, 
                                                                      data["contacts_per_residue"][protein][drug])
         plot_histogram_to_axis(axes[i,j],
                                protein, drug, contacts_per_cluster, 
                                filtered_contact_residue_labels, 
                                colors, weight, False)
         axes[i,j].xaxis.grid()
         axes[i,j].set_aspect("auto")
         if i == 0:
             axes[i,j].set_title(drug)
         if j == 0:
             axes[i,j].set_ylabel(protein)
         axes[i,j].autoscale(tight=True)
 
 scale_axes_to_max_val(axes, len(proteins), len(drugs))
 plt.savefig(os.path.join(options.results, "contacts_per_residue_and_cluster_histogram.svg"))
 plt.close()
     
 
 # PLOT CONTACTS PER MOTIF
 contacts_per_motif_and_cluster = calc_contacts_per_cluster_per_motif_for_prots_and_drugs(proteins, drugs, data, num_atoms_per_drug, frames_per_prot_drug, motifs, ordered_motifs)
 
 f, axes = plt.subplots(len(proteins), len(drugs), sharex='col', sharey='row')
 f.subplots_adjust(hspace=0.1, wspace=0.1 )
 f.set_size_inches(9, 18, forward=True)
 colors = sns.color_palette("hls", 15)
 for i, protein in enumerate(proteins):
     for j, drug in enumerate(drugs):
         weight = num_atoms_per_drug[drug]*frames_per_prot_drug[protein][drug]
         base = numpy.zeros(len(ordered_motifs)) 
Exemplo n.º 2
0
                        )
                        calculator = RMSDCalculator(
                            calculatorType="QCP_OMP_CALCULATOR",
                            fittingCoordsets=cas.getCoordsets(),
                            calculationCoordsets=motif_cas.getCoordsets(),
                        )
                        rmsds = calculator.oneVsFollowing(0)
                        rmsd_results[protein]["RMSD"].extend(rmsds)
                        rmsd_results[protein]["Drug"].extend([drug] * len(rmsds))
                        rmsd_results[protein]["Motif"].extend([motif] * len(rmsds))
                        del cas
                        del motif_cas
                del pdb

        pickle.dump(rmsd_results, open(os.path.join(options.results, "rmsd_results.pickle"), "w"))
    else:
        rmsd_results = pickle.load(open(options.data))

    f, axes = plt.subplots(3, 2, sharey="row")
    f.subplots_adjust(hspace=0.4, wspace=0.1)
    f.set_size_inches(10, 18, forward=True)

    for i, protein in enumerate(ordered_proteins):
        r = rmsd_results[protein]
        sns.barplot(r["Motif"], r["RMSD"], hue=r["Drug"], ax=axes[i / 2, i % 2])
        axes[i / 2, i % 2].set_title(protein)
        plt.setp(axes[i / 2, i % 2].xaxis.get_majorticklabels(), rotation=45)
    scale_axes_to_max_val(axes, 3, 2)
    f.suptitle("Trajectory RMSD per motif")
    plt.savefig(os.path.join(options.results, "motif_rmsd.svg"))