Skip to content

Commit

Permalink
Merge branch 'master' into ar/header-remove-unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester authored Nov 12, 2024
2 parents bc5c9f8 + 4b3cbcb commit 74d9201
Show file tree
Hide file tree
Showing 23 changed files with 817 additions and 209 deletions.
64 changes: 22 additions & 42 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ jobs:
with:
submodules: recursive

- name: Install stable toolchain
- name: Install nightly toolchain
uses: actions-rs/[email protected]
with:
toolchain: stable
toolchain: nightly
override: true

- name: Install system dependencies
Expand All @@ -67,8 +67,9 @@ jobs:
- name: Run cargo-tarpaulin
uses: actions-rs/[email protected]
with:
# TODO: update to latest tarpaulin once artefact download is fixed: https://github.com/actions-rs/tarpaulin/pull/23
version: "0.22.0"
args: "--all-features --out Lcov -- --test-threads 1"
args: "--all-features --run-types Tests,Doctests --out Lcov -- --test-threads 1"

- name: Upload coverage
uses: coverallsapp/github-action@v1
Expand All @@ -84,9 +85,6 @@ jobs:
target:
- no-default-features
- all-features
- musl-release-no-default-features
- musl-release-all-features
- musl-all-features
include:
- target: no-default-features
args: --no-default-features
Expand All @@ -95,18 +93,6 @@ jobs:
args: --all-features
toolchain_target: x86_64-unknown-linux-musl
use_cross: false
- target: musl-release-no-default-features
args: --release --target x86_64-unknown-linux-musl --no-default-features
toolchain_target: x86_64-unknown-linux-musl
use_cross: true
- target: musl-release-all-features
args: --release --target x86_64-unknown-linux-musl --all-features --verbose
toolchain_target: x86_64-unknown-linux-musl
use_cross: true
- target: musl-all-features
args: --target x86_64-unknown-linux-musl --all-features --verbose
toolchain_target: x86_64-unknown-linux-musl
use_cross: true

steps:
- name: Checkout repository
Expand Down Expand Up @@ -139,29 +125,28 @@ jobs:
strategy:
matrix:
target:
- intel-catalina
- intel-bigsur
- m1-bigsur
- intel-monterey
- intel-ventura
- silicon-sonoma
include:
- target: intel-catalina
os: macOS-10.15
- target: intel-monterey
os: macOS-12.0
toolchain_target: x86_64-apple-darwin
toolchain: stable
aux_args: ""
default: false
- target: intel-bigsur
os: macOS-11.0
aux_args: --target x86_64-apple-darwin
default: true
- target: intel-ventura
os: macOS-13.0
toolchain_target: x86_64-apple-darwin
toolchain: stable
aux_args: --target x86_64-apple-darwin
default: true
- target: silicon-sonoma
os: macOS-14.0
toolchain_target: aarch64-apple-darwin
toolchain: stable
aux_args: ""
default: false
# TODO enable again and try to find out why this fails
# - target: m1-bigsur
# os: macOS-11.0
# toolchain_target: aarch64-apple-darwin
# toolchain: nightly
# aux_args: --target aarch64-apple-darwin
# default: true

steps:
- name: Checkout repository
Expand All @@ -172,19 +157,14 @@ jobs:
- name: Install stable toolchain
uses: actions-rs/[email protected]
with:
toolchain: stable
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.toolchain_target }}
override: true
default: ${{ matrix.default }}

- name: Install htslib dependencies
run: brew install bzip2 zlib xz curl-openssl

#- uses: actions-rs/[email protected]
# with:
# toolchain: ${{ matrix.toolchain }}
# target: ${{ matrix.toolchain_target }}
# #override: true
# default: ${{ matrix.default }}

