Skip to content

Commit

Permalink
update project to zpdb-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomcteixeira committed Oct 23, 2024
1 parent e4368bc commit fb32d54
Show file tree
Hide file tree
Showing 54 changed files with 291 additions and 1,629 deletions.
6 changes: 4 additions & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[bumpversion]
current_version = 2.5.1
commit = True
message = [SKIP] version bump {current_version} -> {new_version}
message = version bump {current_version} -> {new_version}
tag = True

[bumpversion:file:setup.py]
[bumpversion:file:pyproject.toml]
search = version = "{current_version}"
replace = version = "{new_version}"
2 changes: 1 addition & 1 deletion .github/workflows/yaml_linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
lintAllTheThings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: yaml-lint
uses: ibiqlik/action-yamllint@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dist/
*egg-info/
*__pycache__
*.pyc
.coverage
2 changes: 1 addition & 1 deletion pdbtools/pdb_delinsertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import sys
import warnings

from pdbtools import pdb_fixinsert
from zpdbtools import pdb_fixinsert

__author__ = "Joao Rodrigues"
__email__ = "j.p.g.l.m.rodrigues@gmail.com"
Expand Down
55 changes: 55 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[project]
name = "zpdb-tools"
readme = "README.md"
description='A swiss army knife for PDB files.'
requires-python = ">=3.7"
version = "2.5.1"
dynamic = ["scripts"]
keywords = [
"zymvol",
"bioinformatics",
"proteins",
"pdb",
"structural-biology",
]
classifiers = [
'Development Status :: 5 - Production/Stable',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Chemistry',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'License :: OSI Approved :: Apache Software License',
]
authors = [
{name = "João Rodrigues", email = "j.p.g.l.m.rodrigues@gmail.com" },
{name = "João M.C. Teixeira", email = "joaomcteixeira@gmail.com" },
{name = "Haddocking", email = "a.m.j.j.bonvin@uu.nl" },
]

maintainers = [
{name = "João M.C. Teixeira", email = "jteixeira@zymvol.com" },
{name = "Zymvol Biomodeling"},
]

[project.urls]
Repository = "https://github.com/zymvol/zpdb-tools"
Issues = "https://github.com/zymvol/zpdb-tools/issues"

[build-system]
requires = [
"setuptools >= 75",
]
build-backend = "setuptools.build_meta"

#[tool.setuptools.packages.find]
#where = ["zpdbtools"]
[tool.setuptools.package-dir]
zpdbtools = "pdbtools"
113 changes: 10 additions & 103 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,108 +1,15 @@
"""A setuptools based setup module.
from pathlib import Path

See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
"""
from setuptools import setup

# Always prefer setuptools over distutils
from setuptools import setup, find_packages
from os import listdir, path
# io.open is needed for projects that support Python 2.7
# It ensures open() defaults to text mode with universal newlines,
# and accepts an argument to specify the text encoding
# Python 3 only projects can skip this import
from io import open

here = path.abspath(path.dirname(__file__))

# Get the long description from the README file
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()

# Collect names of bin/*py scripts
# e.g. 'pdb_intersect=bin.pdb_intersect:main',
binfiles = listdir(path.join(here, 'pdbtools'))
bin_py = [f[:-3] + '=pdbtools.' + f[:-3] + ':main' for f in binfiles
if f.endswith('.py')]
binfiles = Path(Path(__file__).parent, 'pdbtools').resolve().glob('*.py')
bin_py = [
f.stem + '=zpdbtools.' + f.stem + ':main'
for f in binfiles
]

