Files
macrolactone-toolkit/notebooks/README_analyze_ring16.md
lingyuzeng c0ead42384 feat(toolkit): add classification and migration
Implement the standard/non-standard/not-macrolactone classification layer
and integrate it into analyzer, fragmenter, and CLI outputs.

Port the remaining legacy package capabilities into new visualization and
workflow modules, restore batch/statistics/SDF scripts on top of the flat
CSV workflow, and update active docs to the new package API.
2026-03-18 23:56:41 +08:00

5.4 KiB
Raw Blame History

16元环大环内酯分子分析说明

文件说明

  • notebook文件: analyze_ring16_molecules.ipynb
  • 输入数据: ../output/ring16_match_smarts.csv (307个分子)
  • 输出目录: ../output/

使用方法

1. 激活环境

cd /home/zly/project/macro_split
pixi shell

2. 运行notebook

jupyter notebook notebooks/analyze_ring16_molecules.ipynb

或使用 JupyterLab

jupyter lab notebooks/analyze_ring16_molecules.ipynb

3. 按顺序运行所有单元格

notebook会自动

  1. 计算所有分子的药物性质分子量、LogP、QED、TPSA等
  2. 进行侧链断裂分析
  3. 统计每个位置3-16的碎片分布
  4. 生成分布图并保存到 output/ 目录

生成的输出文件

图片文件

  • ring16_molecular_properties_distribution.png - 分子性质分布图4个子图

    • 分子量分布
    • LogP分布
    • QED分布
    • TPSA分布
  • atom_count_distribution_ring16.png - 每个位置的原子数分布14个子图位置3-16

  • molecular_weight_distribution_ring16.png - 每个位置的分子量分布14个子图位置3-16

数据文件

  • ring16_fragments_analysis.csv - 所有碎片的详细信息

    • fragment_id, parent_id, parent_smiles, cleavage_position, fragment_smiles, atom_count, molecular_weight
  • ring16_molecular_properties.csv - 所有分子的性质数据

    • unique_id, mol_weight, logP, num_h_donors, num_h_acceptors, num_rotatable_bonds, tpsa, qed, num_atoms, num_heavy_atoms

分析内容

已完成

  1. 分子基本性质计算

    • 分子量、LogP、QED、TPSA
    • 氢键供受体数、可旋转键数
    • 原子数、重原子数
  2. 侧链断裂分析

    • 使用封装好的 MacrolactoneFragmenter
    • 批量处理所有307个分子
    • 统计每个位置的碎片类型和数量
  3. 分布图绘制

    • 参考 test_align_two_molecules.ipynb 的绘图逻辑
    • 4x4子图布局展示位置3-16的分布
    • 使用 seaborn 和 matplotlib 绘图

延伸分析建议

notebook的最后一个单元格Section 9提供了详细的延伸分析建议包括

优先级1强烈推荐

  • LogP分析:找出对亲脂性贡献最大的侧链位置
  • QED分析:比较高/低QED分子的侧链差异
  • TPSA分析:分析极性侧链的分布模式

优先级2重要

  • SAR分析如果有活性数据max_pChEMBL分析结构-活性关系
  • 特权侧链:找出高频出现在活性分子中的侧链

优先级3有价值

  • 碎片多样性分析:统计每个位置的独特碎片类型
  • 聚类分析:基于碎片指纹进行分子聚类
  • 极性/疏水性分析:分析侧链的极性特征

可选分析

  • 3D性质PMI、NPR等3D描述符
  • Lipinski规则:检查类药性规则
  • 立体化学:手性中心分析

代码示例

notebook中包含了完整的代码示例可以直接运行或修改。主要功能

from macro_lactone_toolkit import MacroLactoneAnalyzer
from macro_lactone_toolkit.workflows import fragment_csv, results_to_dataframe

analyzer = MacroLactoneAnalyzer()
classification = analyzer.classify_macrocycle(smiles, ring_size=16)

batch_results = fragment_csv(csv_file, ring_size=16)
df_fragments = results_to_dataframe(batch_results)
position_stats = df_fragments.groupby("cleavage_position").agg(...)

关键洞察

LogP的价值

  • 反映分子的亲脂性,对膜通透性和药物分布至关重要
  • 大环内酯通常LogP较高
  • 了解侧链对LogP的贡献有助于优化药物设计

QED的意义

  • QED综合评估"类药性"
  • 大环内酯往往违反Lipinski规则分子量>500但仍可能是好药
  • 比较高/低QED分子可以找出影响类药性的关键侧链

TPSA的重要性

  • TPSA与口服生物利用度密切相关一般<140Ų为佳
  • 极性侧链对TPSA贡献显著
  • 可以指导侧链修饰策略

注意事项

  1. 环境要求

    • 需要安装 seabornmatplotlib
    • 如果没有安装notebook会提示pixi add seaborn matplotlib
  2. 处理时间

    • 处理307个分子可能需要几分钟
    • 绘制分布图也需要一些时间
  3. 内存使用

    • 批量处理和绘图会占用一定内存
    • 如果遇到内存问题,可以减少 max_rows 参数
  4. 图片分辨率

    • 默认使用 300 DPI 保存图片
    • 可以根据需要调整 dpi 参数

后续工作

根据分析结果,建议进行:

  1. LogP与侧链的定量关系

    • 计算去除各个侧链后的LogP变化
    • 找出对LogP贡献最大的位置
  2. 活性数据关联(如果有)

    • 分析高活性分子的侧链特征
    • 找出"特权侧链"
  3. 碎片库构建

    • 整理每个位置的常见碎片
    • 用于指导新分子设计
  4. 机器学习预测

    • 使用碎片特征预测分子性质
    • 建立QSAR模型

参考

  • scripts/batch_process_ring16.py - 16 元环 flat workflow 入口
  • scripts/analyze_fragments.py - 位置统计和图表输出
  • src/macro_lactone_toolkit/fragmenter.py - 标准大环内酯裂解器
  • src/macro_lactone_toolkit/visualization.py - 编号和碎片可视化工具

问题反馈

如果遇到问题:

  1. 检查是否在 pixi shell 环境中
  2. 确认所有依赖包已安装
  3. 查看输出目录是否有写入权限
  4. 检查CSV文件路径是否正确