看到这篇论文:通过深度学习设计的抗痤疮丙酸杆菌新型抗菌肽 。这篇论文只讲了方法,没有给出开源工程代码。于是借助AI通过读取论文,写了一个实现项目。
论文信息
痤疮丙酸杆菌(C. acnes)中日益增长的抗生素耐药性要求我们寻找替代治疗策略。抗菌肽(AMPs)为开发针对痤疮丙酸杆菌的新疗法提供了一个有前景的途径。在本研究中,为了设计具有特异性抑制痤疮丙酸杆菌活性的肽,我们采用了一个包含生成器和分类器的深度学习流程,使用了迁移学习和预训练的蛋白质嵌入,并在公开可用的数据上进行训练。为了增强针对痤疮丙酸杆菌抑制的特异性训练数据,我们构建了一个系统发育树。随后,我们合成了42种新生成的线性肽,并通过实验评估了它们的抗菌选择性和活性。其中五种肽显示出对痤疮丙酸杆菌的高效力和高选择性,最小抑菌浓度(MIC)为2–4 µg/mL。我们的研究结果突出了这些设计肽作为有前景的抗痤疮治疗候选物的潜力,并展示了计算方法在靶向抗菌肽理性设计中的强大能力。
深度学习模型从一个在所有活性抗菌肽序列上训练的基本生成模型开始。随后,使用增强的痤疮丙酸杆菌特异性数据对该基本生成模型进行微调。此外,我们训练了两个分类器,一个用于预测抗菌活性,另一个用于预测溶血性。然后,我们应用长度过滤和聚类来优先选择用于体外实验的肽。最后,我们合成了42种肽进行体外测试,并验证了它们的抗菌效力,以及无溶血性和细胞毒性。
简而言之,我们的贡献如下三个方面:
• 我们提出了一个数据整理流程,特别是通过系统发育分析构建了一个与痤疮丙酸杆菌相关的抗菌肽数据集。
• 我们设计了一系列人工智能模型,包括两个生成模型和两个分类模型,以高效地生成和分类独特且强效的肽。
• 我们选择了42种设计的肽进行合成,并进行了体外测试以验证它们的抗菌效力、溶血性和细胞毒性。
开源项目
项目地址:medai:通过深度学习设计的抗痤疮丙酸杆菌新型抗菌肽 – AtomGit | GitCode
建议先创建python虚拟环境
python -m venv venv
# Windows: venv\\Scripts\\activate
# Linux/Mac:
source venv/bin/activate
下载项目代码:
git clone https://gitcode.com/skywalk163/medai
cd acnes_amp_design
安装依赖
pip install -r requirements.txt
一次性运行项目
tensorflow版本
# 1. 数据准备
python scripts/data_preparation.py –all
# 2. 构建系统发育树
python scripts/build_phylogenetic_tree.py
# 3. 训练模型
python scripts/train_generator.py
python scripts/train_classifier.py
# 4. 生成肽序列
python scripts/generate_peptides.py
# 5. 筛选肽序列
python scripts/filter_peptides.py
# 6. 分析物理化学性质
python scripts/analyze_properties.py
pytorch版本
# 1. 数据准备
python scripts/data_preparation.py –all
# 2. 构建系统发育树
python scripts/build_phylogenetic_tree.py
# 3. 训练模型
python scripts/train_generator_pytorch.py
python scripts/train_classifier.py
# 4. 生成肽序列
python scripts/generate_peptides_pytorch.py
# 5. 筛选肽序列
python scripts/filter_peptides.py
# 6. 分析物理化学性质
python scripts/analyze_properties.py
训练记录
训练生成器模型
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1770690095.088961 40175 cuda_executor.cc:1309] INTERNAL: CUDA Runtime error: Failed call to cudaGetRuntimeVersion: Error loading CUDA libraries. GPU will not be used.: Error loading CUDA libraries. GPU will not be used.
W0000 00:00:1770690095.142985 40175 gpu_device.cc:2342] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices…
Model: "sequential"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ Layer (type) ┃ Output Shape ┃ Param # ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│ embedding (Embedding) │ ? │ 0 (unbuilt) │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ lstm (LSTM) │ ? │ 0 (unbuilt) │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ dropout (Dropout) │ ? │ 0 │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ lstm_1 (LSTM) │ ? │ 0 (unbuilt) │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ dropout_1 (Dropout) │ ? │ 0 │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ dense (Dense) │ ? │ 0 (unbuilt) │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ dense_1 (Dense) │ ? │ 0 (unbuilt) │
└──────────────────────────────────────┴─────────────────────────────┴─────────────────┘
Total params: 0 (0.00 B)
Trainable params: 0 (0.00 B)
Non-trainable params: 0 (0.00 B)
None
Epoch 1/100
200/200 ━━━━━━━━━━━━━━━━━━━━ 22s 98ms/step – accuracy: 0.4964 – loss: 0.6937 – val_accuracy: 0.4866 – val_loss: 0.6937
Epoch 2/100
Epoch 100/100
200/200 ━━━━━━━━━━━━━━━━━━━━ 19s 94ms/step – accuracy: 0.8054 – loss: 0.3158 – val_accuracy: 0.5007 – val_loss: 1.7461
112/112 ━━━━━━━━━━━━━━━━━━━━ 3s 28ms/step
Model performance:
ROC AUC: 0.5128
PR AUC: 0.5124
Accuracy: 0.5113
Precision: 0.5122
Recall: 0.4043
F1 Score: 0.4519
WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`.
activity classifier model saved to models/classifier_activity.h5
Tokenizer saved to models/tokenizer_activity.pkl
训练分类器模型
Training hemolytic classifier model…
Preparing data for hemolytic classifier…
Max sequence length: 50
Data prepared: 4230 sequences, 2217 positive examples
Building hemolytic classifier model…
/tmp/code/venv/lib/python3.10/site-packages/keras/src/layers/core/embedding.py:97: UserWarning: Argument `input_length` is deprecated. Just remove it.
warnings.warn(
Model: "sequential_1"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ Layer (type) ┃ Output Shape ┃ Param # ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│ embedding_1 (Embedding) │ ? │ 0 (unbuilt) │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ lstm_2 (LSTM) │ ? │ 0 (unbuilt) │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ dropout_2 (Dropout) │ ? │ 0 │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ lstm_3 (LSTM) │ ? │ 0 (unbuilt) │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ dropout_3 (Dropout) │ ? │ 0 │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ dense_2 (Dense) │ ? │ 0 (unbuilt) │
├──────────────────────────────────────┼─────────────────────────────┼─────────────────┤
│ dense_3 (Dense) │ ? │ 0 (unbuilt) │
└──────────────────────────────────────┴─────────────────────────────┴─────────────────┘
Total params: 0 (0.00 B)
Trainable params: 0 (0.00 B)
Non-trainable params: 0 (0.00 B)
None
Epoch 1/100
48/48 ━━━━━━━━━━━━━━━━━━━━ 8s 107ms/step – accuracy: 0.5103 – loss: 0.6938 – val_accuracy: 0.5162 – val_loss: 0.6928
Epoch 2/100
48/48 ━━━━━━━━━━━━━━━━━━━━ 5s 100ms/step – accuracy: 0.5107 – loss: 0.6933 – val_accuracy: 0.5162 – val_loss: 0.6927
48/48 ━━━━━━━━━━━━━━━━━━━━ 5s 97ms/step – accuracy: 0.7810 – loss: 0.3507 – val_accuracy: 0.4897 – val_loss: 1.5676
Epoch 100/100
48/48 ━━━━━━━━━━━━━━━━━━━━ 5s 97ms/step – accuracy: 0.7911 – loss: 0.3409 – val_accuracy: 0.5015 – val_loss: 1.6722
27/27 ━━━━━━━━━━━━━━━━━━━━ 1s 33ms/step
Model performance:
ROC AUC: 0.4710
PR AUC: 0.5280
Accuracy: 0.4775
Precision: 0.5184
Recall: 0.5792
F1 Score: 0.5471
WARNING:absl:You are saving your model as an HDF5 file via `model.save()` or `keras.saving.save_model(model)`. This file format is considered legacy. We recommend using instead the native Keras format, e.g. `model.save('my_model.keras')` or `keras.saving.save_model(model, 'my_model.keras')`.
hemolytic classifier model saved to models/classifier_hemolytic.h5
Tokenizer saved to models/tokenizer_hemolytic.pkl
生成肽序列
root@c2df61f86faf4cc8b11982820e3f720a-task0-0:/tmp/code/medai# python scripts/generate_peptides_pytorch.py
2026-02-10 14:39:48.601747: I tensorflow/core/util/port.cc:111] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2026-02-10 14:39:48.640338: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2026-02-10 14:39:48.640373: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2026-02-10 14:39:48.640402: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2026-02-10 14:39:48.647452: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2026-02-10 14:39:49.372197: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Using device: cuda
Generating 1000 peptide sequences…
Generating 1000 peptide sequences…
Building generator model…
GeneratorModel(
(embedding): Embedding(21, 64)
(lstm1): LSTM(64, 128, batch_first=True)
(dropout1): Dropout(p=0.2, inplace=False)
(lstm2): LSTM(128, 128, batch_first=True)
(dropout2): Dropout(p=0.2, inplace=False)
(fc): Linear(in_features=128, out_features=21, bias=True)
(softmax): Softmax(dim=-1)
)
Generated 100 sequences
Generated 200 sequences
Generated 300 sequences
Generated 400 sequences
Generated 500 sequences
Generated 600 sequences
Generated 700 sequences
Generated 800 sequences
Generated 900 sequences
Attempts: 1000, Generated: 995 sequences
Generated 1000 sequences
Generated 1000 unique sequences
Sequences saved to data/generated/peptides.csv
筛选肽序列
root@c2df61f86faf4cc8b11982820e3f720a-task0-0:/tmp/code/medai# python scripts/filter_peptides.py
Loading generated peptides…
Loading known sequences…
Loading known antimicrobial peptide sequences…
Loaded 8884 known active antimicrobial peptides
Filtering peptides…
Running complete filtering pipeline…
Filtering peptides by length (10-15)…
Filtered 1000 peptides out of 1000
Filtering peptides by novelty (minimum 5 mutations)…
Filtered 1000 peptides out of 1000
Clustering peptides into 42 clusters…
/opt/conda/lib/python3.10/site-packages/sklearn/cluster/_agglomerative.py:1006: FutureWarning: Attribute `affinity` was deprecated in version 1.2 and will be removed in 1.4. Use `metric` instead
warnings.warn(
Selected 42 representative peptides from 42 clusters
Filtering completed. Final peptides saved to data/processed/filtered_peptides.csv
Total peptides after filtering: 42
Filtering completed. 42 peptides selected.
分析物理化学性质
root@c2df61f86faf4cc8b11982820e3f720a-task0-0:/tmp/code/medai# python scripts/analyze_properties.py
Loading peptides…
Analyzing physicochemical properties…
Analyzing physicochemical properties…
Calculating physicochemical properties…
Calculated properties for 42 valid sequences
Properties saved to analysis/results/physicochemical_properties.csv
Generating visualizations…
Visualizations saved to analysis/results
Analysis completed.
调试
生成肽序列报错
生成肽序列报错,我看前面生成的有这个文件medai/models/generator_basic.h5 ,是不是名字没有写对? :(venv) root@x1c19c5aa4fd4cc5bb7ad6eb5c89ad92-task0-0:/tmp/code/medai# python scripts/generate_peptides.py
2026-02-10 03:03:42.151461: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:31] Could not find cuda drivers on your machine, GPU will not be used.
2026-02-10 03:03:42.151804: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2026-02-10 03:03:42.199419: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2026-02-10 03:03:43.615015: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2026-02-10 03:03:43.615855: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:31] Could not find cuda drivers on your machine, GPU will not be used.
Generating 660000 peptide sequences…
Generating 660000 peptide sequences…
Traceback (most recent call last):
File "/tmp/code/medai/scripts/generate_peptides.py", line 42, in <module>
main()
File "/tmp/code/medai/scripts/generate_peptides.py", line 33, in main
generator.generate_sequences(
File "/tmp/code/medai/models/generator.py", line 193, in generate_sequences
self.model = load_model(model_path)
File "/tmp/code/venv/lib/python3.10/site-packages/keras/src/saving/saving_api.py", line 196, in load_model
return legacy_h5_format.load_model_from_hdf5(
File "/tmp/code/venv/lib/python3.10/site-packages/keras/src/legacy/saving/legacy_h5_format.py", line 118, in load_model_from_hdf5
f = h5py.File(filepath, mode="r")
File "/tmp/code/venv/lib/python3.10/site-packages/h5py/_hl/files.py", line 566, in __init__
fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
File "/tmp/code/venv/lib/python3.10/site-packages/h5py/_hl/files.py", line 241, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 104, in h5py.h5f.open
FileNotFoundError: [Errno 2] Unable to synchronously open file (unable to open file: name = 'models/generator_acnes.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
交给Trae去处理。
后面还有一些小问题,都让AI解决了。


