Skip to content

Commit 23e8c76

Browse files
committed
update v 0.0.6
1 parent 58d05db commit 23e8c76

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

AmberMDrun/mmpbsa.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def split_pdb(pdb: str):
6262
return "pro.pdb", "mol.mol2"
6363

6464

65-
def run_tleap(protein: str, mol_list: List, charge: List, multiplicity: List, guess_charge: bool):
65+
def run_tleap(protein: str, mol_list: List, user_charge: bool, charge: List, multiplicity: List, guess_charge: bool):
6666
cmdline = f'pdb4amber -i {protein} -o _{str(protein)} -y -d -p'
6767
runCMD(cmdline)
6868
protein_path = Path(protein).absolute()
@@ -72,6 +72,13 @@ def run_tleap(protein: str, mol_list: List, charge: List, multiplicity: List, gu
7272
cmdline = f'acpype -i {str(Path(mol).absolute())}'
7373
runCMD(cmdline,
7474
message="Perhaps you should check the charge of the ligand and the correctness of the hydrogen atom.")
75+
elif user_charge:
76+
for mol in mol_list:
77+
if Path(mol).suffix != '.mol2':
78+
raise RuntimeError('must mol2 for user charge!')
79+
cmdline = f'acpype -i {str(Path(mol).absolute())} -c user'
80+
runCMD(cmdline,
81+
message="Perhaps you should check the charge of the ligand and the correctness of the hydrogen atom.")
7582
else:
7683
for mol, c, spin in zip(mol_list, charge, multiplicity):
7784
cmdline = f'acpype -i {str(Path(mol).absolute())} -n {c} -m {spin}'
@@ -80,7 +87,11 @@ def run_tleap(protein: str, mol_list: List, charge: List, multiplicity: List, gu
8087

8188
mol_frcmod = f"".join(
8289
f'loadamberparams {mol_path.stem}.acpype/{mol_path.stem}_AC.frcmod\n' for mol_path in mol_list)
83-
mol_load = f"".join(
90+
if user_charge:
91+
mol_load = f"".join(
92+
f'{mol_path.stem} = loadmol2 {mol_path.stem}.acpype/{mol_path.stem}_user_gaff2.mol2\n' for mol_path in mol_list)
93+
else:
94+
mol_load = f"".join(
8495
f'{mol_path.stem} = loadmol2 {mol_path.stem}.acpype/{mol_path.stem}_bcc_gaff2.mol2\n' for mol_path in mol_list)
8596
combine = f'com = combine{{pro {" ".join(mol_path.stem for mol_path in mol_list)}}}\n'
8697
leapin = (f"""source leaprc.protein.ff14SB
@@ -173,9 +184,10 @@ def arg_parse():
173184
help="time for MD(ns)", default=100)
174185
parser.add_argument('-g', '--guess_charge',
175186
action='store_true', help='guess charge')
187+
parser.add_argument('-uc', '--user_charge',
188+
action='store_true', help='user charge')
176189
parser.add_argument('-c', "--charge", type=int, nargs='+',
177190
default=[0], help="charge of mol")
178-
179191
parser.add_argument("--multiplicity", type=int, nargs='+',
180192
default=[1], help="multiplicity of mol")
181193
parser.add_argument("--MIN", type=str,
@@ -191,22 +203,22 @@ def mmpbsa():
191203
protein = args.protein
192204
mol_list = args.mol2
193205
temp = args.temp
194-
if not args.guess_charge:
206+
if not args.guess_charge and not args.user_charge:
195207
if len(mol_list) != len(args.charge) and len(mol_list) != len(args.multiplicity):
196208
raise ValueError(
197209
"If the charge is not guessed, it is necessary to specify the charge and spin multiplicity for each ligand.")
198210

199211
if mol_list is None:
200212
protein, mol = split_pdb(protein)
201213
mol_list = [mol]
202-
parm7, rst7 = run_tleap(protein, mol_list, args.charge,
214+
parm7, rst7 = run_tleap(protein, mol_list, args.charge, args.user_charge,
203215
args.multiplicity, args.guess_charge)
204216
s = pyamber.SystemInfo(parm7, rst7, runMin=args.MIN, runMd=args.MD)
205217
heavymask = "\"" + s.getHeavyMask() + "\""
206218
backbonemask = "\"" + s.getBackBoneMask() + "\""
207219
rst7 = prep(rst7=rst7, s=s, temp=temp, heavymask=heavymask,
208220
backbonemask=backbonemask, loop=20)
209-
md = pyamber.NPT("md", s, rst7, rst7, ntwx=50000,
221+
md = pyamber.NPT("md", s, rst7, rst7, ntwx=50000,temp=temp,
210222
irest=True, nscm=1000, nstlim=args.ns * 500000)
211223
md.Run()
212224
rst7 = 'final_0.rst7'

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ options:
7979
## How to calculate MM-PB (GB) SA between small molecules and proteins of a single drug
8080

8181
~~~bash
82-
usage: mmpbsa [-h] --protein PROTEIN [--mol2 MOL2 [MOL2 ...]] [--temp TEMP] [--ns NS] [-g] [-c CHARGE [CHARGE ...]] [--multiplicity MULTIPLICITY [MULTIPLICITY ...]] [--MIN MIN] [--MD MD]
82+
usage: mmpbsa [-h] --protein PROTEIN [--mol2 MOL2 [MOL2 ...]] [--temp TEMP] [--ns NS] [-g] [-uc] [-c CHARGE [CHARGE ...]] [--multiplicity MULTIPLICITY [MULTIPLICITY ...]]
83+
[--MIN MIN] [--MD MD]
8384

8485
Tools for automating the operation of MMPBSA
8586

@@ -92,6 +93,7 @@ options:
9293
--temp TEMP, -t TEMP Temperature
9394
--ns NS, -n NS time for MD(ns)
9495
-g, --guess_charge guess charge
96+
-uc, --user_charge user charge
9597
-c CHARGE [CHARGE ...], --charge CHARGE [CHARGE ...]
9698
charge of mol
9799
--multiplicity MULTIPLICITY [MULTIPLICITY ...]

README.zh.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ options:
7878
~~~
7979
## 如何计算单个小分子和蛋白质之间的MM-PB(GB)SA
8080
~~~bash
81-
usage: mmpbsa [-h] --protein PROTEIN [--mol2 MOL2 [MOL2 ...]] [--temp TEMP] [--ns NS] [-g] [-c CHARGE [CHARGE ...]] [--multiplicity MULTIPLICITY [MULTIPLICITY ...]] [--MIN MIN] [--MD MD]
81+
usage: mmpbsa [-h] --protein PROTEIN [--mol2 MOL2 [MOL2 ...]] [--temp TEMP] [--ns NS] [-g] [-uc] [-c CHARGE [CHARGE ...]] [--multiplicity MULTIPLICITY [MULTIPLICITY ...]]
82+
[--MIN MIN] [--MD MD]
8283

8384
Tools for automating the operation of MMPBSA
8485

@@ -91,6 +92,7 @@ options:
9192
--temp TEMP, -t TEMP Temperature
9293
--ns NS, -n NS time for MD(ns)
9394
-g, --guess_charge guess charge
95+
-uc, --user_charge user charge
9496
-c CHARGE [CHARGE ...], --charge CHARGE [CHARGE ...]
9597
charge of mol
9698
--multiplicity MULTIPLICITY [MULTIPLICITY ...]
@@ -108,6 +110,11 @@ mmpbsa -p complex.pdb
108110
~~~bash
109111
mmpbsa -p pro.pdb -m lig1.mol2 lig2.mol2 -g -n 100
110112
~~~
113+
## V0.0.6 添加自定义电荷选项
114+
添加了一个选项`-uc`用于使用自定义小分子的静电荷,只能用mol2文件,例如:
115+
~~~bash
116+
mmpbsa -p pro.pdb -m lig1.mol2 lig2.mol2 -uc -n 100
117+
~~~
111118
## 如何通过继承扩展代码
112119
我们将在不久的将来进行描述。
113120

conda.recipe/meta.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package:
22
name: ambermdrun
3-
version: 0.0.5
3+
version: 0.0.6
44

55
source:
66
path: ..

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.5",
128+
version="0.0.6",
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)