setup(
name='pdb-tools', # Required
version='2.5.1', # Required
description='A swiss army knife for PDB files.', # Optional
long_description=long_description, # Optional
long_description_content_type='text/markdown', # Optional (see note above)
url='http://bonvinlab.org/pdb-tools', # Optional
author='Joao Rodrigues', # Optional
author_email='j.p.g.l.m.rodrigues@gmail.com', # Optional
license='Apache Software License, version 2',
classifiers=[ # Optional
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 5 - Production/Stable',
#'Development Status :: 4 - Beta',

# Indicate who your project is intended for
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Chemistry',
'Topic :: Scientific/Engineering :: Bio-Informatics',


# Pick your license as you wish
'License :: OSI Approved :: Apache Software License',

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],

keywords='bioinformatics protein structural-biology pdb', # Optional

# You can just specify package directories manually here if your project is
# simple. Or you can use find_packages().
#
# Alternatively, if you just want to distribute a single Python file, use
# the `py_modules` argument instead as follows, which will expect a file
# called `my_module.py` to exist:
#
# py_modules=["my_module"],
#
packages=find_packages(), # Required

# To provide executable scripts, use entry points in preference to the
# "scripts" keyword. Entry points provide cross-platform support and allow
# `pip` to create the appropriate form of executable for the target
# platform.
#
# For example, the following would provide a command called `sample` which
# executes the function `main` from this package when invoked:
entry_points={ # Optional
entry_points={
'console_scripts': bin_py,
},

# scripts=[path.join('bin', f) for f in listdir(path.join(here, 'bin'))],

# List additional URLs that are relevant to your project as a dict.
#
# This field corresponds to the "Project-URL" metadata fields:
# https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use
#
# Examples listed include a pattern for specifying where the package tracks
# issues, where the source is hosted, where to say thanks to the package
# maintainers, and where to support the project financially. The key is
# what's used to render the link text on PyPI.
project_urls={ # Optional
'Bug Reports': 'https://github.com/haddocking/pdb-tools/issues',
'Source': 'https://github.com/haddocking/pdb-tools',
},

# Test Suite
test_suite='tests.test_all',
)
},
)
67 changes: 54 additions & 13 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,66 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Unit Tests for all pdb-tools scripts
"""

"""Unit Tests for all pdb-tools scripts."""
import os
import sys
import unittest
from io import StringIO
from importlib import import_module


class OutputCapture(object):
"""Context manager to capture output usually redirected to stdout.
Use as:
>>> with OutputCapture() as output:
>>> ....run_stuff()
>>> print(output) # list with lines
"""

def __enter__(self):
self.stdout = []
self.stderr = []

self._stdout = sys.stdout
self._stderr = sys.stderr
sys.stdout = self._stringout = StringIO()
sys.stderr = self._stringerr = StringIO()
return self

def __exit__(self, *args):

self.stdout.extend(self._stringout.getvalue().splitlines())
self.stderr.extend(self._stringerr.getvalue().splitlines())
del self._stringout # free up some memory
del self._stringerr # free up some memory
sys.stdout = self._stdout
sys.stderr = self._stderr



class TestPDBTools(unittest.TestCase):

from .config import test_dir
@classmethod
def setUpClass(cls):
# Dynamically import the module
cls.module = import_module(cls.name)

def exec_module(self):
"""
Execs module.
"""
with OutputCapture() as output:
try:
self.module.main()
except SystemExit as e:
self.retcode = e.code

def test_all():
mpath = os.path.abspath(os.path.join(test_dir, '..'))
sys.path.insert(0, mpath) # so we load dev files before any installation
self.stdout = output.stdout
self.stderr = output.stderr

loader = unittest.defaultTestLoader
return

tpath = os.path.join(mpath, 'tests')
suite = loader.discover(tpath)

return suite
test_dir = os.path.dirname(os.path.abspath(__file__))
data_dir = os.path.join(test_dir, 'data')
35 changes: 3 additions & 32 deletions tests/test_pdb_b.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,15 @@
import sys
import unittest

from config import data_dir
from utils import OutputCapture
from . import TestPDBTools, data_dir


class TestTool(unittest.TestCase):
class TestTool(TestPDBTools):
"""
Generic class for testing tools.
"""

def setUp(self):
# Dynamically import the module
name = 'pdbtools.pdb_b'
self.module = __import__(name, fromlist=[''])

def exec_module(self):
"""
Execs module.
"""

with OutputCapture() as output:
try:
self.module.main()
except SystemExit as e:
self.retcode = e.code

self.stdout = output.stdout
self.stderr = output.stderr

return
name = 'zpdbtools.pdb_b'

def test_default(self):
"""$ pdb_b data/dummy.pdb"""
Expand Down Expand Up @@ -150,12 +130,3 @@ def test_not_an_option(self):
self.assertEqual(len(self.stdout), 0)
self.assertEqual(self.stderr[0],
"ERROR! First argument is not an option: '20'")


if __name__ == '__main__':
from config import test_dir

mpath = os.path.abspath(os.path.join(test_dir, '..'))
sys.path.insert(0, mpath) # so we load dev files before any installation

unittest.main()
35 changes: 3 additions & 32 deletions tests/test_pdb_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,15 @@
import sys
import unittest

from config import data_dir
from utils import OutputCapture
from . import TestPDBTools, data_dir


class TestTool(unittest.TestCase):
class TestTool(TestPDBTools):
"""
Generic class for testing tools.
"""

def setUp(self):
# Dynamically import the module
name = 'pdbtools.pdb_chain'
self.module = __import__(name, fromlist=[''])

def exec_module(self):
"""
Execs module.
"""

with OutputCapture() as output:
try:
self.module.main()
except SystemExit as e:
self.retcode = e.code

self.stdout = output.stdout
self.stderr = output.stderr

return
name = 'zpdbtools.pdb_chain'

def test_default(self):
"""$ pdb_chain data/dummy.pdb"""
Expand Down Expand Up @@ -149,12 +129,3 @@ def test_not_an_option(self):
self.assertEqual(len(self.stdout), 0)
self.assertEqual(self.stderr[0],
"ERROR! First argument is not an option: 'A'")


if __name__ == '__main__':
from config import test_dir

mpath = os.path.abspath(os.path.join(test_dir, '..'))
sys.path.insert(0, mpath) # so we load dev files before any installation

unittest.main()
Loading

0 comments on commit fb32d54

Please sign in to comment.