Skip to content

Commit

Permalink
Merge pull request #1 from ecrl/dev
Browse files Browse the repository at this point in the history
0.1.3
  • Loading branch information
tjkessler authored Aug 2, 2023
2 parents bda4ad9 + 47a6102 commit 5b6e0f0
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 43 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Upload new alvaDescPy version to PyPI

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Installation via cloned repository:
```
$ git clone https://github.com/ecrl/alvadescpy
$ cd alvadescpy
$ python setup.py install
$ pip install .
```

There are currently no additional dependencies for alvaDescPy, however it requires a valid, licensed installation of [alvaDesc](https://www.alvascience.com/alvadesc/).
Expand Down
3 changes: 2 additions & 1 deletion alvadescpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from alvadescpy.wrapper import alvadesc
from alvadescpy.functions import smiles_to_descriptors
from alvadescpy.wrapper import CONFIG
__version__ = '0.1.2'
import pkg_resources
__version__ = pkg_resources.get_distribution('alvadescpy')
Binary file removed alvadescpy/__pycache__/__init__.cpython-35.pyc
Binary file not shown.
Binary file removed alvadescpy/__pycache__/functions.cpython-35.pyc
Binary file not shown.
Binary file removed alvadescpy/__pycache__/wrapper.cpython-35.pyc
Binary file not shown.
15 changes: 9 additions & 6 deletions alvadescpy/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
from alvadescpy import alvadesc

# custom argument and return variables
_DESC = TypeVar('_DESC', str, list)
_RET_VAL = TypeVar('_RET_VAL', dict, list)
str_or_list = TypeVar('str_or_list', str, list)
list_or_dict = TypeVar('list_or_dict', dict, list)


def smiles_to_descriptors(smiles: str, descriptors: _DESC='ALL',
labels: bool=True) -> _RET_VAL:
def smiles_to_descriptors(smiles: str_or_list,
descriptors: str_or_list = 'ALL',
labels: bool = True) -> list_or_dict:
''' smiles_to_descriptors: returns molecular descriptors for a given
molecule (represented by its SMILES string)
Expand All @@ -37,6 +38,8 @@ def smiles_to_descriptors(smiles: str, descriptors: _DESC='ALL',
'''

if type(smiles) == list:
return [alvadesc(ismiles=smi, descriptors=descriptors, labels=labels)[0]
for smi in smiles]
return [
alvadesc(ismiles=smi, descriptors=descriptors, labels=labels)[0]
for smi in smiles
]
return alvadesc(ismiles=smiles, descriptors=descriptors, labels=labels)[0]
27 changes: 15 additions & 12 deletions alvadescpy/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@
#

# stdlib. imports
from subprocess import check_output, PIPE, Popen, call
from csv import writer, QUOTE_ALL
from subprocess import PIPE, Popen
from typing import TypeVar
import platform
from os.path import realpath

# path to alvaDesc command line interface executable
CONFIG = {
'alvadesc_path': None
}
plt = platform.system()
if plt == 'Windows':
CONFIG['alvadesc_path'] = 'C:\\Program Files\\Alvascience\\alvaDesc\\alvaDescCLI.exe'
CONFIG['alvadesc_path'] = 'C:\\Program Files\\Alvascience\\alvaDesc\\\
alvaDescCLI.exe'
elif plt == 'Darwin':
CONFIG['alvadesc_path'] = '/Applications/alvaDesc.app/Contents/MacOS/alvaDescCLI'
CONFIG['alvadesc_path'] = '/Applications/alvaDesc.app/Contents/MacOS/\
alvaDescCLI'
elif plt == 'Linux':
CONFIG['alvadesc_path'] = '/usr/bin/alvaDescCLI'
else:
raise RuntimeError('Unknown/unsupported operating system: {}'.format(plt))

# custom argument variable (either str or list)
_DESC = TypeVar('_DESC', str, list)
str_or_list = TypeVar('str_or_list', str, list)


def _sub_call(command: str) -> list:
Expand All @@ -54,12 +54,15 @@ def _sub_call(command: str) -> list:
return p.communicate()[0].decode('utf-8')


def alvadesc(script: str=None, ismiles: str=None, input_file: str=None,
inputtype: str=None, descriptors: _DESC=None, labels: bool=False,
ecfp: bool=False, pfp: bool=False, fpsize: int=1024, fpmin: int=0,
fpmax: int=2, count: bool=True, bits: int=2, fpoptions: str=None,
maccsfp: bool=False, output: str=None, threads: int=None) -> list:
''' alvadesc: calls alvaDesc's command line interface; supports all arguments
def alvadesc(script: str = None, ismiles: str = None, input_file: str = None,
inputtype: str = None, descriptors: str_or_list = None,
labels: bool = False, ecfp: bool = False, pfp: bool = False,
fpsize: int = 1024, fpmin: int = 0, fpmax: int = 2,
count: bool = True, bits: int = 2, fpoptions: str = None,
maccsfp: bool = False, output: str = None,
threads: int = None) -> list:
''' alvadesc: calls alvaDesc's command line interface; supports all
arguments
Args:
script (str): path to script file containing all available options; if
Expand Down
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "alvadescpy"
version = "0.1.3"
authors = [
{ name="Travis Kessler", email="[email protected]" },
]
description = "Python wrapper for alvaDesc software"
readme = "README.md"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]

[project.urls]
"Homepage" = "https://github.com/ecrl/alvadescpy"
"Bug Tracker" = "https://github.com/ecrl/alvadescpy/issues"
14 changes: 0 additions & 14 deletions setup.py

This file was deleted.

9 changes: 0 additions & 9 deletions tests/test.py

This file was deleted.

0 comments on commit 5b6e0f0

Please sign in to comment.