Skip to content

Commit

Permalink
Improve installation instructions and README (#51)
Browse files Browse the repository at this point in the history
* Improve installation instructions and README

* Added fixed BGC.mol2 example file
  • Loading branch information
Jnelen authored Jul 9, 2024
1 parent 27e6f14 commit 207a777
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 193 deletions.
File renamed without changes.
166 changes: 87 additions & 79 deletions README.md

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
FROM continuumio/miniconda3

# 1. create a enverioment
# 1. create an environment
SHELL ["/bin/bash", "-c"]
RUN conda create -n gbsa -c conda-forge acpype gromacs openmpi mpi4py \
&& echo -e 'conda activate gbsa' >> ~/.bashrc \
&& echo -e 'alias ls="ls --color" \n' >> ~/.bashrc \
RUN conda create -n gbsa -c conda-forge acpype openmpi mpi4py gromacs "gmx_MMPBSA>=1.5.6" \
&& echo 'conda activate gbsa' >> ~/.bashrc \
&& rm -rf /opt/conda/pkgs/*


# 2. install Uni-GBSA
# 2. install unigbsa
RUN source ~/.bashrc \
&& pip install unigbsa gmx_MMPBSA>=1.5.6 lickit \
&& pip install unigbsa lickit \
&& rm -rf ~/.cache/*

90 changes: 50 additions & 40 deletions example/2fvy/BGC.mol2
Original file line number Diff line number Diff line change
@@ -1,46 +1,56 @@
@<TRIPOS>MOLECULE
BGC.pdb
19 19 0 0 0
*****
24 24 0 0 0
SMALL
GASTEIGER

@<TRIPOS>ATOM
1 C2 5.7270 -0.3600 18.6130 C.3 310 BGC310 0.1785
2 C3 5.9140 -0.0610 20.0890 C.3 310 BGC310 0.1591
3 C4 7.4720 -0.0340 20.4130 C.3 310 BGC310 0.1537
4 C5 8.1890 0.9590 19.4030 C.3 310 BGC310 0.1198
5 C6 9.6750 0.9410 19.5730 C.3 310 BGC310 0.1117
6 C1 6.4990 0.6150 17.7400 C.3 310 BGC310 0.2249
7 O1 6.3840 0.3520 16.3470 O.3 310 BGC310 -0.1973
8 O2 4.3570 -0.3230 18.2440 O.3 310 BGC310 -0.2229
9 O3 5.3190 -1.0720 20.9170 O.3 310 BGC310 -0.2253
10 O4 7.5320 0.4810 21.7220 O.3 310 BGC310 -0.2255
11 O5 7.9390 0.5700 18.0530 O.3 310 BGC310 -0.3380
12 O6 10.3750 1.7990 18.5980 O.3 310 BGC310 -0.2320
13 H2 6.0670 -1.2620 18.4390 H 310 BGC310 0.0709
14 H3 5.5190 0.8110 20.3010 H 310 BGC310 0.0685
15 H4 7.8610 -0.9320 20.3650 H 310 BGC310 0.0683
16 H5 7.8550 1.8680 19.5480 H 310 BGC310 0.0649
17 H61 9.8940 1.2390 20.4690 H 310 BGC310 0.0618
18 H62 9.9930 0.0300 19.4770 H 310 BGC310 0.0618
19 H1 6.1690 1.5210 17.9150 H 310 BGC310 0.0969
1 C 5.7270 -0.3600 18.6130 C.3 1 UNL1 0.1339
2 C 5.9140 -0.0610 20.0890 C.3 1 UNL1 0.1141
3 C 7.4720 -0.0340 20.4130 C.3 1 UNL1 0.1119
4 C 8.1890 0.9590 19.4030 C.3 1 UNL1 0.1130
5 C 9.6750 0.9410 19.5730 C.3 1 UNL1 0.0730
6 C 6.4990 0.6150 17.7400 C.3 1 UNL1 0.1854
7 O 6.3840 0.3520 16.3470 O.3 1 UNL1 -0.3649
8 O 4.3570 -0.3230 18.2440 O.3 1 UNL1 -0.3841
9 O 5.3190 -1.0720 20.9170 O.3 1 UNL1 -0.3864
10 O 7.5320 0.4810 21.7220 O.3 1 UNL1 -0.3865
11 O 7.9390 0.5700 18.0530 O.3 1 UNL1 -0.3407
12 O 10.3750 1.7990 18.5980 O.3 1 UNL1 -0.3924
13 H 6.1189 -1.3749 18.4509 H 1 UNL1 0.0671
14 H 5.4318 0.9051 20.2992 H 1 UNL1 0.0648
15 H 7.9602 -1.0155 20.3224 H 1 UNL1 0.0647
16 H 7.7860 1.9595 19.6187 H 1 UNL1 0.0647
17 H 9.9165 1.2926 20.5869 H 1 UNL1 0.0584
18 H 10.0138 -0.0922 19.4064 H 1 UNL1 0.0584
19 H 6.0548 1.5968 17.9606 H 1 UNL1 0.0935
20 H 5.9911 -0.5466 16.2122 H 1 UNL1 0.2126
21 H 3.7959 -0.3078 19.0595 H 1 UNL1 0.2101
22 H 5.4553 -0.8405 21.8699 H 1 UNL1 0.2100
23 H 7.4456 -0.2603 22.3725 H 1 UNL1 0.2100
24 H 10.9215 2.4688 19.0805 H 1 UNL1 0.2095
@<TRIPOS>BOND
1 7 6 1
2 6 19 1
3 6 11 1
4 6 1 1
5 11 4 1
6 8 1 1
7 13 1 1
8 12 5 1
9 1 2 1
10 4 16 1
11 4 5 1
12 4 3 1
13 18 5 1
14 5 17 1
15 2 14 1
16 2 3 1
17 2 9 1
18 15 3 1
19 3 10 1
1 2 1 1
2 3 2 1
3 4 3 1
4 5 4 1
5 6 1 1
6 7 6 1
7 8 1 1
8 9 2 1
9 10 3 1
10 11 6 1
11 11 4 1
12 12 5 1
13 1 13 1
14 2 14 1
15 3 15 1
16 4 16 1
17 5 17 1
18 5 18 1
19 6 19 1
20 7 20 1
21 8 21 1
22 9 22 1
23 10 23 1
24 12 24 1
60 changes: 30 additions & 30 deletions unigbsa/CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@


def PBC_main():
parser = argparse.ArgumentParser(description='Auto process PBC for gromacs MD trajector.')
parser = argparse.ArgumentParser(description='Auto process PBC for gromacs MD trajectory.')
parser.add_argument('-s', dest='tpr', help='TPR file generated from gromacs or coordinate file.', required=True)
parser.add_argument('-f', dest='xtc', help='Trajector file to process PBC.', required=True)
parser.add_argument('-o', dest='out', help='Result file after processed PBC.', default=None)
parser.add_argument('-f', dest='xtc', help='Trajectory file to process PBC.', required=True)
parser.add_argument('-o', dest='out', help='Results file after processed PBC.', default=None)
parser.add_argument('-n', dest='ndx', help='Index file contains the center and output group.', default=None)
parser.add_argument('-v', '--version', action='version', version="{prog}s ({version})".format(prog="%(prog)", version=__version__))

Expand All @@ -35,10 +35,10 @@ def topol_builder():
parser.add_argument('-p', dest='protein', help='Protein file or directory to build topology.', default="")
parser.add_argument('-l', dest='ligand', help='Ligand file or directory to build topology.', default="")
parser.add_argument('-pf', dest='protforce', help='Protein forcefield.', default='amber03')
parser.add_argument('-lf', dest='ligforce', help='Ligand forcefiled: gaff or gaff2.', default='gaff', choices=['gaff','gaff2'])
parser.add_argument('-o', dest='outdir', help='A output directory.', default='GMXtop')
parser.add_argument('-lf', dest='ligforce', help='Ligand forcefield: gaff or gaff2.', default='gaff', choices=['gaff','gaff2'])
parser.add_argument('-o', dest='outdir', help='The output directory.', default='GMXtop')
parser.add_argument('-c', help='Combine the protein and ligand topology. Suppport for one protein and more ligands. default:True', action='store_true', default=True)
parser.add_argument('-nt', dest='thread', help='Number of thread to run this simulation.', default=4)
parser.add_argument('-nt', dest='threads', help='Number of threads to run this simulation.', default=4)
parser.add_argument('-verbose', help='Keep the directory or not.', default=False, action='store_true')
parser.add_argument('-v', '--version', action='version', version="{prog}s ({version})".format(prog="%(prog)", version=__version__))

Expand All @@ -47,7 +47,7 @@ def topol_builder():
proteinForcefield, ligandForcefield = args.protforce, args.ligforce
verbose = args.verbose
if not protein and not ligand:
print('Not found input file!')
print('Could not find the input file!')

proteinfiles, ligandfiles = [], []
if os.path.isdir(protein):
Expand Down Expand Up @@ -75,23 +75,23 @@ def topol_builder():
ligandName = os.path.split(ligandfile)[-1][:-4]
outtop, outcoord, outitp = os.path.join(outdir, ligandName+'.top'), os.path.join(outdir, ligandName+'.pdb'), os.path.join(outdir, ligandName+'.itp')
# outcoord parameter is useless
ligtop, liggro = topology.build_lignad(ligandfile, forcefield=ligandForcefield, charge_method='bcc', outtop=outtop, outcoord=outcoord, itpfile=outitp, nt=args.thread)
ligtop, liggro = topology.build_lignad(ligandfile, forcefield=ligandForcefield, charge_method='bcc', outtop=outtop, outcoord=outcoord, itpfile=outitp, nt=args.threads)
if cF:
comxtop, comxcoord = os.path.join(outdir, "%s_%s.top"%(proteinName, ligandName)), os.path.join(outdir, "%s_%s.pdb"%(proteinName, ligandName))
topology.build_topol((prottop, protgro), (ligtop, liggro), outtop=comxtop, outpdb=comxcoord, verbose=verbose, nt=args.thread)
topology.build_topol((prottop, protgro), (ligtop, liggro), outtop=comxtop, outpdb=comxcoord, verbose=verbose, nt=args.threads)

def simulation_builder():
parser = argparse.ArgumentParser(description='Build MD simulation for input file.')
parser.add_argument('-p', dest='protein', help='Protein file for the simulation.', required=True)
parser.add_argument('-l', dest='ligand', help='Ligand file or directory for the simulation.', default="")
parser.add_argument('-pf', dest='protforce', help='Protein forcefield.', default='amber03')
parser.add_argument('-lf', dest='ligforce', help='Ligand forcefiled: gaff or gaff2.', default='gaff', choices=['gaff','gaff2'])
parser.add_argument('-lf', dest='ligforce', help='Ligand forcefield: gaff or gaff2.', default='gaff', choices=['gaff','gaff2'])
parser.add_argument('-bt', dest='boxtype', help='Simulation box type, default: triclinic', default='triclinic')
parser.add_argument('-box', help='Simulation box size.', nargs=3, type=float, default=None)
parser.add_argument('-d', help='Distance between the solute and the box.', default=0.9, type=float)
parser.add_argument('-conc', help='Specify salt concentration (mol/liter). default=0.15', default=0.15, type=float)
parser.add_argument('-o', dest='outdir', help='A output directory.', default=None)
parser.add_argument('-nt', dest='thread', help='Number of thread to run this simulation.', default=4)
parser.add_argument('-o', dest='outdir', help='The output directory.', default=None)
parser.add_argument('-nt', dest='threads', help='Number of threads to run this simulation.', default=4)
parser.add_argument('-v', '--version', action='version', version="{prog}s ({version})".format(prog="%(prog)", version=__version__))

args = parser.parse_args()
Expand Down Expand Up @@ -123,7 +123,7 @@ def simulation_builder():

if len(ligandfiles) == 0:
logging.info('No ligand found, build protein only.')
topology.build_topol(receptor, None, outpdb=grofile, outtop=topfile, nt=args.thread)
topology.build_topol(receptor, None, outpdb=grofile, outtop=topfile, nt=args.threads)

logging.info('Build simulation for %s'%proteinName)
engine = mdrun.GMXEngine()
Expand All @@ -142,7 +142,7 @@ def simulation_builder():
os.chdir(ligandName)

logging.info('Build ligand topology: %s'%ligandName)
topology.build_topol(receptor, ligandfile, outpdb=grofile, outtop=topfile, ligandforce=ligandForcefield, nt=args.thread)
topology.build_topol(receptor, ligandfile, outpdb=grofile, outtop=topfile, ligandforce=ligandForcefield, nt=args.threads)

logging.info('Building simulation for: %s'%ligandName)
engine = mdrun.GMXEngine()
Expand All @@ -160,22 +160,22 @@ def simulation_run():
parser.add_argument('-p', dest='protein', help='Protein file for the simulation.', required=True)
parser.add_argument('-l', dest='ligand', help='Ligand file or directory for the simulation.', default="")
parser.add_argument('-pf', dest='protforce', help='Protein forcefield.', default='amber03')
parser.add_argument('-lf', dest='ligforce', help='Ligand forcefiled: gaff or gaff2.', default='gaff', choices=['gaff','gaff2'])
parser.add_argument('-lf', dest='ligforce', help='Ligand forcefield: gaff or gaff2.', default='gaff', choices=['gaff','gaff2'])
parser.add_argument('-bt', dest='boxtype', help='Simulation box type, default: triclinic', default='triclinic')
parser.add_argument('-box', help='Simulation box size.', nargs=3, type=float, default=None)
parser.add_argument('-d', help='Distance between the solute and the box.', default=0.9, type=float)
parser.add_argument('-conc', help='Specify salt concentration (mol/liter). default=0.15', default=0.15, type=float)
parser.add_argument('-o', dest='outdir', help='A output directory.', default=None)
parser.add_argument('-o', dest='outdir', help='The output directory.', default=None)
parser.add_argument('-nsteps', dest='nstep', help='Simulation steps. default:2500', default=2500, type=int)
parser.add_argument('-nframe', dest='nframe', help='Number of frame to save for the xtc file. default:100', default=100, type=int)
parser.add_argument('-nt', dest='thread', help='Number of thread to run this simulation.', default=4)
parser.add_argument('-nframe', dest='nframe', help='Number of frames to save for the xtc file. default:100', default=100, type=int)
parser.add_argument('-nt', dest='threads', help='Number of threads to run this simulation.', default=4)
parser.add_argument('-verbose', help='Keep all the files in the simulation.', action='store_true', default=False)
parser.add_argument('-v', '--version', action='version', version="{prog}s ({version})".format(prog="%(prog)", version=__version__))

args = parser.parse_args()
proteinfile, ligand, outdir = args.protein, args.ligand, args.outdir
proteinForcefield, ligandForcefield = args.protforce, args.ligforce
boxtype, box, conc, boxsize, nsteps, nframe, nt = args.boxtype, args.box, args.conc, args.d, args.nstep, args.nframe, args.thread
boxtype, box, conc, boxsize, nsteps, nframe, nt = args.boxtype, args.box, args.conc, args.d, args.nstep, args.nframe, args.threads
verbose = args.verbose
if box:
boxsize = box
Expand Down Expand Up @@ -239,14 +239,14 @@ def simulation_run():

def traj_pipeline(args=None):
from unigbsa.gbsa.gbsarun import GBSA
parser = argparse.ArgumentParser(description='Free energy calcaulated by PBSA method.')
parser = argparse.ArgumentParser(description='Free energy calcaulation by MM/GB(PB)SA method.')
parser.add_argument('-i', dest='INP', help='A pdb file or a tpr file for the trajectory.', required=True)
parser.add_argument('-p', dest='TOP', help='Gromacs topol file for the system.', required=True)
parser.add_argument('-ndx', dest='ndx', help='Gromacs index file, must contain recepror and ligand group.', required=True)
parser.add_argument('-m', dest='mode', help='MMPBSA mode', nargs='+', default=['GB'])
parser.add_argument('-f', dest='mmpbsafile', help='Input mmpbsa file', default=None)
parser.add_argument('-t', dest='TRAJ', help='A trajectory file contains many structure frames. File format: xtc, pdb, gro...', default=None)
parser.add_argument('-nt', dest='thread', help='Set number of thread to run this program.', type=int, default=1)
parser.add_argument('-ndx', dest='ndx', help='Gromacs index file, must contain receptor and ligand group.', required=True)
parser.add_argument('-m', dest='mode', help='MM/GB(PB)SA mode', nargs='+', default=['GB'])
parser.add_argument('-f', dest='mmpbsafile', help='Input MM/GB(PB)SA file', default=None)
parser.add_argument('-t', dest='TRAJ', help='A trajectory file containing many structure frames. File format: xtc, pdb, gro...', default=None)
parser.add_argument('-nt', dest='threads', help='Set number of threads to run this program.', type=int, default=1)
parser.add_argument('-D', dest='DEBUG', help='DEBUG model, keep all the files.', default=False, action='store_true')
parser.add_argument('-v', '--version', action='version', version="{prog}s ({version})".format(prog="%(prog)", version=__version__))

Expand All @@ -255,7 +255,7 @@ def traj_pipeline(args=None):
else:
args = parser.parse_args(args)
#exit(0)
complexFile, topolFile, indexFile, trajFile, debug, mmpbsafile, nt = args.INP, args.TOP, args.ndx, args.TRAJ, args.DEBUG, args.mmpbsafile, args.thread
complexFile, topolFile, indexFile, trajFile, debug, mmpbsafile, nt = args.INP, args.TOP, args.ndx, args.TRAJ, args.DEBUG, args.mmpbsafile, args.threads
if trajFile is None:
trajFile = complexFile
if mmpbsafile:
Expand All @@ -272,9 +272,9 @@ def traj_pipeline(args=None):

def mmpbsa_plot():
from unigbsa.gbsa import plots
parser = argparse.ArgumentParser(description='Analysis and plot results for MMPBSA.')
parser.add_argument('-i', help='MMPBSA result directory. Which contains FINAL_RESULTS_MMPBSA.dat, FINAL_DECOMP_MMPBSA.dat, EO.csv or DEO.csv file.', required=True)
parser.add_argument('-o', help='Figure output directory. default: analysis', default='analysis')
parser = argparse.ArgumentParser(description='Analyze and plot results for MM/GB(PB)SA.')
parser.add_argument('-i', help='MM/GB(PB)SA results directory. Should contain FINAL_RESULTS_MMPBSA.dat, FINAL_DECOMP_MMPBSA.dat, EO.csv or DEO.csv file.', required=True)
parser.add_argument('-o', help='Output directory for the Figures. default: analysis', default='analysis')
parser.add_argument('-v', '--version', action='version', version="{prog}s ({version})".format(prog="%(prog)", version=__version__))


Expand All @@ -296,7 +296,7 @@ def mmpbsa_plot():


def ligand_check():
parser = argparse.ArgumentParser(description='Analysis and plot results for MMPBSA.')
parser = argparse.ArgumentParser(description='Validate and check an input ligand')
parser.add_argument('-i', help='Ligand file to validate.', required=True)
parser.add_argument('-o', help='Ligand file after validate. default: None', default=None)
parser.add_argument('-v', '--version', action='version', version="{prog}s ({version})".format(prog="%(prog)", version=__version__))
Expand Down
Loading

0 comments on commit 207a777

Please sign in to comment.