Quantitative Aquatic Toxicity: T. pyriformis (pIGC50) Dashboard

DrugBank database
MolPort database
Python script number 109 to build the frequency distribution graph of the pyriformis_toxicity parameter on DrugBank molecules.
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
from matplotlib.patches import Patch
import numpy as np

# 1. PASTE YOUR DATA HERE (T. pyriformis Toxicity (pIGC50, -log mg/L))
datos_crudos = """Bin Center	% Frequency
-2.4	0.169851380042463
-2.2	0.679405520169851
-2	0.849256900212314
-1.8	1.31634819532909
-1.6	1.48619957537155
-1.4	1.86836518046709
-1.2	1.82590233545648
-1	2.84501061571125
-0.8	3.01486199575372
-0.6	3.82165605095541
-0.4	4.07643312101911
-0.2	4.79830148619958
0	4.11889596602972
0.2	5.30785562632696
0.4	6.02972399150743
0.6	6.58174097664544
0.8	6.4968152866242
1	6.07218683651805
1.2	6.36942675159236
1.4	6.41188959660297
1.6	6.96390658174098
1.8	5.98726114649681
2	4.84076433121019
2.2	4.11889596602972
2.4	2.33545647558386
2.6	1.18895966029724
2.8	0.424628450106157"""

# 2. PROCESSING
lineas = datos_crudos.strip().split('\n')[1:] 
bins_array = []
freq_array = []

for linea in lineas:
    b, f = linea.strip().split() 
    bins_array.append(float(b))
    freq_array.append(float(f))

bins = np.array(bins_array)
freq = np.array(freq_array)

# Colors
def get_colors(b_array):
    return ['#008000' if b < -0.5 else '#FFD700' if b <= 1.0 else '#B22222' for b in b_array]

colors_hex = get_colors(bins)
face_colors = [mcolors.to_rgba(c, alpha=0.60) for c in colors_hex]
edge_colors = [mcolors.to_rgba(c, alpha=0.90) for c in colors_hex]

# 3. PLOT
plt.figure(figsize=(7, 6))

plt.bar(bins, freq, width=0.18, color=face_colors, edgecolor=edge_colors, linewidth=1.5, zorder=2)

# 4. LABELS
plt.xlabel('T. pyriformis Toxicity (pIGC50, -log mg/L)', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('Quantitative Aquatic Toxicity: T. pyriformis (pIGC50)', fontsize=14)

legend_elements = [
    Patch(facecolor=mcolors.to_rgba('#008000', 0.6), edgecolor='#008000', label='Non-Toxic (< -0.5)'),
    Patch(facecolor=mcolors.to_rgba('#FFD700', 0.6), edgecolor='#FFD700', label='Toxic (-0.5 to 1.0)'),
    Patch(facecolor=mcolors.to_rgba('#B22222', 0.6), edgecolor='#B22222', label='Highly Toxic (> 1.0)')
]

plt.legend(handles=legend_elements, loc='upper left', framealpha=0.95, fontsize=10)
plt.grid(axis='y', linestyle=':', alpha=0.7, zorder=0)

plt.xlim(min(bins) - 0.2, max(bins) + 0.2)
plt.ylim(0, max(freq) * 1.2) 
plt.tight_layout()

plt.show()