Skip to content

Commit

Permalink
feat: derive PartialEq and Eq for bam:: and bcf::Format (#428)
Browse files Browse the repository at this point in the history
* feat: derive PartialEq and Eq for bam:: and bcf::Format

* docs: add description for bam reference_end function

* docs: typo

* docs: clarify start and stop indexing for bam fetch

* chore: fmt
  • Loading branch information
mbhall88 committed Apr 25, 2024
1 parent 79d70cd commit 528e543
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/bam/ext.rs
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
6 changes: 4 additions & 2 deletions src/bam/mod.rs
Expand Up @@ -677,7 +677,7 @@ impl IndexedReader {
///
/// Both iterating (with [.records()](trait.Read.html#tymethod.records)) and looping without allocation (with [.read()](trait.Read.html#tymethod.read) are a two stage process:
/// 1. 'fetch' the region of interest
/// 2. iter/loop trough the reads.
/// 2. iter/loop through the reads.
///
/// Example:
/// ```
Expand All @@ -703,6 +703,8 @@ impl IndexedReader {
/// coordinates' expansion), i32, u32, and u64 (with a possible panic! if the coordinate
/// won't fit an i64).
///
/// `start` and `stop` are zero-based. `start` is inclusive, `stop` is exclusive.
///
/// This replaces the old fetch and fetch_str implementations.
pub fn fetch<'a, T: Into<FetchDefinition<'a>>>(&mut self, fetch_definition: T) -> Result<()> {
//this 'compile time redirect' safes us
Expand Down Expand Up @@ -1037,7 +1039,7 @@ impl Drop for IndexedReader {
}
}

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Format {
Sam,
Bam,
Expand Down
2 changes: 1 addition & 1 deletion src/bcf/mod.rs
Expand Up @@ -632,7 +632,7 @@ pub mod synced {
}
}

#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Format {
Vcf,
Bcf,
Expand Down

0 comments on commit 528e543

Please sign in to comment.