Skip to content

Commit 8e8a6c1

Browse files
authored
Merge pull request #3 from 9527567/dev
Dev
2 parents e3a3c60 + e4617d6 commit 8e8a6c1

File tree

8 files changed

+189
-55
lines changed

8 files changed

+189
-55
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
2+
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
3+
name: CMake on a single platform
4+
5+
on:
6+
push:
7+
branches: [ "dev" , "main" ]
8+
pull_request:
9+
branches: [ "dev" , "main" ]
10+
11+
env:
12+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
13+
BUILD_TYPE: Release
14+
15+
jobs:
16+
build:
17+
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
18+
# You can convert this to a matrix build if you need cross-platform coverage.
19+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
with:
25+
submodules: true
26+
- name: Configure CMake
27+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
28+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
29+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
30+
31+
- name: Build
32+
# Build your program with the given configuration
33+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
34+
35+
- name: Test
36+
working-directory: ${{github.workspace}}/build
37+
# Execute tests defined by the CMake configuration.
38+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
39+
run: ctest -C ${{env.BUILD_TYPE}}
40+

AmberMDrun/equil.py

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
from . import pyamber
22
import os
33
import pandas as pd
4+
from pathlib import Path
5+
6+
47
def density():
5-
input = f"for FILE in final_?.out,final_??.out \n\
6-
readdata \$FILE name MD \n\
7-
done \n\
8-
evalplateau *[Density] name EQ out Eval.agr resultsout Eval.results\n\
9-
go\n\
10-
quit"
8+
path = Path.cwd()
9+
final_file = []
10+
for out_file in path.glob('final_*.out'):
11+
final_file.append(out_file)
12+
input = (f"for FILE in {' '.join([item.name for item in final_file])} \n"
13+
"readdata \$FILE name MD \n"
14+
"done \n"
15+
"evalplateau *[Density] name EQ out Eval.agr resultsout Eval.results\n"
16+
"go\n"
17+
"quit"
18+
)
19+
1120
with open("cpptraj.in", "w") as f:
1221
f.write(input)
1322
os.system(f'cpptraj -i cpptraj.in')
14-
result = pd.read_csv("Eval.results",sep="\s+")
23+
result = pd.read_csv("Eval.results", sep="\s+")
1524
if result["EQ[result]"][0] == "yes":
1625
return 0
1726
elif result["EQ[result]"][0] == "no":
@@ -52,10 +61,12 @@ def prep(rst7, s, temp, heavymask, backbonemask, loop=20):
5261
ref = "step9.rst7"
5362
for i in range(loop):
5463
final = pyamber.NPT(f"final_{i}", systemInfo=s, ref=ref, temp=temp,
55-
refc="step5.rst7", irest=True, dt=0.002, nscm=1000, nstlim=500000, ntwx=5000)
64+
refc="step5.rst7", irest=True, dt=0.002, nscm=1000, nstlim=500000, ntwx=5000)
5665
final.Run()
5766
result = density()
5867
if result == 0:
59-
return f'final_{i}.rst7'
68+
return f'final_{i}.rst7'
6069
ref = f'final_{i}.rst7'
61-
raise RuntimeError("More than 20 iterations of final density equil required. Bailing out.")
70+
raise RuntimeError(
71+
"More than 20 iterations of final density equil required. Bailing out.")
72+

AmberMDrun/extern/pybind11

Submodule pybind11 updated 107 files

AmberMDrun/mmpbsa.py

+63-34
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import logging
77
from logging import getLogger
88
import subprocess
9+
from typing import List
910

1011

1112
def runCMD(inCmd, *, raise_on_fail: bool = True, logger: logging.Logger = getLogger("mmpbsa"), **kwargs):
@@ -61,36 +62,45 @@ def split_pdb(pdb: str):
6162
return "pro.pdb", "mol.mol2"
6263

6364

