diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 4648a2b2..00000000 --- a/.appveyor.yml +++ /dev/null @@ -1,24 +0,0 @@ -os: Visual Studio 2015 - -environment: - matrix: - - PY_MAJOR_VER: 2 - PYTHON_ARCH: "x86" - - PY_MAJOR_VER: 2 - PYTHON_ARCH: "x86_64" - - PY_MAJOR_VER: 3 - PYTHON_ARCH: "x86" - - PY_MAJOR_VER: 3 - PYTHON_ARCH: "x86_64" - -matrix: - fast_finish: true - -install: - - "python -m pip install flake8" - -build: off - -test_script: - - "flake8" - - "python setup.py test" diff --git a/.coveragerc b/.coveragerc index 9b73ffe2..e56f7a5f 100644 --- a/.coveragerc +++ b/.coveragerc @@ -10,4 +10,5 @@ exclude_lines = if __name__ == .__main__.: ignore_errors = True omit = - tests/* \ No newline at end of file + tests/* + docs/* diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..1cb9a4bb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,156 @@ +name: build + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + lint: + runs-on: ${{ matrix.platform }} + strategy: + matrix: + platform: [ubuntu-latest] + python-version: [3.9] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + shell: bash + + - name: Linter + run: | + python -m pip install flake8 + flake8 . + + build_and_test_linux: + runs-on: ${{ matrix.platform }} + strategy: + matrix: + platform: [ubuntu-latest] + python-version: [3.6, 3.7, 3.8, 3.9] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel bump2version twine + shell: bash + + - name: Linter + run: | + python -m pip install flake8 + flake8 . + + - name: Build + run: | + python --version + python setup.py sdist bdist_wheel + twine check dist/*.whl + twine check dist/*.tar.gz + bump2version --dry-run --verbose --allow-dirty patch + bump2version --dry-run --verbose --allow-dirty minor + bump2version --dry-run --verbose --allow-dirty major + + - name: Test + run: | + python -m pip install . + script -q -e -c "python setup.py test" + + test_macos: + runs-on: ${{ matrix.platform }} + strategy: + matrix: + platform: [macos-latest] + python-version: [3.6, 3.7, 3.8, 3.9] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + brew install expect + shell: bash + + - name: Test Linux/MacOS + run: | + python -m pip install . + unbuffer python setup.py test + + # test_windows: + # runs-on: ${{ matrix.platform }} + # strategy: + # matrix: + # platform: [windows-latest] + # python-version: [3.6, 3.7, 3.8, 3.9] + + # steps: + # - uses: actions/checkout@v2 + + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v2 + # with: + # python-version: ${{ matrix.python-version }} + + # - name: Install dependencies + # run: | + # python -m pip install --upgrade pip setuptools wheel + + # - name: Test Windows + # run: | + # python -m pip install . + # Invoke-Expression 'python setup.py test' + + coverage: + runs-on: ${{ matrix.platform }} + strategy: + matrix: + platform: [ubuntu-latest] + python-version: [3.9] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install coverage + + - name: Get Coverage + run: | + python -m pip install . + script -q -e -c "coverage run setup.py test" + + # from https://about.codecov.io/blog/ + # python-code-coverage-using-github-actions-and-codecov/ + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v2 + with: + fail_ci_if_error: true + verbose: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 91d37195..00000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: python - -python: - - "2.7" - - "3.6" - -matrix: - include: - - python: 3.7 - dist: xenial # required for Python 3.7 (travis-ci/travis-ci#9069) - sudo: required # required for Python 3.7 (travis-ci/travis-ci#9069) - -install: - - pip install flake8 coverage codecov - -script: - - "flake8" - - "coverage run --source=pdbtools/ setup.py test" - - "coverage xml" - -after_success: - - "codecov --file coverage.xml -X pycov -X gcov" \ No newline at end of file diff --git a/README.md b/README.md index 7808bfdc..4a8f39c4 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # pdb-tools [![PyPI version](https://badge.fury.io/py/pdb-tools.svg)](https://badge.fury.io/py/pdb-tools) -[![Travis (.org) branch](https://img.shields.io/travis/haddocking/pdb-tools/master.svg?style=flat&label=TravisCI)](https://travis-ci.org/haddocking/pdb-tools) -[![AppVeyor branch](https://img.shields.io/appveyor/ci/JoaoRodrigues/pdb-tools-2coq6.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/JoaoRodrigues/pdb-tools-2coq6) +[![tests](https://github.com/haddocking/pdb-tools/workflows/tests/badge.svg?branch=master)](https://github.com/haddocking/pdb-tools/actions?workflow=tests) [![codecov](https://codecov.io/gh/haddocking/pdb-tools/branch/master/graph/badge.svg)](https://codecov.io/gh/haddocking/pdb-tools) [![DOI](https://zenodo.org/badge/27217350.svg)](https://doi.org/10.12688/f1000research.17456.1) diff --git a/pdbtools/__init__.py b/pdbtools/__init__.py index 7e84f307..086cfb22 100644 --- a/pdbtools/__init__.py +++ b/pdbtools/__init__.py @@ -121,4 +121,4 @@ 'pdb_uniqname', 'pdb_validate', 'pdb_wc', - ] +] diff --git a/pdbtools/pdb_selaltloc.py b/pdbtools/pdb_selaltloc.py index c2d459b9..d72cf15c 100644 --- a/pdbtools/pdb_selaltloc.py +++ b/pdbtools/pdb_selaltloc.py @@ -39,7 +39,6 @@ data to another. They are based on old FORTRAN77 code that was taking too much effort to maintain and compile. RIP. """ -import operator import os import sys @@ -250,8 +249,8 @@ def is_another_altloc_group( resname, prev_resname, altloc_lines, - rploc, - ): + rploc +): """Detect if current line belongs to a new altloc group.""" a0 = prev_altloc a1 = altloc @@ -264,7 +263,7 @@ def is_another_altloc_group( is_another = ( all((a0, ra0, ru0)) and ( - (a0 != a1 and a1 == ' ' and ru1 > ru0) + (a0 != a1 and a1 == ' ' and ru1 > ru0) or (a0 == ' ' and a1 != ' ' and ru1 > ru0) or (a0 == ' ' and a1 == ' ' and (ru1 != ru0 or ra1 != ra0)) or ( @@ -274,9 +273,9 @@ def is_another_altloc_group( and ru1 > ru0 and len(rl) > 1 and all(len(v) == len(rv[0]) for v in rv[1:]) - ) ) ) + ) return is_another @@ -348,8 +347,8 @@ def flush_resloc_occ_same_residue(altloc_lines, **kw): for atom, linest in sorted_atoms: lines = linest[1] - atom_lines = [l for l in lines if l.startswith(("ATOM", "HETATM"))] - anisou_lines = [l for l in lines if l.startswith(("ANISOU"))] + atom_lines = [ln for ln in lines if ln.startswith(("ATOM", "HETATM"))] + anisou_lines = [ln for ln in lines if ln.startswith(("ANISOU"))] if anisou_lines: new = [] @@ -359,7 +358,7 @@ def flush_resloc_occ_same_residue(altloc_lines, **kw): "There is an error with this PDB. " "We expect one ANISOU line per ATOM/HETATM lines. " "But the number of ATOM/HETATM and ANISOU lines differ." - ) + ) raise ValueError(emsg) for _a, _b in zip(atom_lines, anisou_lines): diff --git a/pdbtools/pdb_tidy.py b/pdbtools/pdb_tidy.py index 2e696cab..f02be8e5 100644 --- a/pdbtools/pdb_tidy.py +++ b/pdbtools/pdb_tidy.py @@ -223,7 +223,6 @@ def make_TER(prev_line): in_model = True serial_offset = 0 - if serial > 99999: emsg = 'ERROR!! Structure contains more than 99.999 atoms.\n' sys.stderr.write(emsg) diff --git a/tox.ini b/setup.cfg similarity index 50% rename from tox.ini rename to setup.cfg index bc0cdacb..9a88560f 100644 --- a/tox.ini +++ b/setup.cfg @@ -7,13 +7,12 @@ exclude = tests/, setup.py -# Ignore long lines and lambda warnings -ignore = E501,E731 +# Ignore: +# E501: long lines +# E731: lambda warnings +# W503/W504: line breaks before/after operators +ignore = E501,E731,W503,W504 # Enable statistics at the end statistics = True -[testenv] -passenv = TOXENV CI TRAVIS TRAVIS_* -deps = codecov>=1.4.0 -commands = codecov -e TOXENV