Files
vina_docking_batch/README.md
2025-08-15 18:14:30 +08:00

796 lines
28 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 目录结构
```shell
project_root/
├── input/
│ ├── receptors/
│ │ ├── TrpE_entry_1.pdb
│ │ └── TrpE_entry_1.pdbqt
│ ├── ligands/
│ │ ├── sdf/
│ │ │ ├── ligand_001.sdf
│ │ │ ├── ligand_002.sdf
│ │ │ └── ...
│ │ └── pdbqt/
│ │ ├── ligand_001.pdbqt
│ │ ├── ligand_002.pdbqt
│ │ └── ...
│ └── configs/
│ ├── TrpE_entry_1.box.txt
│ └── TrpE_entry_1.box.pdb
├── results/
│ ├── poses/
│ │ ├── ligand_001_out.pdbqt
│ │ ├── ligand_002_out.pdbqt
│ │ └── ...
│ └── scores/
│ ├── docking_scores.csv
│ └── summary_report.txt
└── scripts/
├── batch_prepare_ligands.sh
├── batch_docking.sh
└── analyze_results.py
```
## 受体准备 pdbqt 文件
使用 alphafold 预测 pdb 文件 cif 文件。
修复使用 moderller 同源建模,或者 pdbfixerMOEmaestro 等
这里使用 maestro 的 `Protein reparation Workflow` 模块
然后导出 pdb 文件
使用 meeko 准备受体文件 pdbqt 文件,详细可以[参考](https://meeko.readthedocs.io/en/release-doc/rec_overview.html)
```shell
micromamba run -n vina mk_prepare_receptor.py -i receptor/FgBar1_cut_proteinprep.pdb --write_pdbqt receptor/FgBar1_cut_proteinprep.pdbqt
```
选项组合用法
### 举例1用默认输出名生成 pdbqt 和 vina box 配置
mk_prepare_receptor.py -i 1abc.pdb -o 1abc_clean --write_pdbqt --write_vina_box
得到 1abc_clean_rigid.pdbqt, 1abc_clean.vina.txt
### 举例2为指定残基设置模板/柔性,并生成 box 配置
```shell
mk_prepare_receptor.py -i system.pdb \
--output_basename system_prep \
-f "A:42,B:23" \
-n "A:5,7=CYX,B:17=HID" \
--write_pdbqt --write_vina_box
```
### 举例3自动包络某配体生成 box 配置
```
mk_prepare_receptor.py -i prot.pdb \
--box_enveloping ligand.pdb \
--padding 3.0 \
--output_basename dock_ready \
--write_pdbqt --write_vina_box
```
### 受体准备介绍
```shell
mk_prepare_receptor.py -i xxx.pdb -o my_receptor -p -j -v
mk_prepare_receptor.py -i FgBar1_cut_proteinprep.pdb -o FgBar1_cut_proteinprep -p
```
这样会生成:
my_receptor.pdbqt对接用的受体文件
my_receptor.json结构元数据编程用得上
my_receptor.vina_box.txt对接区域参数给 vina 用)
| 选项 | 作用 | 输出文件例子 |
| ---- | -------------------- | ------------------ |
| `-p` | 输出PDBQT文件受体 | `xxx.pdbqt` |
| `-j` | 输出JSON文件元数据 | `xxx.json` |
| `-v` | 输出vina box参数 | `xxx.vina_box.txt` |
| `-g` | 输出GPF文件老版AutoDock用 | `xxx.gpf` |
## 小分子 3D 构象准备
需要给小分子一个初始化的 3d 构象存放到`ligand/sdf`
```shell
python sdf2to3d.py --src_dir ./2d_sdf_dir --out_dir ./3d_sdf_dir --n_jobs 8
```
## 小分子格式转化
使用 meeko 将 `ligand/sdf` 转为 `ligand/pdbqt`
```shell
micromamba run -n vina ./scripts/batch_prepare_ligands.sh ligands/sdf ligands/pdbqt/ batch_prepare_ligands.log 128
```
## 小分子批量提交对接
分割小分子文件将 ligand 目录里面的 pdbqt 文件夹拆分 n 个子文件夹(pdbqt1,pdbqt2,pdbqt3...pdbqtn)
```shell
micromamba run -n vina python vina_split_and_submit.py <split_number_n>
```
执行完成后会自动使用 dsub 命令将对接任务提交给华为多瑙调度系统
需要注意有时候提交执行速度过快可能有批次遗漏,可以在合并时候检查
## 对接结果合并
在对接完成之后会在 `result` 文件夹里面创建 n 个对接结果文件夹poses1poses2poses3...posesn
每个文件夹中都有对应的`*_out.pdbqt`文件与`*_converted.sdf`文件,调用
```shell
micromamba run -n vina python vina_merge_and_check.py --n_splits <split_number_n> --out_dir ./result --output_prefix poses --poses_dir ./result/poses_all
```
会将所有的n 个对接结果文件夹中`*_converted.sdf`文件存放到 `./result/poses_all` 目录,同时会检测是否有提交时候过快导致遗漏某个批次没有对接,需要注意查看。
## 分析对接结果
`*_converted.sdf`文件中存在`20`个对接构象,取决于`scripts/batch_docking.sh``NUM_MODES` 设置多少数目,默认设置为 20。
其中每个 sdf 构象存在下面的`<meeko>`字段 用于获取对接打分等属性用于后续筛选分子。
```
> <meeko> (20)
{"is_sidechain": [false], "free_energy": -6.38, "intermolecular_energy": -15.695, "internal_energy": -2.912}
```
## batch 模式对接
vina=1.2.7可以使用batch 模式进行批量对接。
```shell
mkdir -p results/poses
vina --receptor input/receptors/TrpE_entry_1.pdbqt \
--batch input/ligands/test \
--config ./configs/TrpE_entry_1.box.txt \
--dir results/poses \
--exhaustiveness=32
# 使用脚本对接
./scripts/batch_docking.sh ./receptors/TrpE_entry_1.pdbqt ./config/TrpE_entry_1.box.txt ligands/test output test.log /share/home/lyzeng24/rdkit_script/vina/vina
```
## 环境安装
```shell
conda install -c conda-forge vina meeko rdkit joblib rich ipython parallel openpyxl pandas mordred -y
```
## 准备小分子pdbqt
```shell
# 单个配体准备
mk_prepare_ligand.py -i molecule.sdf -o molecule.pdbqt
# 批量准备
micromamba run -n vina ./scripts/batch_prepare_ligands.sh ligands/sdf ligands/pdbqt/ batch_prepare_ligands.log 128
#监控文件
watch -n 1 "ls -l pdbqt/*.pdbqt 2>/dev/null | wc -l"
```
## 准备受体pdbqt
```shell
# 受体准备(带柔性侧链)
mk_prepare_receptor.py -i nucleic_acid.cif -o my_receptor -j -p -f A:42
```
## batch对接模式
```shell
./scripts/batch_docking.sh input/receptors/TrpE_entry_1.pdbqt \
input/configs/TrpE_entry_1.box.txt \
input/ligands/pdbqt \
results/poses \
results/batch_docking.log
```
## 监控对接结果
```shell
watch -n 1 'for i in {1..12}; do printf "poses$i: "; ls results/poses$i/*.pdbqt 2>/dev/null | wc -l; done'
```
## 将对接结果还原为sdf文件
mk_export.py 命令行工具的各个参数选项。
```shell
cd output
mk_export.py ./*_out.pdbqt --suffix _converted
```
## 分析vina对接结果
```shell
# 结果导出
mk_export.py vina_results.pdbqt -j my_receptor.json -s lig_docked.sdf -p rec_docked.pdb
```
## djob 运行时间耗时长的批次任务
```shell
24562323 vina_job15 RUNNING lyzeng24 default default 2025/07/31 23:16:30 - agent-ARM-17
24562322 vina_job14 RUNNING lyzeng24 default default 2025/07/31 23:16:30 - agent-ARM-17
24562321 vina_job13 RUNNING lyzeng24 default default 2025/07/31 23:16:30 - agent-ARM-17
24562320 vina_job12 RUNNING lyzeng24 default default 2025/07/31 23:16:29 - agent-ARM-21
24562319 vina_job11 RUNNING lyzeng24 default default 2025/07/31 23:16:29 - agent-ARM-21
24562318 vina_job10 RUNNING lyzeng24 default default 2025/07/31 23:16:29 - agent-ARM-21
24562317 vina_job9 RUNNING lyzeng24 default default 2025/07/31 23:16:28 - agent-ARM-21
24562316 vina_job8 RUNNING lyzeng24 default default 2025/07/31 23:16:28 - agent-ARM-16
24562315 vina_job7 RUNNING lyzeng24 default default 2025/07/31 23:16:28 - agent-ARM-16
24562314 vina_job6 RUNNING lyzeng24 default default 2025/07/31 23:16:27 - agent-ARM-16
24562313 vina_job5 RUNNING lyzeng24 default default 2025/07/31 23:16:27 - agent-ARM-19
24562312 vina_job4 RUNNING lyzeng24 default default 2025/07/31 23:16:27 - agent-ARM-19
24562311 vina_job3 RUNNING lyzeng24 default default 2025/07/31 23:16:27 - agent-ARM-19
```
## plant_metabolit 数据集 准备
阮耀师兄之前用构建的植物代谢网络,里面包含的代谢物
执行命令:
```shell
cd /Users/lingyuzeng/Downloads/211.69.141.180/202508021824/vina/ligand/plant_meta
chmod +x run_convert_smiles.sh
./run_convert_smiles.sh
```
执行结果:
```shell
Conversion Summary:
Total SMILES processed: 8086
Successfully converted: 6238
Failed conversions: 1848
Skipped molecules (empty abbreviation): 0
Output directory: sdf
Success rate: 77.1%
Script execution completed.
```
## autodock vina 参考分子对接
trpe:(PDB ID: 5cwa)
```shell
./vina --receptor ./refence/trpe/TrpE_entry_1.pdbqt --ligand ./refence/trpe/align_5cwa_0GA_addH.pdbqt --config ./refence/trpe/TrpE_entry_1.box.txt --out ./refence/trpe/align_5cwa_0GA_addH_out.pdbqt --exhaustiveness="32" --num_modes="20" --energy_range="5.0"
```
result:
```shell
AutoDock Vina v1.2.7
#################################################################
# If you used AutoDock Vina in your work, please cite: #
# #
# J. Eberhardt, D. Santos-Martins, A. F. Tillack, and S. Forli #
# AutoDock Vina 1.2.0: New Docking Methods, Expanded Force #
# Field, and Python Bindings, J. Chem. Inf. Model. (2021) #
# DOI 10.1021/acs.jcim.1c00203 #
# #
# O. Trott, A. J. Olson, #
# AutoDock Vina: improving the speed and accuracy of docking #
# with a new scoring function, efficient optimization and #
# multithreading, J. Comp. Chem. (2010) #
# DOI 10.1002/jcc.21334 #
# #
# Please see https://github.com/ccsb-scripps/AutoDock-Vina for #
# more information. #
#################################################################
Scoring function : vina
Rigid receptor: ./refence/trpe/TrpE_entry_1.pdbqt
Ligand: ./refence/trpe/align_5cwa_0GA_addH.pdbqt
Grid center: X 7.402 Y -4.783 Z -11.818
Grid size : X 30 Y 30 Z 30
Grid space : 0.375
Exhaustiveness: 32
CPU: 0
Verbosity: 1
Computing Vina grid ... done.
WARNING: At low exhaustiveness, it may be impossible to utilize all CPUs.
Performing docking (random seed: 650309048) ...
0% 10 20 30 40 50 60 70 80 90 100%
|----|----|----|----|----|----|----|----|----|----|
***************************************************
mode | affinity | dist from best mode
| (kcal/mol) | rmsd l.b.| rmsd u.b.
-----+------------+----------+----------
1 -6.531 0 0
2 -6.352 3.988 6.453
3 -6.3 1.447 5.602
4 -6.291 1.94 5.284
5 -6.283 1.044 2.037
6 -6.159 3.798 5.275
7 -6.124 1.43 5.553
8 -5.988 3.499 5.489
9 -5.925 3.311 4.252
10 -5.912 3.647 4.894
11 -5.889 7.256 10.49
12 -5.821 2.351 5.29
13 -5.763 3.731 6.18
14 -5.732 3.557 6.002
15 -5.729 7.213 9.251
16 -5.693 4.179 5.642
17 -5.684 3.058 4.111
18 -5.679 4.117 5.518
19 -5.671 4.656 6.098
20 -5.663 4.112 5.705
```
fgbar:PDB ID 8izd
```shell
./vina --receptor ./refence/fgbar/FgBar1_cut_proteinprep.pdbqt --ligand ./refence/fgbar/align_8izd_F_9NY_addH.pdbqt --config ./refence/fgbar/FgBar1_entry_1.box.txt --out ./refence/fgbar/align_8izd_F_9NY_addH_out.pdbqt --exhaustiveness="32" --num_modes="20" --energy_range="5.0"
```
reusult:
```shell
AutoDock Vina v1.2.7
#################################################################
# If you used AutoDock Vina in your work, please cite: #
# #
# J. Eberhardt, D. Santos-Martins, A. F. Tillack, and S. Forli #
# AutoDock Vina 1.2.0: New Docking Methods, Expanded Force #
# Field, and Python Bindings, J. Chem. Inf. Model. (2021) #
# DOI 10.1021/acs.jcim.1c00203 #
# #
# O. Trott, A. J. Olson, #
# AutoDock Vina: improving the speed and accuracy of docking #
# with a new scoring function, efficient optimization and #
# multithreading, J. Comp. Chem. (2010) #
# DOI 10.1002/jcc.21334 #
# #
# Please see https://github.com/ccsb-scripps/AutoDock-Vina for #
# more information. #
#################################################################
Scoring function : vina
Rigid receptor: ./refence/fgbar/FgBar1_cut_proteinprep.pdbqt
Ligand: ./refence/fgbar/align_8izd_F_9NY_addH.pdbqt
Grid center: X -12.7 Y -9.1 Z -0.3
Grid size : X 49.1 Y 37.6 Z 35.2
Grid space : 0.375
Exhaustiveness: 32
CPU: 0
Verbosity: 1
WARNING: Search space volume is greater than 27000 Angstrom^3 (See FAQ)
Computing Vina grid ... done.
WARNING: At low exhaustiveness, it may be impossible to utilize all CPUs.
Performing docking (random seed: -399012800) ...
0% 10 20 30 40 50 60 70 80 90 100%
|----|----|----|----|----|----|----|----|----|----|
***************************************************
mode | affinity | dist from best mode
| (kcal/mol) | rmsd l.b.| rmsd u.b.
-----+------------+----------+----------
1 -5.268 0 0
2 -5.106 3.453 7.96
3 -5.003 3.114 6.709
4 -4.986 6.86 13.92
5 -4.947 5.434 13
6 -4.875 4.933 10.47
7 -4.867 6.888 13.75
8 -4.862 4.244 9.114
9 -4.835 3.776 6.806
10 -4.826 3.682 7.143
11 -4.824 5.4 10.17
12 -4.81 5.364 7.809
13 -4.808 4.364 11.15
14 -4.805 3.211 5.684
15 -4.783 3.585 8.995
16 -4.773 6.47 13.64
17 -4.773 3.465 6.652
18 -4.731 4.73 9.619
19 -4.726 4.867 10.88
20 -4.716 4.834 8.903
```
对接结果并不理想可能是分子中灵活的扭转角多柔性较大。AutoDock Vina 更偏向刚性对接。
## 分析策略
### trpeCOCUNT
#### AutoDock Vina 筛选
过滤结果:
1. 针对 trpe 口袋
因为 trpe 口袋和参考分子较小,考虑使用小分子先过滤(MW < 800)。
针对 AutoDock Vina 的 score score 参考 align_5cwa_0GA_addH 结果 < -6.5 分子保留。
剩下根据 QED 排名选择前 100 个分子作为最后实验分子。
2. 针对 fgbar 口袋筛选
fgbar 口袋的参考分子较大MW 不进行筛选。 针对 QED 进行过滤QED > 0.5 , 参考分子align_8izd_F_9NY_addH rank1 的Vina 分数 < -5.2过滤,之后选择 rank 前 100 的分子。
AutoDock vinaQED 针对小空间分子量小的trpeQED 过滤。
过滤结果
```shell
使用 head 命令查看了两个 CSV 文件的数据结构
验证了 vina_scores 列的数据完整性
trpe 数据集发现 1919 个文件的构象数少于 20
fgbar 数据集发现 404 个文件的构象数少于 20
所有分子的最小构象数为 1
按照 README.md 的要求实现了数据过滤:
TRPE 过滤条件MW < 800 且 Vina < -6.5
FGBAR 过滤条件QED > 0.5 且 Vina < -5.2
生成了过滤结果文件:
/result/filtered_results/qed_values_fgbar_combined_filtered.csv (1878.1KB)
/result/filtered_results/qed_values_fgbar_top100.csv (27.6KB)
/result/filtered_results/qed_values_trpe_combined_filtered.csv (6090.1KB)
/result/filtered_results/qed_values_trpe_top100.csv (27.5KB)
输出了统计信息:
TRPE 数据统计:
原始数据总数: 41166
仅QED过滤后数据总数: 7229
仅Vina得分过滤后数据总数: 29728
同时满足QED和Vina得分条件的数据总数: 18787
FGBAR 数据统计:
原始数据总数: 41166
仅QED过滤后数据总数: 7228
仅Vina得分过滤后数据总数: 36111
同时满足QED和Vina得分条件的数据总数: 6568
## 聚类探索分析
### trpe 聚类探索分析
radius=3 是为了让聚类更敏感于分子结构差异,尤其是在功能团位置上的差异。
n-bits=1024 是因为这个值足够区分几万甚至几十万分子,同时计算代价可接受。
```shell
(vina) lingyuzeng@Mac-mini vina % python scripts/cluster_granularity_scan.py \
--csv result/filtered_results/qed_values_trpe_combined_filtered.csv \
--smiles-col smiles \
--radius 3 \
--n-bits 1024
计算 Tanimoto 相似度矩阵...
Method Params #Clusters AvgSize AvgIntraSim
Butina {'cutoff': 0.4} 8960 2.10 0.706
Butina {'cutoff': 0.5} 6720 2.80 0.625
Butina {'cutoff': 0.6} 4648 4.04 0.548
Butina {'cutoff': 0.7} 2783 6.75 0.463
Butina {'cutoff': 0.8} 958 19.61 0.333
Hierarchical {'threshold': 0.3} 12235 1.54 0.814
Hierarchical {'threshold': 0.4} 9603 1.96 0.739
Hierarchical {'threshold': 0.5} 7300 2.57 0.664
DBSCAN {'eps': 0.2} 2050 3.18 0.106
DBSCAN {'eps': 0.3} 2275 4.61 0.113
DBSCAN {'eps': 0.4} 2014 6.65 0.113
KMeans {'k': 10} 10 1878.70 0.204
KMeans {'k': 20} 20 939.35 0.200
KMeans {'k': 50} 50 375.74 0.233
```
| 方法 | 参数候选 | 簇数 | AvgSize | AvgIntraSim | 解释 |
| ------------ | ----------------- | ---------- | ------- | ----------- | ------------------------------------ |
| Butina | **cutoff=0.6** | 4648 | 4.04 | 0.548 | 簇数适中簇内平均相似度≈0.55,代表簇内有一定结构多样性但不是太松散 |
| Butina | cutoff=0.7 | 2783 | 6.75 | 0.463 | 簇更少,但簇内相似度低,可能太松散 |
| Hierarchical | **threshold=0.5** | 7300 | 2.57 | 0.664 | 簇更细每簇23个分子相似度高代表性好 |
| Hierarchical | threshold=0.6 | (没测,但会更松散) | - | - | 不推荐,可能太松散 |
推荐参数:
Butina → --cutoff 0.6
Hierarchical → --cutoff 0.5(脚本里 Hierarchical cutoff 是距离阈值 t这里 threshold=0.5 就直接传 0.5
### fgbar 聚类探索分析
```shell
(vina) [lyzeng24@cli-ARM-01 vina]$ python scripts/cluster_granularity_scan.py --csv result/filtered_results/qed_values_fgbar_combined_filtered.csv \
> --smiles-col smiles \
> --radius 3 \
> --n-bits 1024
计算 Tanimoto 相似度矩阵...
Method Params #Clusters AvgSize AvgIntraSim
Butina {'cutoff': 0.4} 4810 1.37 0.727
Butina {'cutoff': 0.5} 3915 1.68 0.628
Butina {'cutoff': 0.6} 3027 2.17 0.544
Butina {'cutoff': 0.7} 1943 3.38 0.441
Butina {'cutoff': 0.8} 690 9.52 0.302
Hierarchical {'threshold': 0.3} 5661 1.16 0.849
Hierarchical {'threshold': 0.4} 4993 1.32 0.750
Hierarchical {'threshold': 0.5} 4210 1.56 0.664
DBSCAN {'eps': 0.2} 393 2.24 0.091
DBSCAN {'eps': 0.3} 648 2.54 0.092
DBSCAN {'eps': 0.4} 862 3.25 0.096
KMeans {'k': 10} 10 656.80 0.144
KMeans {'k': 20} 20 328.40 0.159
KMeans {'k': 50} 50 131.36 0.180
```
| 方法 | 参数候选 | 簇数 | AvgSize | AvgIntraSim | 解释 |
| ------------ | ----------------- | ---- | ------- | ----------- | ------------- |
| Butina | **cutoff=0.6** | 3027 | 2.17 | 0.544 | 簇数适中,簇内多样性不错 |
| Butina | cutoff=0.7 | 1943 | 3.38 | 0.441 | 簇更少,簇内相似度低,松散 |
| Hierarchical | **threshold=0.5** | 4210 | 1.56 | 0.664 | 簇小且相似度高,代表性好 |
推荐参数:
Butina → --cutoff 0.6
Hierarchical → --cutoff 0.5
### 选择Butina
分子相似性聚类的老牌方法
Butina 是专门针对分子指纹 + Tanimoto 相似度设计的,化学信息学里用得很广,聚类结果可解释性强。
速度更快
在几万分子的规模上Butina 算法一般比层次聚类Hierarchical快很多也更省内存。
参数直观
cutoff 就是“簇内相似度下限”,调节起来很直观(比如 0.6~0.7 控制簇大小和多样性)。
Hierarchical 的优点是可以得到聚类树(树状图可以动态选择阈值),但缺点是:
大数据量时计算慢,占内存多(需要完整的相似度矩阵)
阈值不如 Butina 的 cutoff 直观,分子数多的时候聚类树的可视化会很复杂
所以我建议:
日常自动化批量筛选 → Butina
需要深入探索簇之间的关系 → Hierarchical
然后根据聚类结果:
聚类:用 Butina cutoff ≈ 0.60.7 或 Hierarchical 阈值 ≈ 0.50.6(保持簇内差异可控,簇数不要太多)。
选代表:每个簇取 1 个中心分子(簇内与其他成员平均相似度最高的那个)。
如果仍想增强多样性,可以在代表集中再跑一次 MaxMin picking。
设计思想:
1. 聚类(控制簇内差异)
目标:把相似的分子放到同一簇,不同簇差异尽量大。
选择 Butina cutoff ≈ 0.60.7 或 层次聚类阈值 ≈ 0.50.6 是为了既保留结构差异,又不让簇数太多。
阈值越低 → 簇数多、粒度细(多样性高但不聚拢),阈值越高 → 簇数少、粒度粗(代表性强但多样性低)。
你这里是在中间值取平衡,保证每个簇内的分子还是相似的,但簇的总数也不会大到难以处理。
2. 簇内代表分子选择
在每个簇里,找出与簇内所有成员平均相似度最高的分子作为“簇中心”。
这样可以确保这个分子最能代表整个簇的化学特征。
这种方法类似medoid picking比随便选一个分子更稳。
3. 再次提升多样性MaxMin picking
如果代表集依然太集中可以再用一次MaxMin picking
第一步选一个分子(比如最活跃的、或者随机一个)
每次选下一个时,都选当前与已选分子集合中最不相似的那个
这样会最大化代表集之间的结构差异,让你挑到的分子更加分散、多样。
每个簇选一个分子后,对每个分子进行对于打分进行 ranking 排序,选择前 100 个分子用于后续实验。
## 聚类结果
### trpe 聚类结果
Butina 聚类0.6
```shell
python scripts/cluster_best_vina.py \
--csv result/filtered_results/qed_values_trpe_combined_filtered.csv \
--smiles-col smiles \
--radius 3 \
--n-bits 1024 \
--cutoff 0.6 \
--out result/trpe_cluster_best_vina_butina.csv
[i] butina 聚类完成8960 个簇,有效分子数 18787
[+] 已保存result/trpe_cluster_best_vina_butina_butina.csv8960 条,每簇 1 条)
```
Hierarchical 聚类0.5
```shell
python scripts/cluster_best_vina.py \
--csv result/filtered_results/qed_values_trpe_combined_filtered.csv \
--smiles-col smiles \
--radius 3 \
--n-bits 1024 \
--method hierarchical \
--cutoff 0.5 \
--out result/trpe_cluster_best_vina_hier.csv
[i] hierarchical 聚类完成7267 个簇,有效分子数 18787
[+] 已保存result/trpe_cluster_best_vina_hier_hierarchical.csv7267 条,每簇 1 条)
```
### fgbar 聚类结果
Butina 聚类0.6
```shell
python scripts/cluster_best_vina.py \
--csv result/filtered_results/qed_values_fgbar_combined_filtered.csv \
--smiles-col smiles \
--radius 3 \
--n-bits 1024 \
--cutoff 0.6 \
--out result/fgbar_cluster_best_vina_butina.csv
[i] butina 聚类完成4810 个簇,有效分子数 6568
[+] 已保存result/fgbar_cluster_best_vina_butina_butina.csv4810 条,每簇 1 条)
```
Hierarchical 聚类0.5
```shell
python scripts/cluster_best_vina.py \
--csv result/filtered_results/qed_values_fgbar_combined_filtered.csv \
--smiles-col smiles \
--radius 3 \
--n-bits 1024 \
--method hierarchical \
--cutoff 0.5 \
--out result/fgbar_cluster_best_vina_hier.csv
[i] hierarchical 聚类完成4176 个簇,有效分子数 6568
[+] 已保存result/fgbar_cluster_best_vina_hier_hierarchical.csv4176 条,每簇 1 条)
```
#### karamadock 筛选
待反馈结构结果
karamadock只看 qed 过滤后的小分子对接情况(过滤标准:**小分子**QED
glide: 小分子QED。vina 打分好的 1w 个 按照底物标准)
#### glide 筛选
之前是考虑底物标准的交集这里使用底物标准剩余的分子全部使用glide 进行分子对接。
`qed_values_fgbar_filtered.csv`
`qed_values_fgbar_filtered.csv`
---
### fgbar
vinakaramadock底物标准选择 交集做 glide。
## tanimoto_clustering.py 用法
环境依赖
```shell
micromamba create -n chem_cluster python=3.11 mordred chemplot pandas rdkit scikit-learn
```
```python
from utils.chem_cluster import TanimotoClusterer, search_best_config, SearchConfig
```
几个核心类和函数:
TanimotoClusterer主聚类类可配置方法、参数fit() / stats() / representatives() / chemplot_scatter()。
SearchConfig自动搜索的参数集合半径、nBits、聚类器等的网格
search_best_config自动搜索“分得比较开”的聚类配置并返回最佳聚类器、统计和历史对比表。
ClusterStats聚类统计结构体样本数、簇数、最大簇比例、轮廓系数等
# 分子对接分析流程
## 目录
[TOC]
## 1. 项目概述
...
## 2. 系统功能
...
## 3. 技术架构
...
## 4. 技术选型
...
## 5. 开发环境
...
## 6. 技术约束
...
## 使用说明
### 数据准备
...
### 分子对接
...
### 结果分析
...
### 聚类分析
...
### 新增:代表分子选择
#### 选择簇内最高Vina得分分子
```bash
# 示例命令
python scripts/select_representatives.py \
--csv result/filtered_results/qed_values_fgbar_top100.csv \
--smiles-col smiles \
--vina-col vina_scores \
--radius 3 \
--n-bits 1024 \
--sim-cutoff 0.6 \
--output result/clustered_representatives.csv
```
- `--csv`: 输入CSV文件路径
- `--smiles-col`: SMILES列名
- `--vina-col`: Vina得分列名
- `--radius`: Morgan指纹半径默认3
- `--n-bits`: 指纹位数默认1024
- `--sim-cutoff`: Butina相似度阈值默认0.6
- `--output`: 输出文件路径
该脚本会:
1. 使用Butina算法对分子进行聚类
2. 在每个簇中选择Vina得分最高的分子
3. 将结果保存到新的CSV文件
输出文件包含每个簇的代表性分子,共保留与簇数量相同的分子。