64-
def run_tleap(protein: str, mol: str, charge: int, multiplicity: int):
65+
def run_tleap(protein: str, mol_list: List, charge: List, multiplicity: List, guess_charge: bool):
6566
cmdline = f'pdb4amber -i {protein} -o _{str(protein)} -y -d -p'
6667
runCMD(cmdline)
6768
protein_path = Path(protein).absolute()
68-
mol_path = Path(mol).absolute()
69-
cmdline = f'acpype -i {str(mol_path)} -n {charge} -m {multiplicity}'
70-
runCMD(cmdline,
71-
message="Perhaps you should check the charge of the ligand and the correctness of the hydrogen atom.")
72-
leapin = f"source leaprc.protein.ff14SB\n\
73-
source leaprc.DNA.OL15\n\
74-
source leaprc.RNA.OL3\n\
75-
source leaprc.water.tip3p\n\
76-
source leaprc.gaff2\n\
77-
pro = loadpdb _{protein}\n\
78-
loadamberparams {mol_path.stem}.acpype/{mol_path.stem}_AC.frcmod\n\
79-
mol = loadmol2 {mol_path.stem}.acpype/{mol_path.stem}_bcc_gaff2.mol2\n\
80-
com = combine{{pro mol}}\n\
81-
solvatebox com TIP3PBOX 10.0\n\
82-
addions2 com Na+ 0\n\
83-
addions2 com Cl- 0\n\
84-
saveamberparm com {protein_path.stem}_{mol_path.stem}.parm7 {protein_path.stem}_{mol_path.stem}.rst7\n\
85-
quit"
69+
mol_list = [Path(mol) for mol in mol_list]
70+
if guess_charge:
71+
for mol in mol_list:
72+
cmdline = f'acpype -i {str(Path(mol).absolute())}'
73+
runCMD(cmdline,
74+
message="Perhaps you should check the charge of the ligand and the correctness of the hydrogen atom.")
75+
else:
76+
for mol, c, spin in zip(mol_list, charge, multiplicity):
77+
cmdline = f'acpype -i {str(Path(mol).absolute())} -n {c} -m {spin}'
78+
runCMD(cmdline,
79+
message="Perhaps you should check the charge of the ligand and the correctness of the hydrogen atom.")
80+
81+
mol_frcmod = f"".join(
82+
f'loadamberparams {mol_path.stem}.acpype/{mol_path.stem}_AC.frcmod\n' for mol_path in mol_list)
83+
mol_load = f"".join(
84+
f'{mol_path.stem} = loadmol2 {mol_path.stem}.acpype/{mol_path.stem}_bcc_gaff2.mol2\n' for mol_path in mol_list)
85+
combine = f'com = combine{{pro {" ".join(mol_path.stem for mol_path in mol_list)}}}\n'
86+
leapin = (f"""source leaprc.protein.ff14SB
87+
source leaprc.DNA.OL15
88+
source leaprc.RNA.OL3
89+
source leaprc.water.tip3p
90+
source leaprc.gaff2
91+
pro = loadpdb _{protein}\n""") + mol_frcmod + mol_load + combine + (f"""solvatebox com TIP3PBOX 10.0
92+
addionsrand com Na+ 0
93+
addionsrand com Cl- 0
94+
saveamberparm com com.parm7 com.rst7
95+
quit""")
8696
with open("leap.in", "w") as f:
8797
for i in leapin:
8898
f.write(i)
8999
runCMD('tleap -f leap.in')
90-
return f'{protein_path.stem}_{mol_path.stem}.parm7', f'{protein_path.stem}_{mol_path.stem}.rst7'
100+
return f'com.parm7', f'com.rst7'
91101

92102

93-
def mmpbsa(parm7: str, rst7: str, netcdf: str, system: pyamber.SystemInfo):
103+
def run_mmpbsa(parm7: str, rst7: str, netcdf: str, system: pyamber.SystemInfo, mol_list: List):
94104
parm7 = Path(parm7).absolute()
95105
rst7 = Path(rst7).absolute()
96106

@@ -138,25 +148,36 @@ def mmpbsa(parm7: str, rst7: str, netcdf: str, system: pyamber.SystemInfo):
138148
with open("mmpbsa.in", 'w') as f:
139149
for i in mmpbsa_in:
140150
f.write(i)
141-
mmpbsa = f"mpirun -np {cpu_count() // 2} gmx_MMPBSA MPI -O -i mmpbsa.in -cs {str(parm7.with_suffix('.pdb'))} -ci index.ndx -cg 1 13 -ct {str(parm7.with_suffix('.xtc'))} -cp \
142-
{str(parm7.with_suffix('.top'))} -nogui"
143-
runCMD(mmpbsa)
151+
mol_number = 13
152+
for mol in range(len(mol_list)):
153+
mol_path = Path.cwd().joinpath(f'lig{mol}')
154+
mol_path.mkdir(exist_ok=True)
155+
os.chdir(str(mol_path))
156+
mmpbsa = f"mpirun -np {cpu_count() // 2} gmx_MMPBSA MPI -O -i ../mmpbsa.in -cs {str(parm7.with_suffix('.pdb'))} -ci ../index.ndx -cg 1 {mol_number} -ct {str(parm7.with_suffix('.xtc'))} -cp \
157+
{str(parm7.with_suffix('.top'))} -nogui"
158+
runCMD(mmpbsa)
159+
os.chdir('..')
160+
mol_number += 1
144161

