Skip to content

Commit 28674ea

Browse files
authored
Merge pull request #19 from jguhlin/tests
Some minor tests, change the grcov script to better find coverage
2 parents bc9fdbb + a1193a2 commit 28674ea

File tree

7 files changed

+73
-20
lines changed

7 files changed

+73
-20
lines changed

.circleci/config.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,30 @@ version: 2.1
55
# Define a job to be invoked later in a workflow.
66
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
77
jobs:
8+
coverage:
9+
machine: true
10+
steps:
11+
- checkout
12+
- run: docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin /bin/bash -c "apt-get update; apt-get install cmake -y; cargo build --features htslib; cargo tarpaulin --features htslib --out Xml"
13+
# - run: cargo tarpaulin --out Xml --features htslib,map-file
14+
# - run: cargo tarpaulin --out Xml -r minimap2-sys
15+
- run: bash <(curl -s https://codecov.io/bash)
16+
817
test:
918
docker:
1019
- image: cimg/rust:1.65.0
1120
steps:
1221
- checkout
1322
- restore_cache:
1423
key: project-cache
15-
- run: cargo install grcov
16-
- run: cargo --version
17-
- run: bash .scripts/grcov.bash
18-
- run: curl -Os https://uploader.codecov.io/latest/linux/codecov
19-
- run: chmod +x codecov
20-
- run: ./codecov
24+
#- run: cargo install grcov
25+
#- run: cargo --version
26+
#- run: bash .scripts/grcov.bash
27+
- run: cargo build
28+
- run: cargo build --features htslib
29+
- run: cargo build --features mm2-fast
30+
- run: cargo build --features simde
31+
- run: cargo build --features htslib,mm2-fast,simde
2132
- save_cache:
2233
key: project-cache
2334
paths:
@@ -40,3 +51,4 @@ workflows:
4051
minimap2-test:
4152
jobs:
4253
- test
54+
- coverage

.github/workflows/build-test-rust.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,14 @@ jobs:
1313
container: messense/rust-musl-cross:x86_64-musl
1414
steps:
1515
- uses: actions/checkout@v3
16-
- uses: NSCoder/[email protected]
1716
- name: Build
1817
run: cargo build --verbose
1918
- name: Run tests
2019
run: cargo test
21-
- name: Run tests mm2-fast
22-
run: cargo test --features mm2-fast
2320
- name: Run tests htslib
2421
run: cargo test --features htslib
25-
- name: Run tests simde
26-
run: cargo test --features simde
27-
2822

2923
test:
30-
3124
runs-on: ubuntu-latest
3225
steps:
3326
- uses: actions/checkout@v3

.scripts/grcov.bash

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ export RUSTDOCFLAGS="-Cpanic=abort"
77
export LLVM_PROFILE_FILE="sfasta-%p-%m.profraw"
88

99
mkdir -p target/coverage
10+
mkdir -p minimap2-sys/target/coverage
1011

11-
cargo test
12+
cargo test --features htslib,mm2-fast,simde,map-file
13+
cd minimap2-sys
14+
cargo test --features mm2-fast,simde
15+
cd ..
1216

1317
#grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/debug/coverage/
1418
grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov
15-
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
19+
# grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
1620
#genhtml -o ./target/debug/coverage/ --show-details --highlight --ignore-errors source --legend ./target/debug/lcov.info

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "minimap2"
3-
version = "0.1.11"
3+
version = "0.1.12"
44
edition = "2021"
55
authors = ["Joseph Guhlin <[email protected]>"]
66
license = "MIT OR Apache-2.0"

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ let mut aligner = Aligner::builder()
103103
The following crate features are available:
104104
* `mm2-fast` - Replace minimap2 with [mm2-fast](https://github.com/bwa-mem2/mm2-fast). This is likely not portable.
105105
* `htslib` - Support output of bam/sam files using htslib.
106-
* `map-file` - Convenience function for mapping an entire file. Caution, this is single-threaded.
107106
* `simde` - Compile minimap2 / mm2-fast with [simd-everywhere](https://github.com/simd-everywhere/simde) support.
107+
* `map-file` - *Default* - Convenience function for mapping an entire file. Caution, this is single-threaded.
108+
109+
Map-file is a *default* feature and enabled unless otherwise specified.
108110

109111
## Building for MUSL
110112
Follow these [instructions](https://github.com/rust-cross/rust-musl-cross#prebuilt-images).
@@ -118,6 +120,12 @@ rust-musl-builder cargo build --release
118120

119121
Please note minimap2 is only tested for x86_64. Other platforms may work, please open an issue if minimap2 compiles but minimap2-rs does not.
120122

123+
### Features tested with MUSL
124+
* `mm2-fast` - **Fail**
125+
* `htslib` - **Success**
126+
* `simde` - **Success**
127+
128+
121129
# Want feedback
122130
* Many fields are i32 / i8 to mimic the C environment, but would it make more sense to convert to u32 / u8 / usize?
123131
* Let me know pain points

minimappers2/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ dependencies = [
1717
"pyarrow==10.0.1",
1818
]
1919

20+
[project.urls]
21+
homepage = "https://github.com/jguhlin/minimap2-rs"
22+
repository = "https://github.com/jguhlin/minimap2-rs"
23+
24+
2025
[build-system]
2126
requires = ["maturin>=0.14,<0.15"]
2227
build-backend = "maturin"

src/lib.rs

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,14 +882,14 @@ pub fn detect_compression_format(buffer: &[u8]) -> Result<CompressionType, &'sta
882882
Ok(match buffer {
883883
[0x1F, 0x8B, ..] => CompressionType::GZIP,
884884
[0x42, 0x5A, ..] => CompressionType::BZIP2,
885-
[0xFD, b'7', b'z', b'X', b'Z', 0x00] => CompressionType::XZ,
885+
[0xFD, b'7', b'z', b'X', b'Z', 0x00, ..] => CompressionType::XZ,
886886
[0x28, 0xB5, 0x2F, 0xFD, ..] => CompressionType::LZMA,
887887
[0x5D, 0x00, ..] => CompressionType::LZMA,
888888
[0x1F, 0x9D, ..] => CompressionType::LZMA,
889-
[0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C] => CompressionType::ZSTD,
889+
[0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C, ..] => CompressionType::ZSTD,
890890
[0x04, 0x22, 0x4D, 0x18, ..] => CompressionType::LZ4,
891891
[0x08, 0x22, 0x4D, 0x18, ..] => CompressionType::LZ4,
892-
[0x52, 0x61, 0x72, 0x21, 0x1A, 0x07] => CompressionType::RAR,
892+
[0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, ..] => CompressionType::RAR,
893893
_ => CompressionType::NONE,
894894
})
895895
}
@@ -899,6 +899,34 @@ mod tests {
899899
use super::*;
900900
use std::mem::MaybeUninit;
901901

902+
#[test]
903+
fn compression_format_detections() {
904+
let buf = [0x1F, 0x8B, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF];
905+
assert_eq!(detect_compression_format(&buf).unwrap(), CompressionType::GZIP);
906+
907+
let buf = [0x42, 0x5A, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59];
908+
assert_eq!(detect_compression_format(&buf).unwrap(), CompressionType::BZIP2);
909+
910+
let buf = [0x28, 0xB5, 0x2F, 0xFD, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00];
911+
assert_eq!(detect_compression_format(&buf).unwrap(), CompressionType::LZMA);
912+
913+
let buf = [0x04, 0x22, 0x4D, 0x18, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00];
914+
assert_eq!(detect_compression_format(&buf).unwrap(), CompressionType::LZ4);
915+
916+
let buf = [0x08, 0x22, 0x4D, 0x18, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00];
917+
assert_eq!(detect_compression_format(&buf).unwrap(), CompressionType::LZ4);
918+
919+
let buf = [0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00, 0x00, 0x00, 0x00];
920+
assert_eq!(detect_compression_format(&buf).unwrap(), CompressionType::RAR);
921+
922+
let buf = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
923+
assert_eq!(detect_compression_format(&buf).unwrap(), CompressionType::NONE);
924+
925+
let buf = [0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C, 0x00, 0x00, 0x00, 0x00];
926+
assert_eq!(detect_compression_format(&buf).unwrap(), CompressionType::ZSTD);
927+
928+
}
929+
902930
#[test]
903931
fn does_it_work() {
904932
let mut mm_idxopt = MaybeUninit::uninit();
@@ -960,6 +988,9 @@ mod tests {
960988
println!("Reverse Strand\n{:#?}", mappings);
961989
assert!(mappings[0].strand == Strand::Reverse);
962990

991+
// Assert the Display impl for strand works
992+
println!("{}", mappings[0].strand);
993+
963994
let mut aligner = aligner.with_cigar();
964995

965996
aligner

0 commit comments

Comments
 (0)