diff --git a/.github/workflows/publish_to_pypi.yml b/.github/workflows/publish_to_pypi.yml new file mode 100644 index 0000000..4495f7f --- /dev/null +++ b/.github/workflows/publish_to_pypi.yml @@ -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 }} \ No newline at end of file diff --git a/README.md b/README.md index d520f04..ac15de1 100644 --- a/README.md +++ b/README.md @@ -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/). diff --git a/alvadescpy/__init__.py b/alvadescpy/__init__.py index da6901c..5044a72 100644 --- a/alvadescpy/__init__.py +++ b/alvadescpy/__init__.py @@ -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') diff --git a/alvadescpy/__pycache__/__init__.cpython-35.pyc b/alvadescpy/__pycache__/__init__.cpython-35.pyc deleted file mode 100644 index 9ce7136..0000000 Binary files a/alvadescpy/__pycache__/__init__.cpython-35.pyc and /dev/null differ diff --git a/alvadescpy/__pycache__/functions.cpython-35.pyc b/alvadescpy/__pycache__/functions.cpython-35.pyc deleted file mode 100644 index c7f34c1..0000000 Binary files a/alvadescpy/__pycache__/functions.cpython-35.pyc and /dev/null differ diff --git a/alvadescpy/__pycache__/wrapper.cpython-35.pyc b/alvadescpy/__pycache__/wrapper.cpython-35.pyc deleted file mode 100644 index be6ebba..0000000 Binary files a/alvadescpy/__pycache__/wrapper.cpython-35.pyc and /dev/null differ diff --git a/alvadescpy/functions.py b/alvadescpy/functions.py index e5e3332..aa8ccbb 100644 --- a/alvadescpy/functions.py +++ b/alvadescpy/functions.py @@ -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) @@ -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] diff --git a/alvadescpy/wrapper.py b/alvadescpy/wrapper.py index 6c12f88..d837d41 100644 --- a/alvadescpy/wrapper.py +++ b/alvadescpy/wrapper.py @@ -9,11 +9,9 @@ # # 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 = { @@ -21,16 +19,18 @@ } 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: @@ -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 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..aa12a29 --- /dev/null +++ b/pyproject.toml @@ -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="travis.j.kessler@gmail.com" }, +] +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" \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 6898ca7..0000000 --- a/setup.py +++ /dev/null @@ -1,14 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name='alvadescpy', - version='0.1.2', - description='Python wrapper for alvaDesc software', - url='http://github.com/tjkessler/ecnet', - author='Travis Kessler', - author_email='travis.j.kessler@gmail.com,', - license='MIT', - packages=['alvadescpy'], - install_requires=[], - zip_safe=False -) diff --git a/tests/test.py b/tests/test.py deleted file mode 100644 index 37fb7d6..0000000 --- a/tests/test.py +++ /dev/null @@ -1,9 +0,0 @@ -from alvadescpy import smiles_to_descriptors - - -if __name__ == '__main__': - - print(smiles_to_descriptors('CCCOC', descriptors=['MW', 'AMW'], labels=True)) - res = smiles_to_descriptors(['CCCC', 'CCOCC', 'CCCCC'], descriptors='ALL', labels=True) - print(len(res)) - print(len(res[0]))