- name: Test
uses: actions-rs/[email protected]
with:
Expand Down
61 changes: 61 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,67 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.47.0](https://github.com/rust-bio/rust-htslib/compare/v0.46.0...v0.47.0) (2024-05-22)


### Features

* Add fasta::build function + FaidxBuildError ([#418](https://github.com/rust-bio/rust-htslib/issues/418)) ([7c575ef](https://github.com/rust-bio/rust-htslib/commit/7c575ef549908745f34d9371986551f3d70ed444))
* Add rust_htslib::bcf::index::build ([#408](https://github.com/rust-bio/rust-htslib/issues/408)) ([79d70cd](https://github.com/rust-bio/rust-htslib/commit/79d70cd6683f1a019e9052baa495dada709db432))
* derive PartialEq and Eq for bam:: and bcf::Format ([#428](https://github.com/rust-bio/rust-htslib/issues/428)) ([528e543](https://github.com/rust-bio/rust-htslib/commit/528e54367367487a28bbc2566bd37de995f8ed1d))


### Bug Fixes

* bam::Record:new should return a valid record ([#361](https://github.com/rust-bio/rust-htslib/issues/361)) ([87f2011](https://github.com/rust-bio/rust-htslib/commit/87f20116c4337eda17a416ebafb8976abc188d87))
* build for macOS ([#431](https://github.com/rust-bio/rust-htslib/issues/431)) ([d869fdd](https://github.com/rust-bio/rust-htslib/commit/d869fdda03900cafae0f4f60b033121dcd57b723))
* in bam record buffer, change the start of the window to the first added item in last iteration ([#430](https://github.com/rust-bio/rust-htslib/issues/430)) ([56ee2bd](https://github.com/rust-bio/rust-htslib/commit/56ee2bd562788dad0dc8516d0e3db90ffa916320))
* Panic on trailing omitted FORMAT records ([#417](https://github.com/rust-bio/rust-htslib/issues/417)) ([9f575ee](https://github.com/rust-bio/rust-htslib/commit/9f575ee40e15737731bc8234812c0cf36c1157f4))

## [0.46.0](https://github.com/rust-bio/rust-htslib/compare/v0.45.0...v0.46.0) (2024-02-22)


### Features

* making several RecordBuffer methods public ([6757f52](https://github.com/rust-bio/rust-htslib/commit/6757f5219955fd4edba4f61e62978ce1e001068e))


### Bug Fixes

* fix building libz-sys ([#420](https://github.com/rust-bio/rust-htslib/issues/420)) ([01c8849](https://github.com/rust-bio/rust-htslib/commit/01c884945686e7a6756406b579fde28657f70b36))

## [0.45.0](https://github.com/rust-bio/rust-htslib/compare/v0.44.1...v0.45.0) (2024-02-07)


### Features

* adding function to get sequence length to faidx mod ([#410](https://github.com/rust-bio/rust-htslib/issues/410)) ([ae79eba](https://github.com/rust-bio/rust-htslib/commit/ae79eba82ef6929105bdbe08246a8e973660899e))


### Bug Fixes

* Loosen acceptable types to support current linux build on aarch64 ([#415](https://github.com/rust-bio/rust-htslib/issues/415)) ([1d78d12](https://github.com/rust-bio/rust-htslib/commit/1d78d1251a052461605d28cd8cf832ccad93ef73))

## [0.44.1](https://github.com/rust-bio/rust-htslib/compare/v0.44.0...v0.44.1) (2023-06-21)


### Bug Fixes

* use correct return value in bcf_get_format and bcf_get_info_values ([#398](https://github.com/rust-bio/rust-htslib/issues/398)) ([f9a1981](https://github.com/rust-bio/rust-htslib/commit/f9a1981fa84eef39e35f868ddfc773ea265b94b3))

## [0.44.0](https://github.com/rust-bio/rust-htslib/compare/v0.43.1...v0.44.0) (2023-06-20)


### Features

* implement Clone for bcf::Record ([#394](https://github.com/rust-bio/rust-htslib/issues/394)) ([e89538d](https://github.com/rust-bio/rust-htslib/commit/e89538d5a9971c6508ac38d92ac468f3d70241aa))
* implement htslib basemod api ([#385](https://github.com/rust-bio/rust-htslib/issues/385)) ([8beee14](https://github.com/rust-bio/rust-htslib/commit/8beee145a116f7ae936f1b6e36d876116dca18f1))


### Bug Fixes

* include doctests in test coverage calculations ([#397](https://github.com/rust-bio/rust-htslib/issues/397)) ([8ed0837](https://github.com/rust-bio/rust-htslib/commit/8ed083783fa1dce09535564a090d37f687fc832f))

## [0.43.1](https://github.com/rust-bio/rust-htslib/compare/v0.43.0...v0.43.1) (2023-05-16)


Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ license = "MIT"
name = "rust-htslib"
readme = "README.md"
repository = "https://github.com/rust-bio/rust-htslib.git"
version = "0.43.1"
version = "0.47.0"

[package.metadata.release]
pre-release-commit-message = "release version {{version}}"
tag-message = "Version {{version}} of Rust-HTSlib."

[dependencies]
libz-sys = ">=1.1.15"
bio-types = ">=0.9"
byteorder = "1.3"
custom_derive = "0.1"
derive-new = "0.5"
hts-sys = {version = "2.0.3", default-features = false}
hts-sys = {version = "2.1.4", default-features = false, features = ["bindgen"]}
ieee754 = "0.2"
lazy_static = "1.4"
libc = "0.2"
Expand Down
11 changes: 0 additions & 11 deletions Cross.toml

This file was deleted.

30 changes: 0 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,6 @@ If you only want to use the library, there is no need to clone the repository. G

rust-htslib comes with pre-built bindings to htslib for Mac and Linux. You will need a C toolchain compatible with the `cc` crate. The build script for this crate will automatically build a link htslib.


### MUSL build
To compile this for MUSL crate you need docker and cross:

```shell
$ cargo install cross
$ cross build # will build with GNU GCC or LLVM toolchains
```

If you want to run rust-htslib code on AWS lambda, [you'll need to statically compile it with MUSL](https://github.com/awslabs/aws-lambda-rust-runtime/issues/17#issuecomment-577490373) as follows:

```shell
$ cross build --target x86_64-unknown-linux-musl # will build with MUSL toolchain
```

Alternatively, you can also install it locally by installing the development headers of zlib, bzip2 and xz. For instance, in Debian systems one needs the following dependencies:

```shell
$ sudo apt-get install zlib1g-dev libbz2-dev liblzma-dev clang pkg-config
```

We provide Dockerfile bases that provide these dependencies. Refer to the [docker](https://github.com/rust-bio/rust-htslib/tree/master/docker) directory in this repository for the latest instructions, including LLVM installation.

On OSX:

```shell
$ brew install FiloSottile/musl-cross/musl-cross
$ brew install bzip2 zlib xz curl-openssl
```

## Usage

Add this to your `Cargo.toml`:
Expand Down
7 changes: 0 additions & 7 deletions docker/Dockerfile.gnu

This file was deleted.

16 changes: 0 additions & 16 deletions docker/Dockerfile.musl

This file was deleted.

17 changes: 0 additions & 17 deletions docker/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions docker/config-musl-cross-make.mak

This file was deleted.

12 changes: 7 additions & 5 deletions src/bam/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::str;
use crate::bam;
use crate::bam::Read;
use crate::errors::{Error, Result};

/// A buffer for BAM records. This allows access regions in a sorted BAM file while iterating
/// over it in a single pass.
/// The buffer is implemented as a ringbuffer, such that extension or movement to the right has
Expand All @@ -25,6 +24,7 @@ pub struct RecordBuffer {
cache_cigar: bool,
min_refetch_distance: u64,
buffer_record: Rc<bam::Record>,
start_pos: Option<u64>,
}

unsafe impl Sync for RecordBuffer {}
Expand All @@ -45,6 +45,7 @@ impl RecordBuffer {
cache_cigar,
min_refetch_distance: 1,
buffer_record: Rc::new(bam::Record::new()),
start_pos: Some(0),
}
}

Expand All @@ -57,16 +58,16 @@ impl RecordBuffer {
}

/// Return start position of buffer
fn start(&self) -> Option<u64> {
pub fn start(&self) -> Option<u64> {
self.inner.front().map(|rec| rec.pos() as u64)
}

/// Return end position of buffer.
fn end(&self) -> Option<u64> {
pub fn end(&self) -> Option<u64> {
self.inner.back().map(|rec| rec.pos() as u64)
}

fn tid(&self) -> Option<i32> {
pub fn tid(&self) -> Option<i32> {
self.inner.back().map(|rec| rec.tid())
}

Expand All @@ -89,7 +90,7 @@ impl RecordBuffer {
if self.inner.is_empty()
|| window_start.saturating_sub(self.end().unwrap()) >= self.min_refetch_distance
|| self.tid().unwrap() != tid as i32
|| self.start().unwrap() > window_start
|| self.start().unwrap() > self.start_pos.unwrap()
{
let end = self.reader.header.target_len(tid).unwrap();
self.reader.fetch((tid, window_start, end))?;
Expand Down Expand Up @@ -145,6 +146,7 @@ impl RecordBuffer {
added += 1;
}
}
self.start_pos = Some(self.start().unwrap_or(window_start));

Ok((added, deleted))
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/bam/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ impl BamRecordExtensions for bam::Record {
fn reference_start(&self) -> i64 {
self.pos()
}

/// Calculate the rightmost base position of an alignment on the reference genome.
/// Returns the coordinate of the first base after the alignment (0-based).
fn reference_end(&self) -> i64 {
unsafe { htslib::bam_endpos(self.inner_ptr()) }
}
Expand Down
Loading

0 comments on commit 74d9201

Please sign in to comment.