145162

146163
def arg_parse():
147-
parser = argparse.ArgumentParser(description='Tools for automating the operation of MMPBSA')
164+
parser = argparse.ArgumentParser(
165+
description='Tools for automating the operation of MMPBSA')
148166
parser.add_argument('--protein', '-p', type=str,
149167
required=True, help="pdb file for protein")
150-
parser.add_argument('--mol2', '-m', type=str,
168+
parser.add_argument('--mol2', '-m', type=str, nargs='+',
151169
required=False, help='mol2 file for mol')
152170
parser.add_argument('--temp', '-t', type=float,
153171
required=False, help='Temperature', default=303.15)
154172
parser.add_argument("--ns", '-n', type=int,
155173
help="time for MD(ns)", default=100)
156-
parser.add_argument("--charge", type=int,
157-
default=0, help="charge of mol")
158-
parser.add_argument("--multiplicity", type=int,
159-
default=1, help="multiplicity of mol")
174+
parser.add_argument('-g', '--guess_charge',
175+
action='store_true', help='guess charge')
176+
parser.add_argument('-c', "--charge", type=int, nargs='+',
177+
default=[0], help="charge of mol")
178+
179+
parser.add_argument("--multiplicity", type=int, nargs='+',
180+
default=[1], help="multiplicity of mol")
160181
parser.add_argument("--MIN", type=str,
161182
default="pmemd.cuda_DPFP", help="Engine for MIN")
162183
parser.add_argument("--MD", type=str,
@@ -168,11 +189,18 @@ def arg_parse():
168189
def mmpbsa():
169190
args = arg_parse()
170191
protein = args.protein
171-
mol = args.mol2
192+
mol_list = args.mol2
172193
temp = args.temp
173-
if mol is None:
194+
if not args.guess_charge:
195+
if len(mol_list) != len(args.charge) and len(mol_list) != len(args.multiplicity):
196+
raise ValueError(
197+
"If the charge is not guessed, it is necessary to specify the charge and spin multiplicity for each ligand.")
198+
199+
if mol_list is None:
174200
protein, mol = split_pdb(protein)
175-
parm7, rst7 = run_tleap(protein, mol, args.charge, args.multiplicity)
201+
mol_list = [mol]
202+
parm7, rst7 = run_tleap(protein, mol_list, args.charge,
203+
args.multiplicity, args.guess_charge)
176204
s = pyamber.SystemInfo(parm7, rst7, runMin=args.MIN, runMd=args.MD)
177205
heavymask = "\"" + s.getHeavyMask() + "\""
178206
backbonemask = "\"" + s.getBackBoneMask() + "\""
@@ -181,7 +209,8 @@ def mmpbsa():
181209
md = pyamber.NPT("md", s, rst7, rst7, ntwx=50000,
182210
irest=True, nscm=1000, nstlim=args.ns * 500000)
183211
md.Run()
184-
mmpbsa(parm7, rst7, "md.nc", s)
212+
rst7 = 'final_0.rst7'
213+
run_mmpbsa(parm7, rst7, "md.nc", s, mol_list)
185214

186215

187216
if __name__ == '__main__':

AmberMDrun/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.0.4'
1+
__version__ = '0.0.5'

README.md

+30-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
# AmberMDrun
55
Easy to use, easy to expand, high-performance Amber simulation package
6+
## Update
7+
v0.0.5 Added support for multiple ligands.
68
## Install
79
This software only supports **Linux** because some Linux system functions are called.**Mac OS X** and **Windows** are not supported.
810
### Necessary
@@ -77,19 +79,22 @@ options:
7779
## How to calculate MM-PB (GB) SA between small molecules and proteins of a single drug
7880

7981
~~~bash
80-
usage: mmpbsa [-h] --protein PROTEIN [--mol2 MOL2] [--temp TEMP] [--ns NS] [--charge CHARGE] [--multiplicity MULTIPLICITY] [--MIN MIN] [--MD MD]
82+
usage: mmpbsa [-h] --protein PROTEIN [--mol2 MOL2 [MOL2 ...]] [--temp TEMP] [--ns NS] [-g] [-c CHARGE [CHARGE ...]] [--multiplicity MULTIPLICITY [MULTIPLICITY ...]] [--MIN MIN] [--MD MD]
8183

8284
Tools for automating the operation of MMPBSA
8385

8486
options:
8587
-h, --help show this help message and exit
8688
--protein PROTEIN, -p PROTEIN
8789
pdb file for protein
88-
--mol2 MOL2, -m MOL2 mol2 file for mol
90+
--mol2 MOL2 [MOL2 ...], -m MOL2 [MOL2 ...]
91+
mol2 file for mol
8992
--temp TEMP, -t TEMP Temperature
9093
--ns NS, -n NS time for MD(ns)
91-
--charge CHARGE charge of mol
92-
--multiplicity MULTIPLICITY
94+
-g, --guess_charge guess charge
95+
-c CHARGE [CHARGE ...], --charge CHARGE [CHARGE ...]
96+
charge of mol
97+
--multiplicity MULTIPLICITY [MULTIPLICITY ...]
9398
multiplicity of mol
9499
--MIN MIN Engine for MIN
95100
--MD MD Engine for MD
@@ -98,6 +103,11 @@ Typically, the complex structure after molecular docking is used to perform MMPB
98103
~~~bash
99104
mmpbsa -p complex.pdb
100105
~~~
106+
## V0.0.5 added support for multiple ligands
107+
Just follow the files of multiple ligands after -m, and add an option `-g` to guess the static charge of small molecules, or manually specify the static charge, for example:
108+
~~~bash
109+
mmpbsa -p pro.pdb -m lig1.mol2 lig2.mol2 -g -n 100
110+
~~~
101111
## How to extend code through inheritance classes
102112
Will be described in the near future
103113

@@ -116,4 +126,20 @@ URL = {https://www.mdpi.com/2218-273X/13/4/635},
116126
ISSN = {2218-273X},
117127
DOI = {10.3390/biom13040635}
118128
}
129+
~~~
130+
## If you are interested, you can also cite this article
131+
~~~tex
132+
@article{CUI2023134812,
133+
title = {A TastePeptides-Meta system including an umami/bitter classification model Umami_YYDS, a TastePeptidesDB database and an open-source package Auto_Taste_ML},
134+
journal = {Food Chemistry},
135+
volume = {405},
136+
pages = {134812},
137+
year = {2023},
138+
issn = {0308-8146},
139+
doi = {https://doi.org/10.1016/j.foodchem.2022.134812},
140+
url = {https://www.sciencedirect.com/science/article/pii/S0308814622027741},
141+
author = {Zhiyong Cui and Zhiwei Zhang and Tianxing Zhou and Xueke Zhou and Yin Zhang and Hengli Meng and Wenli Wang and Yuan Liu},
142+
keywords = {Peptides, Umami prediction, TastePeptidesDB, Machine learning},
143+
abstract = {Taste peptides with umami/bitterness play a role in food attributes. However, the taste mechanisms of peptides are not fully understood, and the identification of these peptides is time-consuming. Here, we created a taste peptide database by collecting the reported taste peptide information. Eight key molecular descriptors from di/tri-peptides were selected and obtained by modeling screening. A gradient boosting decision tree model named Umami_YYDS (89.6\% accuracy) was established by data enhancement, comparison algorithm and model optimization. Our model showed a great prediction performance compared to other models, and its outstanding ability was verified by sensory experiments. To provide a convenient approach, we deployed a prediction website based on Umami_YYDS and uploaded the Auto_Taste_ML machine learning package. In summary, we established the system TastePeptides-Meta, containing a taste peptide database TastePeptidesDB an umami/bitter taste prediction model Umami_YYDS and an open-source machine learning package Auto_Taste_ML, which were helpful for rapid screening of umami peptides.}
144+
}
119145
~~~

README.zh.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# AmberMDrun
22
易于使用、易于扩展、高性能的Amber模拟软件包。
3+
## 版本更新
4+
v0.0.5 添加了多配体的支持。
35
## 安装
46
此软件仅支持**Linux**,因为某些Linux系统功能被调用。**Mac OS X****Windows**不受支持。
57
### 必要的依赖
@@ -76,19 +78,22 @@ options:
7678
~~~
7779
## 如何计算单个小分子和蛋白质之间的MM-PB(GB)SA
7880
~~~bash
79-
usage: mmpbsa [-h] --protein PROTEIN [--mol2 MOL2] [--temp TEMP] [--ns NS] [--charge CHARGE] [--multiplicity MULTIPLICITY] [--MIN MIN] [--MD MD]
81+
usage: mmpbsa [-h] --protein PROTEIN [--mol2 MOL2 [MOL2 ...]] [--temp TEMP] [--ns NS] [-g] [-c CHARGE [CHARGE ...]] [--multiplicity MULTIPLICITY [MULTIPLICITY ...]] [--MIN MIN] [--MD MD]
8082

8183
Tools for automating the operation of MMPBSA
8284

8385
options:
8486
-h, --help show this help message and exit
8587
--protein PROTEIN, -p PROTEIN
8688
pdb file for protein
87-
--mol2 MOL2, -m MOL2 mol2 file for mol
89+
--mol2 MOL2 [MOL2 ...], -m MOL2 [MOL2 ...]
90+
mol2 file for mol
8891
--temp TEMP, -t TEMP Temperature
8992
--ns NS, -n NS time for MD(ns)
90-
--charge CHARGE charge of mol
91-
--multiplicity MULTIPLICITY
93+
-g, --guess_charge guess charge
94+
-c CHARGE [CHARGE ...], --charge CHARGE [CHARGE ...]
95+
charge of mol
96+
--multiplicity MULTIPLICITY [MULTIPLICITY ...]
9297
multiplicity of mol
9398
--MIN MIN Engine for MIN
9499
--MD MD Engine for MD
@@ -97,6 +102,12 @@ options:
97102
~~~bash
98103
mmpbsa -p complex.pdb
99104
~~~
105+
106+
## V0.0.5 添加了多配体的支持
107+
只需要在-m 后跟多个配体的文件即可,添加了一个选项`-g`用于猜测小分子的静电荷,或者手动指定静电荷,例如:
108+
~~~bash
109+
mmpbsa -p pro.pdb -m lig1.mol2 lig2.mol2 -g -n 100
110+
~~~
100111
## 如何通过继承扩展代码
101112
我们将在不久的将来进行描述。
102113

@@ -115,4 +126,21 @@ URL = {https://www.mdpi.com/2218-273X/13/4/635},
115126
ISSN = {2218-273X},
116127
DOI = {10.3390/biom13040635}
117128
}
129+
~~~
130+
## 如果您感兴趣的话,也可以引用这篇文章
131+
bibtex:
132+
~~~tex
133+
@article{CUI2023134812,
134+
title = {A TastePeptides-Meta system including an umami/bitter classification model Umami_YYDS, a TastePeptidesDB database and an open-source package Auto_Taste_ML},
135+
journal = {Food Chemistry},
136+
volume = {405},
137+
pages = {134812},
138+
year = {2023},
139+
issn = {0308-8146},
140+
doi = {https://doi.org/10.1016/j.foodchem.2022.134812},
141+
url = {https://www.sciencedirect.com/science/article/pii/S0308814622027741},
142+
author = {Zhiyong Cui and Zhiwei Zhang and Tianxing Zhou and Xueke Zhou and Yin Zhang and Hengli Meng and Wenli Wang and Yuan Liu},
143+
keywords = {Peptides, Umami prediction, TastePeptidesDB, Machine learning},
144+
abstract = {Taste peptides with umami/bitterness play a role in food attributes. However, the taste mechanisms of peptides are not fully understood, and the identification of these peptides is time-consuming. Here, we created a taste peptide database by collecting the reported taste peptide information. Eight key molecular descriptors from di/tri-peptides were selected and obtained by modeling screening. A gradient boosting decision tree model named Umami_YYDS (89.6\% accuracy) was established by data enhancement, comparison algorithm and model optimization. Our model showed a great prediction performance compared to other models, and its outstanding ability was verified by sensory experiments. To provide a convenient approach, we deployed a prediction website based on Umami_YYDS and uploaded the Auto_Taste_ML machine learning package. In summary, we established the system TastePeptides-Meta, containing a taste peptide database TastePeptidesDB an umami/bitter taste prediction model Umami_YYDS and an open-source machine learning package Auto_Taste_ML, which were helpful for rapid screening of umami peptides.}
145+
}
118146
~~~

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def build_extension(self, ext: CMakeExtension) -> None:
125125
# logic and declaration, and simpler if you include description/version in a file.
126126
setup(
127127
name="AmberMDrun",
128-
version="0.0.4",
128+
version="0.0.5",
129129
author="ZhiWei Zhang",
130130
author_email="[email protected]",
131131
description="A scripting tool for running Amber MD in an easy way",

0 commit comments

Comments
 (0)