Skip to content

Commit

Permalink
Merge pull request #54 from alanwilter/failing_cases new_release
Browse files Browse the repository at this point in the history
Prepared for different user's scenarios
  • Loading branch information
alanwilter authored Nov 29, 2021
2 parents d248f1e + 69302b0 commit 9c45d7e
Show file tree
Hide file tree
Showing 15 changed files with 334 additions and 162 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ RUN apt-get update && apt-get install -y \
python3-openbabel \
libgfortran5 \
libarpack++2-dev \
python3-ipython \
&& apt-get autoremove -y && apt-get autoclean -y && apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

COPY run_acpype.py /home
COPY acpype_lib /home/acpype_lib
RUN ln -s /home/run_acpype.py /usr/local/bin/acpype
RUN ln -s /home/run_acpype.py /usr/local/bin/acpype
ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/amber21/bin"
77 changes: 46 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# ACPYPE

![GitHub](https://img.shields.io/github/license/alanwilter/acpype?style=social)
![GitHub All Releases](https://img.shields.io/github/downloads/alanwilter/acpype/total?style=social)
![Docker Pulls](https://img.shields.io/docker/pulls/acpype/acpype?style=social&logo=docker)
![Docker Image Size (tag)](https://img.shields.io/docker/image-size/lpkagami/acpype/latest?style=social&logo=docker)
![GitHub Relase](https://img.shields.io/github/release-date/alanwilter/acpype?style=social)
![Conda Version](https://img.shields.io/conda/vn/conda-forge/acpype.svg)
![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/acpype.svg)
![GitHub](https://img.shields.io/github/license/alanwilter/acpype?style=plastic)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/alanwilter/acpype?display_name=tag&logo=github&style=plastic)
![GitHub Relase](https://img.shields.io/github/release-date/alanwilter/acpype?style=plastic&logo=github)<!-- ![GitHub All Releases](https://img.shields.io/github/downloads/alanwilter/acpype/total?style=plastic) -->
![Docker Pulls](https://img.shields.io/docker/pulls/acpype/acpype?style=plastic&logo=docker)
![Docker Image Size (tag)](https://img.shields.io/docker/image-size/acpype/acpype/latest?style=plastic&logo=docker)
![Conda Version](https://img.shields.io/conda/vn/conda-forge/acpype.svg?style=plastic&logo=conda-forge)
![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/acpype.svg?style=plastic&logo=conda-forge)<!-- ![Conda](https://img.shields.io/conda/pn/conda-forge/acpype?logo=conda-forge&style=plastic) -->
![PyPI](https://img.shields.io/pypi/v/acpype?style=plastic&logo=pypi)
![PyPI - Downloads](https://img.shields.io/pypi/dm/acpype?style=plastic&logo=pypi)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/alanwilter/acpype/check_acpype)
<!-- ![Scrutinizer code quality (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/quality/g/alanwilter/acpype) -->
<!-- ![Scrutinizer coverage (GitHub/BitBucket)](https://img.shields.io/scrutinizer/coverage/g/alanwilter/acpype) -->

## AnteChamber PYthon Parser interfacE

Expand Down Expand Up @@ -87,21 +92,33 @@ There are several ways of obtaining `acpype`:

1. Via **[CONDA](https://anaconda.org/search?q=acpype)**:

*(It should be wholesome, fully funcional, all batteries included)*

```bash
conda install -c conda-forge acpype
```

2. Via **[PyPI](https://pypi.org/project/acpype/)**:

*(Make sure you have `AmberTools` and, optionally but highly recommended, `OpenBabel` )*

```bash
# You can use conda to get the needed 3rd parties for example
conda create -n acpype --channel conda-forge ambertools openbabel

pip install acpype

# or if you feel daring

pip install git+https://github.com/alanwilter/acpype.git
```

note that `pip install acpype`, unfortunately, is not *yet* picking the original one.

3. By downloading it via `git`:

*(Make sure you have `AmberTools` and, optionally but highly recommended, `OpenBabel` )*

```bash
# You can use conda to get the needed 3rd parties for example
conda create -n acpype --channel conda-forge ambertools openbabel
git clone https://github.com/alanwilter/acpype.git
```
Expand All @@ -110,39 +127,37 @@ There are several ways of obtaining `acpype`:

4. Via **[Docker](https://hub.docker.com/repository/docker/acpype/acpype/)**:

If you have Docker installed, you can run `acpype` by:

```bash
docker pull acpype/acpype:latest
```
*(It should be wholesome, fully funcional, all batteries included)*

If you have Docker installed, you can run `acpype_docker.sh` by:

Then, on Linux / MacOS choose a folder where to work (e.g. contains your PDB, MOL2 or inpcrd/prmtop files) and do:
NOTE: first time may take some time as it pulls the `acpype` docker image.

On Linux / MacOS:

```bash

# it opens a terminal inside docker with access to your working folder
docker run -i -t --rm -v ${PWD}:/wdir -w /wdir acpype/acpype bash

# use acpype
acpype -i CCCC
acpype -i DDD.pdb -c gas # if you have a DDD.pdb file there in "wdir" ($PWD)
exit # and your output files will be at your working directory ($PWD)
ln -fsv "$PWD/acpype_docker.sh" /usr/local/bin/acpype_docker

```

On Windows:
Using Command Prompt:

In the directory where the `acpype_docker.bat` file is found:

```bash
docker run -i -t --rm -v%cd%:/wdir -w /wdir acpype bash
setx /M path "%path%;%cd%"
```

Using PowerShell:

Commands:
```bash
docker run -i -t --rm -v ${PWD}:/wdir -w /wdir acpype bash
acpype_docker -i CCCC

acpype_docker -i tests/DDD.pdb -c gas
```
**NB:**

**NB:** Installing via `conda` or via `pip/git` you get `AmberTools v.21.11` and `OpenBabel v3.11`. Our `AmberTools v.21.11` comes with binary `charmmgen` from `AmberTools17` in order to generate CHARMM topologies.
- By installing via `conda` or using via `docker` you get `AmberTools v.21.11` and `OpenBabel v3.1.1`. Our `AmberTools v.21.11` comes with binary `charmmgen` from `AmberTools17` in order to generate CHARMM topologies.
- By installing via `pip` you get `AmberTools` (as described above) embeded. However, the included binaries may not work in your system (library dependecies issues) and with only provide binaries for Linux (Ubuntu20) and Mac OSX.

##### To Test, if doing via `git`

Expand Down Expand Up @@ -174,7 +189,7 @@ To get help and more information, type:
At folder `acpype/`, type:

```bash
ln -s $PWD/run_acpype.py /usr/local/bin/acpype
ln -fsv "$PWD/run_acpype.py" /usr/local/bin/acpype
```

Then re-login or start another shell session.
Expand Down Expand Up @@ -241,4 +256,4 @@ cns < FFF_CNS.inp

#### To Verify with NAMD

- see [TutorialNAMD]
- see [TutorialNAMD](../../wiki/Tutorial-NAMD)
2 changes: 2 additions & 0 deletions acpype_docker.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo on
docker run -i -t -v %cd%:/wdir -w /wdir acpype/acpype acpype %*
3 changes: 3 additions & 0 deletions acpype_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

docker run -i -t -v "${PWD}":/wdir -w /wdir acpype/acpype acpype "$@"
3 changes: 2 additions & 1 deletion acpype_lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# from https://packaging.python.org/guides/single-sourcing-package-version/
# using option 2
__version__ = "2021.11.27"
# updated automatically via pre-commit git-hook
__version__ = "2021.11.29"
50 changes: 29 additions & 21 deletions acpype_lib/acpype.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,43 @@
import time
import os
import sys
import sysconfig
from shutil import rmtree, which
from acpype_lib.topol import MolTopol, ACTopol, header
from acpype_lib.parser_args import get_option_parser
from acpype_lib.utils import while_replace
from acpype_lib.utils import checkSmiles, elapsedTime
from acpype_lib.utils import while_replace, elapsedTime
from acpype_lib.params import binaries

# For pip package
if which("antechamber") is None:
LOCAL_PATH = sysconfig.get_paths()["purelib"]
if sys.platform == "linux":
os.environ["PATH"] += os.pathsep + LOCAL_PATH + "/amber21-11_linux/bin:" + LOCAL_PATH + "/amber21-11_linux/dat/"
os.environ["AMBERHOME"] = LOCAL_PATH + "/amber21-11_linux/"
os.environ["ACHOME"] = LOCAL_PATH + "/amber21-11_linux/bin/"
os.environ["LD_LIBRARY_PATH"] = LOCAL_PATH + "/amber21-11_linux/lib/"
elif sys.platform == "darwin":
os.environ["PATH"] += os.pathsep + LOCAL_PATH + "/amber21-11_os/bin:" + LOCAL_PATH + "/amber21-11_os/dat/"
os.environ["AMBERHOME"] = LOCAL_PATH + "/amber21-11_os/"
os.environ["ACHOME"] = LOCAL_PATH + "/amber21-11_os/bin/"
os.environ["LD_LIBRARY_PATH"] = LOCAL_PATH + "/amber21-11_os/lib/"

if sys.version_info < (3, 6):
raise Exception("Sorry, you need python 3.6 or higher")
def set_for_pip():
# For pip package
if which(binaries["ac_bin"]) is None:
try:
LOCAL_PATH = os.path.dirname(os.path.dirname(__file__))
if sys.platform == "linux":
os.environ["PATH"] += os.pathsep + LOCAL_PATH + "/amber21-11_linux/bin"
os.environ["AMBERHOME"] = LOCAL_PATH + "/amber21-11_linux/"
os.environ["LD_LIBRARY_PATH"] = LOCAL_PATH + "/amber21-11_linux/lib/"
elif sys.platform == "darwin":
os.environ["PATH"] += os.pathsep + LOCAL_PATH + "/amber21-11_os/bin"
os.environ["AMBERHOME"] = LOCAL_PATH + "/amber21-11_os/"
os.environ["LD_LIBRARY_PATH"] = LOCAL_PATH + "/amber21-11_os/lib/"
os.environ["DYLD_LIBRARY_PATH"] = LOCAL_PATH + "/amber21-11_os/lib/"
except Exception:
print("ERROR: AmberTools NOT FOUND")


def init_main(argv=None):
def chk_py_ver():
if sys.version_info < (3, 6):
raise Exception("Sorry, you need python 3.6 or higher")


def init_main(binaries=binaries, argv=None):

"""
Main function, to satisfy Conda
"""
chk_py_ver()
set_for_pip()
if argv is None:
argv = sys.argv[1:]

Expand Down Expand Up @@ -141,6 +148,7 @@ def init_main(argv=None):
else:
molecule = ACTopol(
args.input,
binaries=binaries,
chargeType=args.charge_method,
chargeVal=args.net_charge,
debug=args.debug,
Expand Down Expand Up @@ -196,8 +204,8 @@ def init_main(argv=None):
except Exception:
pass

if not amb2gmxF and molecule.babelExe:
if checkSmiles(args.input):
if not amb2gmxF and molecule.obabelExe:
if molecule.checkSmiles():
afile = "smiles_molecule.mol2"
if os.path.exists(afile):
os.remove(afile)
Expand Down
2 changes: 2 additions & 0 deletions acpype_lib/params.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
binaries = {"ac_bin": "antechamber", "obabel_bin": "obabel"}

MAXTIME = 3 * 3600
cal = 4.184
Pi = 3.141593
Expand Down
1 change: 1 addition & 0 deletions acpype_lib/parser_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


def get_option_parser():
# not used yet: -e -l -r
parser = argparse.ArgumentParser(usage=usage + epilog)
group = parser.add_mutually_exclusive_group()
parser.add_argument(
Expand Down
Loading

0 comments on commit 9c45d7e

Please sign in to comment.