ACPYPE

From Alliance Doc
Jump to navigation Jump to search


This article is a draft

This is not a complete article: This is a draft, a work in progress that is intended to be published into an article, which may or may not be ready for inclusion in the main wiki. It should not necessarily be considered factual or authoritative.




General

ACPYPE: AnteChamber PYthon Parser interfacE (pronounced as ace + pipe), is a tool written in Python to use Antechamber to generate topologies for chemical compounds and to interface with others python applications like CCPN and ARIA.

It will generate topologies for CNS/XPLOR, GROMACS, CHARMM and AMBER, that are based on General Amber Force Field (GAFF) and should be used only with compatible forcefields like AMBER and its variants.

We provide Python wheels for ACPYPE for StdEnv/2020 and StdEnv/2023 in our wheelhouse that you should install into a virtual environment.

Please note that you need to load the openbabel module before installing ACPYPE and anytime you want to use it.

Creating a virtual environment for ACPYPE

[user@login1]$ module load  python  openbabel
[user@login1]$ virtualenv ~/venv_acpype
[user@login1]$ source ~/venv_acpype/bin/activate
[user@login1]$ pip install --no-index acpype


Now the acpype command can be used:

(venv_acpype) [user@login1]$  acpype --help
usage: 
    acpype -i _file_ | _SMILES_string_ [-c _string_] [-n _int_] [-m _int_] [-a _string_] [-f] etc. or
    acpype -p _prmtop_ -x _inpcrd_ [-d | -w]

    output: assuming 'root' is the basename of either the top input file,
            the 3-letter residue name or user defined (-b option)
    root_bcc_gaff.mol2:  final mol2 file with 'bcc' charges and 'gaff' atom type
    root_AC.inpcrd    :  coord file for AMBER
    root_AC.prmtop    :  topology and parameter file for AMBER
    root_AC.lib       :  residue library file for AMBER
    root_AC.frcmod    :  modified force field parameters
    root_GMX.gro      :  coord file for GROMACS
    root_GMX.top      :  topology file for GROMACS
    root_GMX.itp      :  molecule unit topology and parameter file for GROMACS
    root_GMX_OPLS.itp :  OPLS/AA mol unit topol & par file for GROMACS (experimental!)
    em.mdp, md.mdp    :  run parameters file for GROMACS
    root_NEW.pdb      :  final pdb file generated by ACPYPE
    root_CNS.top      :  topology file for CNS/XPLOR
    root_CNS.par      :  parameter file for CNS/XPLOR
    root_CNS.inp      :  run parameters file for CNS/XPLOR
    root_CHARMM.rtf   :  topology file for CHARMM
    root_CHARMM.prm   :  parameter file for CHARMM
    root_CHARMM.inp   :  run parameters file for CHARMM

options:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        input file type like '.pdb', '.mdl', '.mol2' or SMILES string (mandatory if -p and -x not set)
  -b BASENAME, --basename BASENAME
                        a basename for the project (folder and output files)
  -x INPCRD, --inpcrd INPCRD
                        amber inpcrd file name (always used with -p)
  -p PRMTOP, --prmtop PRMTOP
                        amber prmtop file name (always used with -x)
  -c {gas,bcc,user}, --charge_method {gas,bcc,user}
                        charge method: gas, bcc (default), user (users charges in mol2 file)
  -n NET_CHARGE, --net_charge NET_CHARGE
                        net molecular charge (int), it tries to guess it if not not declared
  -m MULTIPLICITY, --multiplicity MULTIPLICITY
                        multiplicity (2S+1), default is 1
  -a {gaff,amber,gaff2,amber2}, --atom_type {gaff,amber,gaff2,amber2}
                        atom type, can be gaff, gaff2 (default), amber (AMBER14SB) or amber2 (AMBER14SB + GAFF2)
  -q {mopac,sqm,divcon}, --qprog {mopac,sqm,divcon}
                        am1-bcc flag, sqm (default), divcon, mopac
  -k KEYWORD, --keyword KEYWORD
                        mopac or sqm keyword, inside quotes
  -f, --force           force topologies recalculation anew
  -d, --debug           for debugging purposes, keep any temporary file created (not allowed with arg -w)
  -w, --verboseless     print nothing (not allowed with arg -d)
  -o {all,gmx,cns,charmm}, --outtop {all,gmx,cns,charmm}
                        output topologies: all (default), gmx, cns or charmm
  -z, --gmx4            write RB dihedrals old GMX 4.0
  -t, --cnstop          write CNS topology with allhdg-like parameters (experimental)
  -s MAX_TIME, --max_time MAX_TIME
                        max time (in sec) tolerance for sqm/mopac, default is 3 hours
  -y, --ipython         start iPython interpreter
  -g, --merge           Merge lower and uppercase atomtypes in GMX top file if identical parameters
  -u, --direct          for 'amb2gmx' mode, does a direct conversion, for any solvent (EXPERIMENTAL)
  -l, --sorted          sort atoms for GMX ordering
  -j, --chiral          create improper dihedral parameters for chiral atoms in CNS
  -v, --version         Show the Acpype version and exit

