Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: derive PartialEq and Eq for bam:: and bcf::Format #428

Merged
merged 5 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 4 additions & 2 deletions src/bam/mod.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading