Import packages and load data¶

In [1]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from cypsummary import *
import glob, re, sys, os, importlib
import cypsummary
importlib.reload(cypsummary)
del analyze
from cypsummary import *
/net/galaxy/home/koes/dkoes/.local/lib/python3.10/site-packages/matplotlib/projections/__init__.py:63: UserWarning: Unable to import Axes3D. This may be due to multiple versions of Matplotlib being installed (e.g. as a system package and as a pip package). As a result, the 3D projection is not available.
  warnings.warn("Unable to import Axes3D. This may be due to multiple versions of "
In [2]:
df = pd.concat((pd.read_csv(f,index_col=0) for f in glob.glob('*.csv')), ignore_index=True)
In [3]:
df["ASP_min"] = df[[
    "ASP311_OD1_ave",
    "ASP311_OD2_ave",
    "ASP304_OD1_ave",
    "ASP304_OD2_ave"
]].min(axis=1)

Data¶

For some models the closest atom to the FE is not a carbon.

In [4]:
df
Out[4]:
label cyp ligand model charged avermsf nclusts nclustsperc featom avefe ... frac6fe ASP311_OD1_ave ASP311_OD1_std ASP311_OD2_ave ASP311_OD2_std ASP304_OD1_ave ASP304_OD1_std ASP304_OD2_ave ASP304_OD2_std ASP_min
0 cyp35b1_clemizole_models_model1 cyp35b1 clemizole models_model1 True 2.755680 5 99.833333 C28 7.004436 ... 0.332667 12.616459 0.993289 12.221389 1.326094 2.748673 0.105565 4.737415 0.196022 2.748673
1 cyp35b1_clemizole_models_model2 cyp35b1 clemizole models_model2 True 1.171633 2 100.000000 C28 8.624297 ... 0.000000 12.323451 0.891017 12.432032 1.049660 2.734250 0.086308 4.750673 0.144463 2.734250
2 cyp35b1_clemizole_models_model3 cyp35b1 clemizole models_model3 True 1.148177 5 99.833333 C31 10.216063 ... 0.000000 11.960422 0.968025 12.329617 0.935384 2.773906 0.110201 4.846911 0.141818 2.773906
3 cyp35b1_clemizole_models_model4 cyp35b1 clemizole models_model4 True 2.455778 31 49.366667 C25 7.946717 ... 0.073667 5.784297 1.587585 5.414953 1.520463 10.922581 0.711395 11.892527 1.050971 5.414953
4 cyp35b1_clemizole_models_model5 cyp35b1 clemizole models_model5 True 2.043223 10 82.966667 CL22 5.746361 ... 0.709333 11.238187 0.960753 11.264184 1.014249 3.197480 0.820171 5.081813 0.874114 3.197480
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
251 cyp35b2_azelastine_uncharged_models_model2 cyp35b2 azelastine uncharged_models_model2 False 2.751167 21 65.000000 C34 5.745116 ... 0.714000 6.970463 2.497723 6.842302 2.511325 12.630244 1.157978 12.571135 1.374061 6.842302
252 cyp35b2_azelastine_uncharged_models_model3 cyp35b2 azelastine uncharged_models_model3 False 2.522804 15 76.566667 O26 8.047019 ... 0.000667 6.038128 1.467116 5.974527 1.672112 12.019222 0.905342 13.261692 1.292404 5.974527
253 cyp35b2_azelastine_uncharged_models_model4 cyp35b2 azelastine uncharged_models_model4 False 2.294584 15 83.600000 C30 6.190050 ... 0.663333 6.573103 1.606960 6.533184 1.553055 13.117672 0.994050 14.413677 0.892222 6.533184
254 cyp35b2_azelastine_uncharged_models_model5 cyp35b2 azelastine uncharged_models_model5 False 2.445196 23 78.166667 CL27 5.142812 ... 0.797667 8.006782 1.601858 7.929558 1.567985 11.750858 1.524333 13.338495 1.342090 7.929558
255 cyp35b2_azelastine_uncharged_models_model6 cyp35b2 azelastine uncharged_models_model6 False 1.535395 7 94.766667 CL27 5.030561 ... 0.958333 7.065642 1.322088 6.749130 1.271836 11.852220 0.676716 13.222108 0.610477 6.749130

256 rows × 21 columns

Filtering out non-carbon close-to-FE models.

In [5]:
prefdf = df[~(df.featom.str.startswith('O') | df.featom.str.startswith('CL'))]
prefdf
Out[5]:
label cyp ligand model charged avermsf nclusts nclustsperc featom avefe ... frac6fe ASP311_OD1_ave ASP311_OD1_std ASP311_OD2_ave ASP311_OD2_std ASP304_OD1_ave ASP304_OD1_std ASP304_OD2_ave ASP304_OD2_std ASP_min
0 cyp35b1_clemizole_models_model1 cyp35b1 clemizole models_model1 True 2.755680 5 99.833333 C28 7.004436 ... 0.332667 12.616459 0.993289 12.221389 1.326094 2.748673 0.105565 4.737415 0.196022 2.748673
1 cyp35b1_clemizole_models_model2 cyp35b1 clemizole models_model2 True 1.171633 2 100.000000 C28 8.624297 ... 0.000000 12.323451 0.891017 12.432032 1.049660 2.734250 0.086308 4.750673 0.144463 2.734250
2 cyp35b1_clemizole_models_model3 cyp35b1 clemizole models_model3 True 1.148177 5 99.833333 C31 10.216063 ... 0.000000 11.960422 0.968025 12.329617 0.935384 2.773906 0.110201 4.846911 0.141818 2.773906
3 cyp35b1_clemizole_models_model4 cyp35b1 clemizole models_model4 True 2.455778 31 49.366667 C25 7.946717 ... 0.073667 5.784297 1.587585 5.414953 1.520463 10.922581 0.711395 11.892527 1.050971 5.414953
9 cyp35b2_clemizole_models_model4 cyp35b2 clemizole models_model4 True 1.951156 10 75.433333 C28 4.476287 ... 0.964000 6.192553 2.396453 6.225269 2.412194 7.962295 2.226264 9.597702 2.197542 6.192553
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
247 cyp35b1_azelastine_uncharged_model4 cyp35b1 azelastine uncharged_model4 False 1.468213 4 99.933333 C29 5.970015 ... 0.606333 7.066720 1.400919 7.114590 1.385066 12.735864 0.612221 12.783843 0.602896 7.066720
249 cyp35b1_azelastine_uncharged_model6 cyp35b1 azelastine uncharged_model6 False 1.540535 5 98.800000 C30 5.553536 ... 0.847333 7.214012 1.666787 7.425996 1.644505 12.695609 0.519363 13.072401 0.722250 7.214012
250 cyp35b2_azelastine_uncharged_models_model1 cyp35b2 azelastine uncharged_models_model1 False 1.515686 6 99.833333 C34 5.015954 ... 0.991667 7.749970 1.063150 7.505898 0.959403 10.544401 1.629440 12.396356 1.573657 7.505898
251 cyp35b2_azelastine_uncharged_models_model2 cyp35b2 azelastine uncharged_models_model2 False 2.751167 21 65.000000 C34 5.745116 ... 0.714000 6.970463 2.497723 6.842302 2.511325 12.630244 1.157978 12.571135 1.374061 6.842302
253 cyp35b2_azelastine_uncharged_models_model4 cyp35b2 azelastine uncharged_models_model4 False 2.294584 15 83.600000 C30 6.190050 ... 0.663333 6.573103 1.606960 6.533184 1.553055 13.117672 0.994050 14.413677 0.892222 6.533184

189 rows × 21 columns

Selecting single model closest (on average) to iron for each system.

In [6]:
df_min = prefdf.loc[
    prefdf.groupby(['cyp', 'ligand', 'charged'])['avefe'].idxmin()
].reset_index(drop=True)

Plotting Code¶

In [7]:
def plot_scatter(df_max):
    fig, ax = plt.subplots(figsize=(8, 6))

    df_max["ASP_min"] = df_max[[
        "ASP311_OD1_ave",
        "ASP311_OD2_ave",
        "ASP304_OD1_ave",
        "ASP304_OD2_ave"
    ]].min(axis=1)

    # Base scatter (color and shape by ligand/cyp)
    sns.scatterplot(
        data=df_max,
        x="ASP_min",
        y="avefe",
        hue="ligand",
        style="cyp",
        s=80,            # marker size
        edgecolor="black",  # temporary edge
        linewidth=1,
        ax=ax
    )
    
    # Overlay edges by 'charged' state
    # Suppose charged is boolean or categorical
    for charge_state, subdf in df_max.groupby("charged"):
        sns.scatterplot(
            data=subdf,
            x="ASP_min",
            y="avefe",
            hue=None,
            style="cyp",
            markers=True,
            s=80,
            facecolor="none",
            edgecolor="black" if charge_state else "white",
            linewidth=1,
            legend=False,
            ax=ax
        )
    
    # Tidy up legend and appearance
    ax.set_xlabel("Ave Distance to ASP311 or 304")
    ax.set_ylabel("Average FE Distance")
    ax.legend(bbox_to_anchor=(1.05, 1), loc="upper left", borderaxespad=0.)
    sns.despine()
    plt.tight_layout()
    plt.show()
In [8]:
from matplotlib.lines import Line2D

def orderplot(df,value,larger_better=True):
    if larger_better:
        df = df.loc[df.groupby(['cyp', 'ligand', 'charged'])[value].idxmax()].reset_index(drop=True)
    else:
        df = df.loc[df.groupby(['cyp', 'ligand', 'charged'])[value].idxmin()].reset_index(drop=True)

    # Make sure charged is boolean; if it's strings like "True"/"False", coerce:
    # df["charged"] = df["charged"].astype(bool)
    
    # Keep colors/shapes consistent across both panels
    cyp_order = sorted(df["cyp"].astype(str).unique())
    palette = dict(zip(cyp_order, sns.color_palette(n_colors=len(cyp_order))))
    markers = ["o", "s", "D", "^", "v", "P", "X", "*"]
    marker_map = {c: markers[i % len(markers)] for i, c in enumerate(cyp_order)}
        
    fig, axes = plt.subplots(1, 2, figsize=(12, 6), sharex=True,sharey=True, constrained_layout=True)
    
    panes = [
        ("charged = True", df[df["charged"] == True], axes[0]),
        ("charged = False", df[df["charged"] == False], axes[1]),
    ]
    
    for title, dsub, ax in panes:
        sns.scatterplot(
            data=dsub,
            x=value,
            y="ligand",
            hue="cyp",
            style="cyp",
            hue_order=cyp_order,
            style_order=cyp_order,
            markers=markers,        
            palette=palette,
            s=110,
            linewidth=0.8,
            edgecolor="black",
            ax=ax,
            legend=False,   # we'll add one combined legend later
        )
    
        # Label each point with last two chars of cyp
        for _, row in dsub.iterrows():
            ax.text(
                row[value],
                row["ligand"],
                str(row["cyp"])[-1:]+'\n',
                ha="center", va="bottom",
                fontsize=8,
                clip_on=True,
            )
    
        ax.set_title(title)
        ax.set_xlabel(value)
    
    # Shared y-label
    axes[0].set_ylabel("ligand")
    
    # === Manual legend ===
    legend_elements = [
        Line2D(
            [0], [0],
            marker=marker_map[c],
            color="w",
            label=c,
            markerfacecolor=palette[c],
            markeredgecolor="black",
            markersize=10,
            linewidth=0
        )
        for c in cyp_order
    ]
    
    fig.legend(
        handles=legend_elements,
        title="cyp",
        loc="upper center",
        ncol=3,
        bbox_to_anchor=(0.5, 1.12)
    )
    sns.despine()
    plt.show()

Plots¶

Black borders are charged, white uncharted.

In [9]:
plot_scatter(df_min)
No description has been provided for this image

These plots order ligands (y-axis) by various computational observables (x-axis).

In [10]:
orderplot(df,'frac6fe',True) # fraction of time distance to FE is less than 6
No description has been provided for this image
In [11]:
orderplot(df,'avefe',False) # average distance to FE
No description has been provided for this image
In [12]:
orderplot(df,'avermsf',False) # average RMSF - how stable is the ligand pose
No description has been provided for this image
In [13]:
orderplot(df,'ASP_min',False) # minimum average distance to an aspartic (either 311 or 304) from charged atom
No description has been provided for this image

Ignore poses that don't place a carbon closest to FE¶

In [14]:
orderplot(prefdf,'frac6fe',True)
No description has been provided for this image
In [15]:
orderplot(prefdf,'avefe',False)
No description has been provided for this image
In [16]:
orderplot(prefdf,'avermsf',False)
No description has been provided for this image
In [17]:
orderplot(prefdf,'ASP_min',False)
No description has been provided for this image

Structures¶

The main structure is the pose from the simulation that is closest to FE (distance shown). Three other representative structures from the simulation are shown to qualitatively illustrate the diversity of conformations sampled. The three most commonly interacting atoms with the charged atom are shown as grey distances.

In [18]:
charged_names = {
    'azelastine':'N52',
    'clemizole':'N44',
    'clomipramine':'N46',
    'clozapine_charged':'N43',
    'clozapine_uncharged':'N37',
    'eticlopride_charged':'N49',
    'eticlopride_uncharged':'N38',
    'fipexide_charged':'N49',
    'fipexide_uncharged':'N41',
    'prochlorperazine_charged':'N50',
    'prochlorperazine_uncharged':'N39',
    'sertraline_charged':'N38',
    'sertraline_uncharged':'N32',
    'terconazole_charged':'N68'
}
In [20]:
prefix='/net/galaxy/home/koes/spirhadi/cyp-project/worm/'
for label in df_min[df_min.charged].sort_values(by=['ligand','cyp']).label:
    vals = label.split('_')
    ligand = vals[1]
    if ligand in charged_names:
        analyze(prefix+label.replace('_','/'), charged_names[ligand],verbose=False)
    else:
        analyze(prefix+label.replace('_','/').replace('charged/1','charged_1').replace('charged/2','charged_2'), charged_names[f'{ligand}_charged'],verbose=False)

cyp35b1_azelastine_models_model3

Average ligand RMSD: 3.10
Average ligand RMSF: 1.843
19 ligand clusters with 2.0â„« radius (average linkage)
Top 3 clusters represent 47.10% of simulation
The ligand atom with the shortest average distance to the HEME FE is C33.
Average distance of 4.75±0.48Å and a minimum distance of 3.43Å
Fraction within 6â„«: 0.986
TYR104:OH ave dist 5.55±1.54Å to N52; min dist 3.14Å
ALA484:CB ave dist 6.23±1.50Å to N52; min dist 3.71Å
PHE213:CD1 ave dist 6.25±2.12Å to N52; min dist 3.30Å

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

cyp35b2_azelastine_models_model1

Average ligand RMSD: 2.16
Average ligand RMSF: 1.597
5 ligand clusters with 2.0â„« radius (average linkage)
Top 3 clusters represent 97.93% of simulation
The ligand atom with the shortest average distance to the HEME FE is C34.
Average distance of 4.45±0.44Å and a minimum distance of 3.22Å
Fraction within 6â„«: 1.000
ASP311:OD2 ave dist 3.43±0.86Å to N52; min dist 2.55Å
ASP311:OD1 ave dist 3.72±0.77Å to N52; min dist 2.57Å
ASP311:CG ave dist 3.75±0.64Å to N52; min dist 2.97Å

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

cyp35b3_azelastine_models_model2

Average ligand RMSD: 2.20
Average ligand RMSF: 1.217
7 ligand clusters with 2.0â„« radius (average linkage)
Top 3 clusters represent 99.73% of simulation
The ligand atom with the shortest average distance to the HEME FE is C34.
Average distance of 4.98±0.34Å and a minimum distance of 3.82Å
Fraction within 6â„«: 0.994
ASP311:OD1 ave dist 3.45±0.97Å to N52; min dist 2.57Å
ASP311:OD2 ave dist 3.57±0.92Å to N52; min dist 2.58Å
ASP311:CG ave dist 3.73±0.75Å to N52; min dist 3.05Å

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

cyp35b1_clemizole_models_model1

Average ligand RMSD: 3.42
Average ligand RMSF: 2.756
5 ligand clusters with 2.0â„« radius (average linkage)
Top 3 clusters represent 99.83% of simulation
The ligand atom with the shortest average distance to the HEME FE is C28.
Average distance of 7.00±2.06Å and a minimum distance of 3.30Å
Fraction within 6â„«: 0.333
ASP304:OD1 ave dist 2.75±0.11Å to N44; min dist 2.50Å
ASP304:CG ave dist 3.86±0.14Å to N44; min dist 3.31Å
ASP304:CA ave dist 4.25±0.23Å to N44; min dist 3.50Å

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

cyp35b2_clemizole_models_model4

Average ligand RMSD: 3.40
Average ligand RMSF: 1.951
10 ligand clusters with 2.0â„« radius (average linkage)
Top 3 clusters represent 75.43% of simulation
The ligand atom with the shortest average distance to the HEME FE is C28.
Average distance of 4.48±0.71Å and a minimum distance of 3.34Å
Fraction within 6â„«: 0.964
LEU307:O ave dist 5.37±0.89Å to N44; min dist 2.81Å
LEU307:C ave dist 5.71±0.61Å to N44; min dist 3.78Å
LEU307:CB ave dist 5.82±0.69Å to N44; min dist 3.54Å

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

cyp35b3_clemizole_models_model6

Average ligand RMSD: 4.69
Average ligand RMSF: 1.620
14 ligand clusters with 2.0â„« radius (average linkage)
Top 3 clusters represent 88.93% of simulation
The ligand atom with the shortest average distance to the HEME FE is C28.
Average distance of 4.73±0.31Å and a minimum distance of 3.62Å
Fraction within 6â„«: 1.000
LEU307:O ave dist 4.32±0.61Å to N44; min dist 2.61Å
ASP311:OD1 ave dist 4.65±2.31Å to N44; min dist 2.54Å
ASP311:CG ave dist 4.67±1.83Å to N44; min dist 3.05Å

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

cyp35b1_clomipramine_models_model2

Average ligand RMSD: 3.12
Average ligand RMSF: 1.476
19 ligand clusters with 2.0â„« radius (average linkage)
Top 3 clusters represent 95.03% of simulation
The ligand atom with the shortest average distance to the HEME FE is C28.
Average distance of 5.45±0.59Å and a minimum distance of 4.33Å
Fraction within 6â„«: 0.881
ASP311:OD1 ave dist 3.71±1.04Å to N46; min dist 2.55Å
ASP311:OD2 ave dist 3.77±1.03Å to N46; min dist 2.55Å
ASP311:CG ave dist 3.83±0.72Å to N46; min dist 2.97Å

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

cyp35b2_clomipramine_models_model6

Average ligand RMSD: 2.20
Average ligand RMSF: 1.406
7 ligand clusters with 2.0â„« radius (average linkage)
Top 3 clusters represent 97.50% of simulation
The ligand atom with the shortest average distance to the HEME FE is C27.
Average distance of 4.61±0.38Å and a minimum distance of 3.59Å
Fraction within 6â„«: 0.995
ASP311:OD1 ave dist 3.32±0.68Å to N46; min dist 2.55Å
ASP311:OD2 ave dist 3.37±0.72Å to N46; min dist 2.54Å
ASP311:CG ave dist 3.54±0.38Å to N46; min dist 2.95Å

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

cyp35b3_clomipramine_models_model6

Average ligand RMSD: 2.90
Average ligand RMSF: 1.446
8 ligand clusters with 2.0â„« radius (average linkage)
Top 3 clusters represent 99.00% of simulation
The ligand atom with the shortest average distance to the HEME FE is C27.
Average distance of 4.85±0.34Å and a minimum distance of 3.86Å
Fraction within 6â„«: 0.996
ASP311:OD1 ave dist 3.63±0.86Å to N46; min dist 2.57Å
ASP311:OD2 ave dist 3.63±0.97Å to N46; min dist 2.52Å
ASP311:CG ave dist 3.73±0.48Å to N46; min dist 2.98Å

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

cyp35b1_clozapine_charged_models_model3

Average ligand RMSD: 3.89
Average ligand RMSF: 2.125
11 ligand clusters with 2.0â„« radius (average linkage)
Top 3 clusters represent 88.37% of simulation
The ligand atom with the shortest average distance to the HEME FE is C26.
Average distance of 5.63±0.81Å and a minimum distance of 4.03Å
Fraction within 6â„«: 0.668
ALA210:CB ave dist 5.86±1.72Å to N43; min dist 3.51Å
ASP311:OD1 ave dist 5.88±1.41Å to N43; min dist 2.68Å
ASP311:OD2 ave dist 5.89±1.32Å to N43; min dist 2.59Å

3Dmol.js failed to load for some reason. Please check your browser console for error messages.