AI for Drug Discovery
Molecular Representation
SMILES and Molecular Graphs
from rdkit import Chem
def smiles_to_graph(smiles):
mol = Chem.MolFromSmiles(smiles)
atoms = [{'atomic_num': a.GetAtomicNum(), 'formal_charge': a.GetFormalCharge(),
'hybridization': str(a.GetHybridization())} for a in mol.GetAtoms()]
bonds = [{'begin': b.GetBeginAtomIdx(), 'end': b.GetEndAtomIdx(),
'type': str(b.GetBondType())} for b in mol.GetBonds()]
return {'atoms': atoms, 'bonds': bonds}
Molecular Fingerprints
Molecular Property Prediction
Graph Neural Networks
import torch
from torch_geometric.nn import GCNConv, global_mean_pool
class MolecularPropertyPredictor(torch.nn.Module):
def __init__(self, in_channels, hidden_channels, out_channels):
super().__init__()
self.conv1 = GCNConv(in_channels, hidden_channels)
self.conv2 = GCNConv(hidden_channels, hidden_channels)
self.conv3 = GCNConv(hidden_channels, hidden_channels)
self.fc = torch.nn.Linear(hidden_channels, out_channels)
def forward(self, x, edge_index, batch):
x = torch.relu(self.conv1(x, edge_index))
x = torch.relu(self.conv2(x, edge_index))
x = torch.relu(self.conv3(x, edge_index))
x = global_mean_pool(x, batch)
return self.fc(x)
Generative Models for Drug Design
Variational Autoencoders
Reinforcement Learning
class MolGenerator(nn.Module):
def __init__(self, vocab_size, embed_dim, hidden_dim):
super().__init__()
self.embedding = nn.Embedding(vocab_size, embed_dim)
self.lstm = nn.LSTM(embed_dim, hidden_dim, batch_first=True)
self.output = nn.Linear(hidden_dim, vocab_size)
def forward(self, x, hidden=None):
embedded = self.embedding(x)
output, hidden = self.lstm(embedded, hidden)
return self.output(output), hidden
Virtual Screening Pipelines
Pharmacokinetic Properties
- Lipinski Rule of Five: MW < 500, LogP < 5, HBD <= 5, HBA <= 10
- Half-life:
Docking Score