Ames Mutagenicity Profile Dashboard

DrugBank database
MolPort database
Python script number 71 to build the frequency distribution graph of the Ames parameter on DrugBank molecules.
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
import numpy as np
from scipy.interpolate import make_interp_spline

# 1. Original Data (Ames Mutagenicity)
bin_centers = [0.0, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.0]

frequencies = [0.04, 8.54, 12.99, 11.85, 9.81, 9.34, 8.20, 5.69, 5.77, 4.88, 3.91, 4.16, 2.76, 2.59, 2.93, 1.49, 1.66, 1.70, 0.93, 0.72, 0.04]

# 2. Generate the smoothed curve (Spline)
x_smooth = np.linspace(min(bin_centers), max(bin_centers), 300)
spl = make_interp_spline(bin_centers, frequencies, k=3)
y_smooth = spl(x_smooth)
y_smooth = [val if val > 0 else 0 for val in y_smooth]

# 3. Colors (Green < 0.3, Gold up to 0.7, Red >= 0.7)
colors = []
for val in bin_centers:
    if val < 0.3:
        colors.append('green')
    elif val < 0.7:
        colors.append('gold')
    else:
        colors.append('firebrick')

# 4. Create the graph
plt.figure(figsize=(7, 6))

# Bars
plt.bar(bin_centers, frequencies, width=0.04, color=colors, edgecolor='black', alpha=0.6, label='Observed Data')

# 5. Tags and Titles
plt.xlabel('Probability of Ames Mutagenicity', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('Ames Mutagenicity Distribution', fontsize=14)

# Axle settings
plt.xticks(np.arange(0.0, 1.05, 0.1))
plt.xlim(-0.05, 1.05)
plt.ylim(0, 15)

# 6. Legend
legend_elements = [
    Patch(facecolor='green', edgecolor='black', label='Ames Negative (Safe)'),
    Patch(facecolor='gold', edgecolor='black', label='Structural Warning'),
    Patch(facecolor='firebrick', edgecolor='black', label='Ames Positive (DNA Hazard)'),
]

plt.legend(handles=legend_elements, loc='upper right', framealpha=0.95, fontsize=10)

plt.grid(axis='y', linestyle='--', alpha=0.5)
plt.tight_layout()

plt.show()