From f48ff6253d8b6a80778c7546d1ad0c47d5aa28aa Mon Sep 17 00:00:00 2001 From: Jakob Nybo Nissen Date: Wed, 14 Feb 2024 09:57:56 +0100 Subject: [PATCH] Update dependencies Update all dependencies to latest versions. This might be necessary to support Windows. --- Cargo.toml | 13 +++++-------- pyproject.toml | 2 +- src/lib.rs | 33 +++++++++++++++++---------------- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 26dfff7..de56b7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,11 +12,8 @@ name = "pycoverm" crate-type = ["cdylib"] [dependencies] -coverm = "0.6.0" -ndarray = "0.13.1" -numpy = "0.12.1" -pyo3 = { version = "0.12.4", features = ["extension-module"] } -rust-htslib = "0.36.0" - -[package.metadata.maturin] -requires-dist = ["numpy"] +coverm = "0.7.0" +ndarray = "0.15.6" +numpy = "0.20.0" +pyo3 = { version = "0.20", features = ["extension-module"] } +rust-htslib = "0.45.0" diff --git a/pyproject.toml b/pyproject.toml index 9a2f56d..28236c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["maturin>=0.10,<0.11"] +requires = ["maturin>=1.4.0,<2.0", "numpy==0.20.0"] build-backend = "maturin" diff --git a/src/lib.rs b/src/lib.rs index 22cd7cf..92e856e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,8 @@ use coverm::{ FlagFilter, }; use ndarray::Array; -use numpy::convert::ToPyArray; +use numpy::pyo3::IntoPy; +use numpy::ToPyArray; use pyo3::{prelude::*, wrap_pyfunction}; use rust_htslib::{bam, bam::Read}; use std::collections::HashSet; @@ -83,14 +84,16 @@ fn is_bam_sorted(bam_file: &str) -> PyResult { /// tuple /// A tuple whose fist element is a list of the contig names and the second /// one is a numpy matrix of contig coverages in the input BAM files. -#[pyfunction( - contig_end_exclusion = "75", - min_identity = "0.97", - trim_lower = "0.", - trim_upper = "0.", - contig_set = "None", - threads = "1" -)] +#[pyfunction] +#[pyo3(signature = ( + bam_list, + contig_end_exclusion = 75, + min_identity = 0.97, + trim_lower = 0., + trim_upper = 0., + contig_set = None, + threads = 1 +))] fn get_coverages_from_bam( py: Python, bam_list: Vec<&str>, @@ -99,7 +102,7 @@ fn get_coverages_from_bam( trim_lower: f32, trim_upper: f32, contig_set: Option>, - threads: usize, + threads: u16, ) -> (PyObject, PyObject) { let trim_upper = 1. - trim_upper; let min_fraction_covered_bases = 0.; @@ -166,7 +169,7 @@ fn get_coverages_from_bam( &mut estimators_and_taker.taker, &mut estimators_and_taker.estimators, true, - filter_params.flag_filters, + &filter_params.flag_filters, threads, ); @@ -200,9 +203,7 @@ fn get_coverages_from_bam( } ( headers.into_py(py), - matrix - .to_pyarray(Python::acquire_gil().python()) - .into_py(py), + matrix.to_pyarray(py).into() ) } @@ -210,8 +211,8 @@ fn default_return_value(py: Python, n_files: usize) -> (Py, Py) { ( Vec::::new().into_py(py), Array::from_elem((0, n_files), 0f32) - .to_pyarray(Python::acquire_gil().python()) - .into_py(py), + .to_pyarray(py) + .into(), ) }