def test_get_labels(self): contacts_per_cluster, contacts_per_residue = histogram.parse_contacts(TestDataManaging.small_contacts_file_name) labels = get_labels(contacts_per_cluster) self.assertItemsEqual(labels, contacts_per_residue.keys()) ordered_labels = ['181:TYR:A', '266:GLY:A', '268:ASP:A', '329:ARG:A', '333:GLN:A', '337:TYR:A', '340:ASN:A', '395:ASP:A', '421:LYS:A', '442:SER:A', '461:ARG:A', '527:TRP:A', '528:SER:A'] self.assertSequenceEqual(ordered_labels, labels)
t_c_p_d = get_total_contacts_per_protein_and_drug(data["contacts_per_residue"], proteins, drugs, num_atoms_per_drug, frames_per_prot_drug) db = pd.DataFrame.from_dict(t_c_p_d) sns.barplot(x="Protein", y="Contacts", hue="Drug", data = db) plt.savefig(os.path.join(options.results, "total_contacts.svg")) # PLOT CONTACTS PER RESIDUE f, axes = plt.subplots(len(proteins), len(drugs), sharey='row') f.subplots_adjust(hspace=0.3, 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): contacts_per_cluster = data["contacts_per_cluster"][protein][drug] contact_residue_labels = get_labels(contacts_per_cluster) weight = num_atoms_per_drug[drug]*frames_per_prot_drug[protein][drug] 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)