Using ACPYPE

Running as a non-interactive job

You can run ACPYPE as a short job with a job script similar to the one shown below.

If you have already a file with the 3D-coordinates of your molecule, you can delete the lines that use obabel to generate the file adp.mol2 from the SMILES string.


File : job_acpype_ADP.sh

#!/bin/bash
#SBATCH --time=00:15:00
#SBATCH --cpus-per-task=4
#SBATCH --mem-per-cpu=2000M

module load python  openbabel
source ~/venv_acpype/bin/activate

export OMP_NUM_THREADS="${SLURM_CPUS_PER_TASK:-1}"

# generate "adp.mol2" file from SMILES string:
obabel  -:"c1nc(c2c(n1)n(cn2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)O)O)O)N" \
    -i smi -o mol2 -O adp.mol2 -h  --gen3d

acpype -i adp.mol2


Running on a login node

As apart of the topology generation, ACPYPE will run a short QM calculation to optimize the structure and determine the partial charges. For small molecules this should take less than two minutes and can therefore be done on a login-node, however in this case the number of threads should be limited by running ACPYPE with: OMP_NUM_THREADS=2 acpype ....

For larger molecules or generating topologies for several molecules you should submit a job as shown above.

First the python and openbabel need to be loaded. We also download a structure file of Adenosine triphosphate (ATP) from PubChem:

[user@login1]$ module load  python  openbabel
[user@login1]$ source ~/venv_acpype/bin/activate
[user@login1]$ 
# download a test file for ATP:
[user@login1]$ wget "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/CID/5957/record/SDF?record_type=3d&response_type=save&response_basename=ATP" -O atp.sdf


We run ACPYPE, restricting it to using a maximum of two threads:

(venv_acpype) [user@login1]$  OMP_NUM_THREADS=2 acpype -i atp.sdf
============================================================================
| ACPYPE: AnteChamber PYthon Parser interfacE v. 2023.10.27 (c) 2025 AWSdS |
============================================================================
WARNING: no charge value given, trying to guess one...
==> ... charge set to 0
==> Executing Antechamber...
==> * Antechamber OK *
==> * Parmchk OK *
==> Executing Tleap...
==> * Tleap OK *
[...]
==> Removing temporary files...
Total time of execution: 1m 32s

The directory atp.acpype is created

[name@server ~]$  ls atp.acpype/
acpype.log                 ANTECHAMBER_PREP.AC0  atp_CHARMM.prm    atp_GMX_OPLS.top  posre_atp.itp
ANTECHAMBER_AC.AC          ATOMTYPE.INF          atp_CHARMM.rtf    atp_GMX.top       rungmx.sh
ANTECHAMBER_AC.AC0         atp_AC.frcmod         atp_CNS.inp       atp_NEW.pdb       sqm.in
ANTECHAMBER_AM1BCC.AC      atp_AC.inpcrd         atp_CNS.par       atp.pkl           sqm.out
ANTECHAMBER_AM1BCC_PRE.AC  atp_AC.lib            atp_CNS.top       atp.sdf           sqm.pdb
ANTECHAMBER_BOND_TYPE.AC   atp_AC.prmtop         atp_GMX.gro       em.mdp
ANTECHAMBER_BOND_TYPE.AC0  atp_bcc_gaff2.mol2    atp_GMX.itp       leap.log
ANTECHAMBER_PREP.AC        atp_CHARMM.inp        atp_GMX_OPLS.itp  md.mdp

Useful Links