Created
November 14, 2025 03:16
-
-
Save PatWalters/019ad6ddf85804293d53feff41da60fd to your computer and use it in GitHub Desktop.
Code generated by LLMs to depict proton pump inhibitors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Code from GPT-5 | |
| from rdkit import Chem | |
| from rdkit.Chem import Draw | |
| # 1. Names (for legends) | |
| names = [ | |
| "Omeprazole", | |
| "Esomeprazole", | |
| "Lansoprazole", | |
| "Dexlansoprazole", | |
| "Pantoprazole", | |
| "Rabeprazole", | |
| ] | |
| # 2. SMILES | |
| smiles_list = [ | |
| # Omeprazole (canonical SMILES) | |
| "CC1=CN=C(C(=C1OC)C)CS(=O)C2=NC3=C(N2)C=C(C=C3)OC", | |
| # Esomeprazole (S-enantiomer; isomeric SMILES with S@ on sulfur) | |
| "COc1ccc2nc([nH]c2c1)[S@](=O)Cc1ncc(C)c(OC)c1C", | |
| # Lansoprazole | |
| "Cc1c(CS(=O)c2nc3ccccc3[nH]2)nccc1OCC(F)(F)F", | |
| # Dexlansoprazole (R-enantiomer; S@ on sulfur in alternative orientation) | |
| "n1c2ccccc2[nH]c1[S@](=O)Cc3nccc(c3C)OCC(F)(F)F", | |
| # Pantoprazole | |
| "FC(F)Oc1ccc2[nH]c(nc2c1)S(=O)Cc3nccc(OC)c3OC", | |
| # Rabeprazole | |
| "CC1=C(C=CN=C1CS(=O)C2=NC3=CC=CC=C3N2)OCCCOC", | |
| ] | |
| # 3. Convert SMILES to RDKit Mol objects | |
| mols = [Chem.MolFromSmiles(s) for s in smiles_list] | |
| # Optional: quick sanity check | |
| for n, m in zip(names, mols): | |
| if m is None: | |
| raise ValueError(f"SMILES failed to parse for: {n}") | |
| # 4. Draw molecules: 3 per row with names under each structure | |
| img = Draw.MolsToImage( | |
| mols, | |
| molsPerRow=3, | |
| subImgSize=(300, 300), | |
| legends=names | |
| ) | |
| # 5. Save (and/or show) the image | |
| img.save("ppis_omep_eso_lanso_dexlanso_panto_rabe.png") | |
| # img.show() # uncomment to open in a window if your environment supports it | |
| ### Code from Claude 4.5 Sonnet | |
| from rdkit import Chem | |
| from rdkit.Chem import Draw | |
| # SMILES dictionary | |
| smiles_dict = { | |
| 'Omeprazole': 'CC1=CN=C(C(=C1OC)C)CS(=O)C2=NC3=C(N2)C=CC(=C3)OC', | |
| 'Esomeprazole': 'CC1=CN=C(C(=C1OC)C)C[S@](=O)C2=NC3=C(N2)C=CC(=C3)OC', | |
| 'Lansoprazole': 'CC1=C(C=CN=C1CS(=O)C2=NC3=CC=CC=C3N2)OCC(F)(F)F', | |
| 'Dexlansoprazole': 'CC1=C(C=CN=C1C[S@](=O)C2=NC3=CC=CC=C3N2)OCC(F)(F)F', | |
| 'Pantoprazole': 'COC1=C(C=C(C=C1)OC)CS(=O)C2=NC3=C(N2)C=C(C=C3)OCC(F)F', | |
| 'Rabeprazole': 'CCOC(=O)C1=C(C=CN=C1)CS(=O)C2=NC3=C(N2)C=CC(=C3)OC' | |
| } | |
| # Convert SMILES to molecules | |
| mols = [] | |
| names = [] | |
| for name, smiles in smiles_dict.items(): | |
| mol = Chem.MolFromSmiles(smiles) | |
| mols.append(mol) | |
| names.append(name) | |
| # Draw molecules with 3 per row | |
| img = Draw.MolsToGridImage(mols, molsPerRow=3, subImgSize=(400, 400), | |
| legends=names) | |
| img.save('ppi_structures.png') | |
| img.show() | |
| ### Code from Perplexity | |
| from rdkit import Chem | |
| from rdkit.Chem import Draw | |
| smiles_dict = { | |
| 'Omeprazole': 'CC1=CN=C(C(=C1OC)C)CS(=O)C2=NC3=C(N2)C=C(C=C3)OC', | |
| 'Esomeprazole': 'COc1ccc2nc([nH]c2c1)[S@](=O)Cc1ncc(C)c(OC)c1C', | |
| 'Lansoprazole': 'CC1=C(OCC(F)(F)F)C=CN=C1CS(=O)C1=NC2=CC=CC=C2N1', | |
| 'Dexlansoprazole': 'CC1=C(OCC(F)(F)F)C=CN=C1C[S@@](=O)C1=NC2=CC=CC=C2N1', | |
| 'Pantoprazole': 'FC(F)Oc1ccc2[nH]c(nc2c1)S(=O)Cc3nccc(OC)c3OC', | |
| 'Rabeprazole': 'CC1=C(C=CN=C1CS(=O)C2=NC3=CC=CC=C3N2)OCCCOC', | |
| } | |
| names = list(smiles_dict.keys()) | |
| mols = [Chem.MolFromSmiles(smiles_dict[name]) for name in names] | |
| img = Draw.MolsToGridImage(mols, molsPerRow=3, subImgSize=(350,350), legends=names) | |
| img.save("ppi_grid.png") | |
| ### Code from Gemini | |
| import matplotlib.pyplot as plt | |
| from rdkit import Chem | |
| from rdkit.Chem import Draw | |
| def draw_ppi_molecules(): | |
| """ | |
| Generates an image of the six requested PPI molecules arranged in a 2x3 grid. | |
| """ | |
| # 1. Define Drug Names and Stereospecific SMILES | |
| # Note: Stereochemistry is explicitly defined for Esomeprazole ([S@]) and Dexlansoprazole ([S@@]) | |
| ppi_data = { | |
| 'Omeprazole': 'CC1=C(C=C(N=C1)CS(=O)C2=NC3=CC=C(C)C=C3N2)OC', # Racemate (non-stereospecific SMILES) | |
| 'Esomeprazole': 'CC1=C(C=C(N1)C[S@](=O)C2=NC3=CC=C(C)C=C3N2)OC', # S-enantiomer | |
| 'Lansoprazole': 'Cc1nc(CS(=O)c2nc3ccc(F)c-3n2)c(C)n1C', # Racemate (non-stereospecific SMILES) | |
| 'Dexlansoprazole': 'Cc1nc(C[S@@](=O)c2nc3ccc(F)c-3n2)c(C)n1C', # R-enantiomer | |
| 'Pantoprazole': 'COC1=C(C)N(C)C=C1CS(=O)C2=NC3=CC=C(OCF2)C=C3N2', | |
| 'Rabeprazole': 'CC1=C(C=CN=C1CS(=O)C2=NC3=CC=CC=C3N2)OCCCOC' | |
| } | |
| # 2. Convert SMILES to RDKit molecules and get names | |
| mol_list = [Chem.MolFromSmiles(smiles) for smiles in ppi_data.values()] | |
| name_list = list(ppi_data.keys()) | |
| # 3. Define drawing parameters | |
| mols_per_row = 3 | |
| num_mols = len(mol_list) | |
| num_rows = (num_mols + mols_per_row - 1) // mols_per_row | |
| # 4. Set up the figure and axes using matplotlib | |
| fig, axes = plt.subplots(num_rows, mols_per_row, figsize=(15, 10)) | |
| axes = axes.flatten() # Flatten the array of axes for easy indexing | |
| # 5. Draw each molecule | |
| for i in range(num_mols): | |
| ax = axes[i] | |
| mol = mol_list[i] | |
| name = name_list[i] | |
| # Use RDKit's MolToImage to draw the molecule onto the Matplotlib axis | |
| # Note: MolToImage requires a temporary PIL image conversion, | |
| # but Draw.MolToMPL is often cleaner if available and configured. | |
| # We'll use the standard Draw.MolToImage, which Matplotlib can display. | |
| img = Draw.MolToImage( | |
| mol, | |
| size=(300, 300), | |
| legend=name, # RDKit can add the name directly to the image | |
| wedgeBonds=True, # Ensure stereochemistry is visible | |
| fitImage=True | |
| ) | |
| ax.imshow(img) | |
| ax.axis('off') # Hide the axes lines and ticks | |
| # Manually add the name below the structure if RDKit's legend is not prominent enough | |
| ax.set_title(name, y=-0.15, fontsize=12) | |
| # 6. Hide any unused axes (if fewer than 6 molecules) | |
| for i in range(num_mols, len(axes)): | |
| fig.delaxes(axes[i]) | |
| # 7. Adjust layout and display/save | |
| plt.tight_layout() | |
| # Save the figure to a file | |
| file_name = 'ppi_structures.png' | |
| plt.savefig(file_name, dpi=300) | |
| print(f"Image successfully saved as: {file_name}") | |
| # plt.show() # Uncomment this line to display the image immediately in a notebook or script | |
| if __name__ == '__main__': | |
| draw_ppi_molecules() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment