[med-svn] [Git][med-team/python-pyspoa][master] 8 commits: Fix clean target Closes: #1045607

Andreas Tille (@tille) gitlab at salsa.debian.org
Sun Dec 22 21:38:04 GMT 2024



Andreas Tille pushed to branch master at Debian Med / python-pyspoa


Commits:
ee2d35f5 by Andreas Tille at 2024-12-22T22:33:30+01:00
Fix clean target Closes: #1045607

- - - - -
d20808a2 by Andreas Tille at 2024-12-22T22:33:44+01:00
New upstream version 0.2.1
- - - - -
ca9bacdc by Andreas Tille at 2024-12-22T22:33:44+01:00
New upstream version

- - - - -
5ca85a97 by Andreas Tille at 2024-12-22T22:33:45+01:00
Update upstream source from tag 'upstream/0.2.1'

Update to upstream version '0.2.1'
with Debian dir a333e1df18c726d40af861307b1d8240d4b00905
- - - - -
6bc5c045 by Andreas Tille at 2024-12-22T22:33:45+01:00
Standards-Version: 4.7.0 (routine-update)

- - - - -
ad4ed8cd by Andreas Tille at 2024-12-22T22:33:47+01:00
Build-Depends: s/dh-python/dh-sequence-python3/ (routine-update)

- - - - -
daf0c109 by Andreas Tille at 2024-12-22T22:35:46+01:00
UPdate patch

- - - - -
d5072043 by Andreas Tille at 2024-12-22T22:37:03+01:00
Upload to unstable

- - - - -


17 changed files:

- − .github/workflows/build-wheels.sh
- − .github/workflows/publish.yml
- − .github/workflows/test.yml
- + .gitlab-ci.yml
- + CHANGELOG.md
- LICENSE
- Makefile
- + build-wheels.sh
- + conda/build.sh
- + conda/meta.yaml
- debian/changelog
- debian/control
- debian/patches/adjust-spoa-lib.patch
- debian/rules
- pyspoa.cpp
- setup.py
- tests/test_pyspoa.py


Changes:

=====================================
.github/workflows/build-wheels.sh deleted
=====================================
@@ -1,18 +0,0 @@
-#!/bin/bash
-set -e -x
-
-for VER in cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311; do
-    PYBIN=/opt/python/${VER}/bin
-    rm -rf venv3
-    "${PYBIN}/python3" -m venv venv3
-    source venv3/bin/activate
-    "${PYBIN}/python3" -m pip install --upgrade pip
-    "${PYBIN}/python3" -m pip install cmake==3.27.1 scikit-build
-    "${PYBIN}/python3" -m pip wheel . -w dist
-    make clean
-    deactivate
-done
-
-for wheel in dist/*.whl; do
-    auditwheel repair "${wheel}"
-done


=====================================
.github/workflows/publish.yml deleted
=====================================
@@ -1,45 +0,0 @@
-name: publish-pyspoa
-
-on:
-  push:
-    tags:
-       - 'v*'
-
-jobs:
-
-  linux-wheels:
-    runs-on: ubuntu-latest
-    container: quay.io/pypa/manylinux_2_28_x86_64
-    steps:
-     - uses: actions/checkout at v3
-       with:
-         submodules: recursive
-     - name: Build wheels
-       run: |
-         bash .github/workflows/build-wheels.sh
-     - uses: actions/upload-artifact at v3
-       with:
-         name: linux-wheels
-         path: wheelhouse/
-
-  osx-wheels:
-    runs-on: macos-latest
-    strategy:
-      matrix:
-        python-version: ['3.8', '3.9', '3.10', '3.11']
-    steps:
-     - uses: actions/checkout at v3
-       with:
-         submodules: recursive
-     - uses: actions/setup-python at v4
-       with:
-         python-version: ${{ matrix.python-version }}
-     - name: Build wheels
-       run: |
-         python3 -m venv venv3
-         source venv3/bin/activate
-         make build
-     - uses: actions/upload-artifact at v3
-       with:
-         name: osx-${{ matrix.python-version }}-wheel
-         path: dist/


=====================================
.github/workflows/test.yml deleted
=====================================
@@ -1,52 +0,0 @@
-name: test-pyspoa
-
-on: [push]
-
-jobs:
-
-  test:
-    strategy:
-      matrix:
-        os: [ubuntu-latest, macos-latest]
-    runs-on: ${{ matrix.os }}
-    steps:
-      - uses: actions/checkout at v3
-        with:
-          submodules: recursive
-      - uses: actions/setup-python at v4
-        with:
-          python-version: '3.9'
-      - name: Test ${{ matrix.os }} binding
-        run: |
-          python3 -m venv venv3
-          source venv3/bin/activate
-          make test
-
-  linux-wheels:
-    runs-on: ubuntu-latest
-    container: quay.io/pypa/manylinux_2_28_x86_64
-    steps:
-     - uses: actions/checkout at v3
-       with:
-          submodules: recursive
-     - name: Build wheels
-       run: |
-         bash .github/workflows/build-wheels.sh
-
-  osx-wheels:
-    runs-on: macos-latest
-    strategy:
-      matrix:
-        python-version: ['3.8', '3.9', '3.10', '3.11']
-    steps:
-     - uses: actions/checkout at v3
-       with:
-          submodules: recursive
-     - uses: actions/setup-python at v4
-       with:
-         python-version: ${{ matrix.python-version }}
-     - name: Build wheels
-       run: |
-         python3 -m venv venv3
-         source venv3/bin/activate
-         make test


=====================================
.gitlab-ci.yml
=====================================
@@ -0,0 +1,174 @@
+include:
+    - project: "epi2melabs/ci-templates"
+      file:
+          - "push-github.yaml"
+          - "push-conda.yaml"
+          - "snippets.yaml"
+
+image: ${UBUNTUIMAGE}:20.04
+
+variables:
+    GIT_SUBMODULE_STRATEGY: recursive
+    GH_NAMESPACE: "nanoporetech"
+
+
+.prep-image: &prep-image |
+    export DEBIAN_FRONTEND=noninteractive
+    apt update -qq
+    apt install -y --no-install-recommends gcc autoconf libtool automake make curl wget zlib1g-dev git
+
+.minimal-python: &minimal-python |
+    export DEBIAN_FRONTEND=noninteractive
+    apt-get update -qq && apt-get install -y -qq python3-all-dev python3-venv
+
+
+stages:
+    - test
+    - prerelease
+    - release
+
+
+test:
+    stage: test
+    parallel:
+        matrix:
+            - PYENV_VERSION: ["3.8", "3.9", "3.10", "3.11"]
+    script:
+        - *prep-image
+        - !reference [.install, pyenv]
+        - !reference [.setup, pyenv-python]
+        - make test
+
+
+deploy-checks:
+    stage: prerelease
+    variables:
+        PACKAGE_NAME: pyspoa
+        LICENSE_FILE: BSD-4-CLAUSE
+    script:
+        - !reference [.check, python-version-setup]
+        - !reference [.check, changelog]
+        - !reference [.check, license]
+    rules:
+        - if: '$CI_COMMIT_TAG =~ /^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$/'
+
+
+.conda-before-script: &conda-before-script |
+    export CONDA_PKG=${CI_PROJECT_NAME}
+    export CONDA_PKG_VERSION=${CI_COMMIT_TAG/v/}
+    mkdir conda-build
+    cd conda-build
+
+conda:
+    extends:
+        - .deploy-conda-linux
+    variables:
+        RECIPEPATH: "../conda"
+    before_script:
+        - *prep-image
+        - *conda-before-script
+
+conda-arm:
+    extends:
+        - .deploy-conda-linux-arm
+    variables:
+        RECIPEPATH: "../conda"
+    before_script:
+        - *prep-image
+        - *conda-before-script
+
+conda-mac:
+    extends:
+        - .deploy-conda-mac
+    variables:
+        RECIPEPATH: "../conda"
+    before_script:
+        - *conda-before-script
+
+conda-mac-arm:
+    extends:
+        - .deploy-conda-mac-arm
+    variables:
+        RECIPEPATH: "../conda"
+    before_script:
+        - *conda-before-script
+
+
+### Python
+# The selection of wheels built here is mainly driven by the matrix
+# we build for medaka.
+
+bld:py-sdist:
+    stage: prerelease
+    script:
+        - *prep-image
+        - *minimal-python
+        - make sdist
+        - cd dist
+        - python3 -m venv venv
+        - . venv/bin/activate
+        - pip install --upgrade pip
+        - pip install *.tar.gz
+    artifacts:
+        paths:
+            - dist/*.tar.gz
+
+.many-linux:
+    stage: prerelease
+    script:
+        - echo "Building a Python ${PYWHEEL} wheel on manylinux_${FLAVOUR}"
+        - ./build-wheels.sh . ${PYWHEEL}
+    artifacts:
+        paths:
+            - wheelhouse-final/*.whl
+
+
+wheels-2014:
+    extends: .many-linux
+    image: "quay.io/pypa/manylinux2014_x86_64"
+    parallel:
+        matrix:
+            - PYWHEEL: [7, 8, 9]
+              FLAVOUR: ["2014"]
+
+
+wheels-arm-2014:
+    extends: .many-linux
+    tags:
+        - arm64
+    image: "quay.io/pypa/manylinux2014_aarch64"
+    parallel:
+        matrix:
+            - PYWHEEL: [8, 9, 10]
+              FLAVOUR: ["2014"]
+
+
+wheels-2_28:
+    extends: .many-linux
+    image: "quay.io/pypa/manylinux_2_28_x86_64"
+    parallel:
+        matrix:
+            - PYWHEEL: [8, 9, 10, 11]
+              FLAVOUR: ["2_28"]
+
+
+wheels-arm-2_28:
+    extends: .many-linux
+    tags:
+        - arm64
+    image: "quay.io/pypa/manylinux_2_28_aarch64"
+    parallel:
+        matrix:
+            - PYWHEEL: [8, 9, 10, 11]
+              FLAVOUR: ["2_28"]
+
+
+deploy:pypi:
+    stage: release
+    script:
+        - *minimal-python
+        - make pypi_build/bin/activate
+        - source pypi_build/bin/activate
+        - twine upload --non-interactive wheelhouse-final/pyspoa*.whl dist/pyspoa*.tar.gz
+    rules:
+        - if: '$CI_COMMIT_TAG =~ /^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$/'


=====================================
CHANGELOG.md
=====================================
@@ -0,0 +1,65 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [v0.2.1]
+### Changed
+- Default argument for `min_coverage` to `None`
+
+## [v0.2.0]
+### Changed
+- Updated SPOA to v4.1.2
+### Added
+- `min_coverage` option recently introduced in SPOA
+
+## [v0.1.0]
+### Changed
+- Moved CI to internal infrastructure
+- Added conda builds to CI
+- Larger selection of wheels
+
+## [v0.0.10]
+### Added
+- Support for aarch64 in setup.py
+
+## [v0.0.9]
+### Changed
+- Python support: 3.6, 3.7, removed 3.10, added 3.11
+- All package requirements removed in favour of build time requirements in pyproject.toml
+
+## [v0.0.8]
+### Added
+- Python 3.6+ wheels and source distribution
+
+## [v0.0.6]
+### Added
+- Python 3.9 Support
+### Changed
+- Update spoa to v4.0.7
+
+
+## [v0.0.5]
+### Fixed
+- Alignment type selection, Smith-Waterman no longer hardcoded.
+
+## [v0.0.4]
+### Fixed
+- Portability build
+
+
+## [v0.0.3]
+### Changed
+- Upgrade to spoa 4.0.0
+- Compile for portability
+
+
+## [v0.0.2]
+### Added
+- Python 3.8 support
+
+
+## [v0.0.1]
+### Added
+- PyPI builds


=====================================
LICENSE
=====================================
@@ -1,21 +1,30 @@
-MIT License
+Copyright (c) 2020-, Oxford Nanopore Technologies Plc. All rights reserved.
 
-Copyright (c) 2020 Oxford Nanopore Technologies, Ltd.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimer.
 
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
+* Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+* All advertising materials mentioning features or use of this software must
+  display the following acknowledgement: This product includes software
+  developed by Oxford Nanopore Technologies Plc.
+
+* Neither the name of Oxford Nanopore Technologies Plc. nor the names of
+  its contributors may be used to endorse or promote products derived from this
+  software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY Oxford Nanopore Technologies Plc. AS IS AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Oxford Nanopore Technologies Plc. BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


=====================================
Makefile
=====================================
@@ -1,13 +1,33 @@
-build:
-	pip wheel . -w dist
+PYTHON ?= python3
 
+IN_VENV=. ./venv/bin/activate
+
+venv/bin/activate:
+	test -d venv || $(PYTHON) -m venv venv
+	${IN_VENV} && pip install pip --upgrade
+
+.PHONY: build
+build: venv/bin/activate
+	${IN_VENV} && pip wheel . -w dist
+
+.PHONY: install
 install: build
-	pip install dist/pyspoa*.whl
+	${IN_VENV} && pip install dist/pyspoa*.whl
 
+.PHONY: test
 test: install
-	python3 tests/test_pyspoa.py
+	${IN_VENV} && python tests/test_pyspoa.py
+
+sdist: venv/bin/activate
+	${IN_VENV} && python setup.py sdist
+
+IN_BUILD=. ./pypi_build/bin/activate
+pypi_build/bin/activate:
+	test -d pypi_build || $(PYTHON) -m venv pypi_build --prompt "(pypi) "
+	${IN_BUILD} && pip install pip --upgrade
+	${IN_BUILD} && pip install --upgrade pip setuptools twine wheel readme_renderer[md] keyrings.alt
 
 clean:
-	rm -rf src/build build tmp var *~ *.whl __pycache__
+	rm -rf dist wheelhouse-final venv pypi_build src/build build tmp var *~ *.whl __pycache__
 	python setup.py clean
 	pip uninstall -y pyspoa


=====================================
build-wheels.sh
=====================================
@@ -0,0 +1,72 @@
+#!/bin/bash
+# Usage: ./build-wheels.sh <workdir> <pyminorversion1> <pyminorversion2> ...
+set -eux
+
+PACKAGE_NAME=pyspoa
+
+workdir=$1
+shift
+
+echo "Changing cwd to ${workdir}"
+cd ${workdir}
+
+# some many linux containers are centos-based, others are debian!
+if [ -f /etc/centos-release ]; then
+    yum install -y wget
+else
+    # https://stackoverflow.com/questions/76094428/debian-stretch-repositories-404-not-found
+    sed -i -e 's/deb.debian.org/archive.debian.org/g' \
+           -e 's|security.debian.org|archive.debian.org/|g' \
+           -e '/stretch-updates/d' /etc/apt/sources.list
+    apt update
+    apt install -y wget
+fi
+
+# spoa wants zlib >=1.2.8, ensure we have that
+wget https://github.com/madler/zlib/releases/download/v1.3/zlib-1.3.tar.gz
+tar -xzvf zlib-1.3.tar.gz
+pushd zlib-1.3
+./configure
+make install
+popd
+
+mkdir -p wheelhouse
+
+echo "PYTHON VERSIONS AVAILABLE"
+ls /opt/python/
+
+# Compile wheels
+for minor in $@; do
+    if [[ "${minor}" == "8" ]] || [[ "${minor}" == "9" ]] || \
+        [[ "${minor}" == "10" ]] || [[ "${minor}" == "11" ]]; then
+        PYBIN="/opt/python/cp3${minor}-cp3${minor}/bin"
+    else
+        PYBIN="/opt/python/cp3${minor}-cp3${minor}m/bin"
+    fi
+    "${PYBIN}/python3" -m pip install --upgrade pip
+    "${PYBIN}/python3" -m pip install cmake==3.27.1 scikit-build
+    "${PYBIN}"/pip wheel --no-dependencies . -w ./wheelhouse/
+done
+
+ls ${PYBIN}
+
+# Bundle external shared libraries into the wheels
+for whl in "wheelhouse/${PACKAGE_NAME}"*.whl; do
+    auditwheel repair "${whl}" -w ./wheelhouse/
+done
+
+
+# Install + test packages
+for minor in $@; do
+    if [[ "${minor}" == "8" ]] || [[ "${minor}" == "9" ]] || \
+        [[ "${minor}" == "10" ]] || [[ "${minor}" == "11" ]]; then
+        PYBIN="/opt/python/cp3${minor}-cp3${minor}/bin"
+    else
+        PYBIN="/opt/python/cp3${minor}-cp3${minor}m/bin"
+    fi
+    "${PYBIN}"/pip install "${PACKAGE_NAME}" --no-index -f ./wheelhouse
+    "${PYBIN}"/python3 tests/test_pyspoa.py
+done
+
+mkdir wheelhouse-final
+cp wheelhouse/${PACKAGE_NAME}*manylinux* wheelhouse-final


=====================================
conda/build.sh
=====================================
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+
+${PYTHON} -m pip wheel . -w dist
+${PYTHON} -m pip install . --no-deps --ignore-install -vv


=====================================
conda/meta.yaml
=====================================
@@ -0,0 +1,45 @@
+package:
+    name: {{ environ.get('CONDA_PKG') }}
+    version: {{ environ.get('CONDA_PKG_VERSION') }}
+
+source:
+    path: ../
+
+build:
+    number: {{ environ.get('CONDA_PKG_BUILD', 0) }}
+    skip: True  # [py2k]
+
+requirements:
+    build:
+        - {{ compiler('c') }}
+        - {{ compiler('cxx') }}
+        - make
+        - cmake
+    host:
+        - python
+        - pip
+        - pybind11
+        - zlib
+        - simde
+        - libgomp # [linux]
+        - llvm-openmp # [osx]
+        - cpu_features # [x86]
+    run:
+        - python
+
+test:
+    imports:
+        - spoa
+
+about:
+    home: https://github.com/nanoporetech/pyspoa
+    license: MIT License
+    license_file: LICENSE
+    summary: Python binding to spoa library.
+    doc_url: https://github.com/nanoporetech/spoa
+    dev_url: https://github.com/nanoporetech/spoa
+
+extra:
+    recipe-maintainers:
+        - cjw85
+        - iiSeymour


=====================================
debian/changelog
=====================================
@@ -1,3 +1,14 @@
+python-pyspoa (0.2.1-1) unstable; urgency=medium
+
+  * Team upload.
+  * Fix clean target
+    Closes: #1045607
+  * New upstream version
+  * Standards-Version: 4.7.0 (routine-update)
+  * Build-Depends: s/dh-python/dh-sequence-python3/ (routine-update)
+
+ -- Andreas Tille <tille at debian.org>  Sun, 22 Dec 2024 22:36:09 +0100
+
 python-pyspoa (0.0.10-1) unstable; urgency=medium
 
   * Team upload.


=====================================
debian/control
=====================================
@@ -6,12 +6,12 @@ Uploaders: Nilesh Patra <nilesh at debian.org>,
 Testsuite: autopkgtest-pkg-python
 Build-Depends:
  debhelper-compat (= 13),
- dh-python,
+ dh-sequence-python3,
  python3-all-dev,
  python3-setuptools,
  libspoa-dev,
  python3-pybind11
-Standards-Version: 4.6.2
+Standards-Version: 4.7.0
 Vcs-Browser: https://salsa.debian.org/med-team/python-pyspoa
 Vcs-Git: https://salsa.debian.org/med-team/python-pyspoa.git
 Homepage: https://github.com/nanoporetech/pyspoa


=====================================
debian/patches/adjust-spoa-lib.patch
=====================================
@@ -2,9 +2,9 @@ Description: Make adjustmanets so as to use system's spoa library
 Author: Nilesh Patra <nilesh at debian.org>
 Forwarded: not-needed
 Last-Update: 2021-07-10
---- python-pyspoa.orig/setup.py
-+++ python-pyspoa/setup.py
-@@ -69,11 +69,6 @@
+--- a/setup.py
++++ b/setup.py
+@@ -69,11 +69,6 @@ def build_spoa():
              "-D", "spoa_use_simde=ON",
              "-D", "spoa_use_simde_nonvec=ON",
              "-D", "spoa_use_simde_openmp=ON"]
@@ -16,7 +16,7 @@ Last-Update: 2021-07-10
      run("make", cwd=bdir)
  
  
-@@ -126,7 +121,7 @@
+@@ -126,7 +121,7 @@ ext_modules = [
          ],
          language='c++',
          extra_objects=[
@@ -25,11 +25,11 @@ Last-Update: 2021-07-10
          ],
  
      ),
---- python-pyspoa.orig/pyspoa.cpp
-+++ python-pyspoa/pyspoa.cpp
+--- a/pyspoa.cpp
++++ b/pyspoa.cpp
 @@ -1,4 +1,4 @@
 -#include "spoa.hpp"
 +#include "spoa/spoa.hpp"
- #include <pybind11/stl.h>
- #include <pybind11/pybind11.h>
  
+ #define PYBIND11_DETAILED_ERROR_MESSAGES  // for type information in casting errors
+ #include <pybind11/stl.h>


=====================================
debian/rules
=====================================
@@ -8,7 +8,11 @@ include /usr/share/dpkg/default.mk
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 
 %:
-	dh $@ --with python3 --buildsystem=pybuild
+	dh $@ --buildsystem=pybuild
+
+override_dh_clean:
+	dh_clean
+	rm -rf tmp
 
 override_dh_auto_test:
 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))


=====================================
pyspoa.cpp
=====================================
@@ -1,12 +1,19 @@
 #include "spoa.hpp"
+
+#define PYBIND11_DETAILED_ERROR_MESSAGES  // for type information in casting errors
 #include <pybind11/stl.h>
 #include <pybind11/pybind11.h>
 
 using namespace pybind11::literals;  // for _a in pybind def
 
 auto poa(std::vector<std::string> sequences, int algorithm, bool genmsa,
-	 int m, int n, int g, int e, int q, int c) -> pybind11::tuple
+	 int m, int n, int g, int e, int q, int c, pybind11::object min_coverage) -> pybind11::tuple
 {
+    // set min_coverage to the default of the SPOA CLI (-1) if None
+    int min_cov = -1;
+    if (min_coverage != pybind11::none()) {
+        min_cov = min_coverage.cast<int>();
+    }
     auto alignment_engine = spoa::AlignmentEngine::Create(
       static_cast<spoa::AlignmentType>(algorithm), m, n, g, e, q, c
     );
@@ -18,7 +25,7 @@ auto poa(std::vector<std::string> sequences, int algorithm, bool genmsa,
 	    graph.AddAlignment(alignment, it);
     }
 
-    auto consensus = graph.GenerateConsensus();
+    auto consensus = graph.GenerateConsensus(min_cov);
     std::vector<std::string> msa;
     if (genmsa)
         msa = graph.GenerateMultipleSequenceAlignment();
@@ -30,7 +37,8 @@ PYBIND11_MODULE(spoa, m) {
     m.def(
        "poa", &poa, "",
        "sequences"_a, "algorithm"_a=0, "genmsa"_a=true,
-       "m"_a=5, "n"_a=-4, "g"_a=-8, "e"_a=-6, "q"_a=-10, "c"_a=-4
+       "m"_a=5, "n"_a=-4, "g"_a=-8, "e"_a=-6, "q"_a=-10, "c"_a=-4,
+       "min_coverage"_a=pybind11::none()
     );
 
     m.attr("__version__") = VERSION_INFO;


=====================================
setup.py
=====================================
@@ -137,10 +137,9 @@ with open('README.md', encoding='utf-8') as f:
     long_description = f.read()
 
 
-
 setup(
     name='pyspoa',
-    version='0.0.10',
+    version='0.2.1',
     author='Oxford Nanoporetech Technologies, Ltd.',
     author_email='support at nanoporetech.com',
     url='https://github.com/nanoporetech/pyspoa',


=====================================
tests/test_pyspoa.py
=====================================
@@ -18,6 +18,30 @@ class Tests(TestCase):
         self.assertEqual(consensus, 'AACTTATA')
         self.assertEqual(len(msa), 0)
 
+    def test_bindings_min_coverage(self):
+        """ simple poa to check bindings with `min_coverage` param"""
+        consensus, msa = poa(['AACTTATA', 'AACTTATG', 'AACTATA'], min_coverage=3)
+        self.assertEqual(consensus, 'AACTAT')
+        self.assertEqual(len(msa), 3)
+
+    def test_bindings_min_coverage_None(self):
+        """ simple poa to check bindings with `min_coverage=None`"""
+        consensus, msa = poa(['AACTTATA', 'AACTTATG', 'AACTATA'], min_coverage=None)
+        self.assertEqual(consensus, 'AACTTATA')
+        self.assertEqual(len(msa), 3)
+
+    def test_bindings_min_coverage_wrong_type_string(self):
+        """ check that bindings with `min_coverage=str` throw error"""
+        self.assertRaises(
+            RuntimeError, poa, ["AACTTATA", "AACTTATG", "AACTATA"], min_coverage="x"
+        )
+
+    def test_bindings_min_coverage_wrong_type_float(self):
+        """ check that bindings with `min_coverage=float` throw error"""
+        self.assertRaises(
+            RuntimeError, poa, ["AACTTATA", "AACTTATG", "AACTATA"], min_coverage=1.5
+        )
+
 
 if __name__ == '__main__':
     main()



View it on GitLab: https://salsa.debian.org/med-team/python-pyspoa/-/compare/fa2a33d288d8ebfaa8aaf817e07cf96e5e6c63ca...d5072043ecf91f0e865da0e06fba568508190f1a

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-pyspoa/-/compare/fa2a33d288d8ebfaa8aaf817e07cf96e5e6c63ca...d5072043ecf91f0e865da0e06fba568508190f1a
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20241222/3ade3c2f/attachment-0001.htm>


More information about the debian-med-commit mailing list