pub struct ReferenceSequence<I> { /* private fields */ }
Expand description
A binning index reference sequence.
Implementations§
source§impl<I> ReferenceSequence<I>where
I: Index,
impl<I> ReferenceSequence<I>where
I: Index,
sourcepub fn new(
bins: IndexMap<usize, Bin>,
index: I,
metadata: Option<Metadata>
) -> Self
pub fn new( bins: IndexMap<usize, Bin>, index: I, metadata: Option<Metadata> ) -> Self
Creates a binning index reference sequence.
§Examples
use noodles_csi::binning_index::index::ReferenceSequence;
let reference_sequence = ReferenceSequence::new(Default::default(), Vec::new(), None);
sourcepub fn bins(&self) -> &IndexMap<usize, Bin>
pub fn bins(&self) -> &IndexMap<usize, Bin>
Returns the list of bins in the reference sequence.
This list does not include the metadata pseudo-bin. Use
binning_index::ReferenceSequence::metadata
instead.
§Examples
use noodles_csi::binning_index::index::ReferenceSequence;
let reference_sequence = ReferenceSequence::new(Default::default(), Vec::new(), None);
assert!(reference_sequence.bins().is_empty());
sourcepub fn query<J>(
&self,
min_shift: u8,
depth: u8,
interval: J
) -> Result<Vec<&Bin>>
pub fn query<J>( &self, min_shift: u8, depth: u8, interval: J ) -> Result<Vec<&Bin>>
Returns a list of bins in this reference sequence that intersects the given range.
The interval values are 1-based.
§Examples
use noodles_core::Position;
use noodles_csi::binning_index::index::ReferenceSequence;
let reference_sequence = ReferenceSequence::new(Default::default(), Vec::new(), None);
let start = Position::try_from(8)?;
let end = Position::try_from(13)?;
let query_bins = reference_sequence.query(14, 5, start..=end)?;
assert!(query_bins.is_empty());
sourcepub fn min_offset(
&self,
min_shift: u8,
depth: u8,
start: Position
) -> VirtualPosition
pub fn min_offset( &self, min_shift: u8, depth: u8, start: Position ) -> VirtualPosition
Finds the start virtual position of the first record in the bin that contains that given start position.
§Examples
use noodles_bgzf as bgzf;
use noodles_core::Position;
use noodles_csi::binning_index::index::{
reference_sequence::{index::BinnedIndex, Bin},
ReferenceSequence,
};
const MIN_SHIFT: u8 = 4;
const DEPTH: u8 = 2;
let bins = [(1, Bin::new(Vec::new()))].into_iter().collect();
let index = [(1, bgzf::VirtualPosition::from(233))].into_iter().collect();
let reference_sequence: ReferenceSequence<BinnedIndex> = ReferenceSequence::new(bins, index, None);
let start = Position::try_from(8)?;
assert_eq!(
reference_sequence.min_offset(MIN_SHIFT, DEPTH, start),
bgzf::VirtualPosition::from(233)
);
let start = Position::try_from(144)?;
assert_eq!(
reference_sequence.min_offset(MIN_SHIFT, DEPTH, start),
bgzf::VirtualPosition::default()
);
sourcepub fn first_record_in_last_linear_bin_start_position(
&self
) -> Option<VirtualPosition>
pub fn first_record_in_last_linear_bin_start_position( &self ) -> Option<VirtualPosition>
Returns the start position of the first record in the last linear bin.
This uses the linear index, if available; otherwise, the largest linear offset of all the
bins is returned. If there is neither a linear index nor a collection of bins, this returns
None
.
§Examples
use noodles_bgzf as bgzf;
use noodles_csi::binning_index::index::{
reference_sequence::{index::BinnedIndex, Bin},
ReferenceSequence,
};
let reference_sequence = ReferenceSequence::new(
Default::default(),
vec![
bgzf::VirtualPosition::from(8),
bgzf::VirtualPosition::from(13),
bgzf::VirtualPosition::from(21),
],
None,
);
assert_eq!(
reference_sequence.first_record_in_last_linear_bin_start_position(),
Some(bgzf::VirtualPosition::from(21))
);
let mut reference_sequence: ReferenceSequence<BinnedIndex> = ReferenceSequence::new(
[
(0, Bin::new(Vec::new())),
(2, Bin::new(Vec::new())),
(9, Bin::new(Vec::new())),
]
.into_iter()
.collect(),
[
(0, bgzf::VirtualPosition::from(8)),
(2, bgzf::VirtualPosition::from(21)),
(9, bgzf::VirtualPosition::from(13)),
]
.into_iter()
.collect(),
None,
);
assert_eq!(
reference_sequence.first_record_in_last_linear_bin_start_position(),
Some(bgzf::VirtualPosition::from(21))
);
let reference_sequence = ReferenceSequence::new(Default::default(), Vec::new(), None);
assert!(reference_sequence.first_record_in_last_linear_bin_start_position().is_none());
Trait Implementations§
source§impl<I: Clone> Clone for ReferenceSequence<I>
impl<I: Clone> Clone for ReferenceSequence<I>
source§fn clone(&self) -> ReferenceSequence<I>
fn clone(&self) -> ReferenceSequence<I>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<I: Debug> Debug for ReferenceSequence<I>
impl<I: Debug> Debug for ReferenceSequence<I>
source§impl<I: PartialEq> PartialEq for ReferenceSequence<I>
impl<I: PartialEq> PartialEq for ReferenceSequence<I>
source§fn eq(&self, other: &ReferenceSequence<I>) -> bool
fn eq(&self, other: &ReferenceSequence<I>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<I> ReferenceSequence for ReferenceSequence<I>where
I: Index,
impl<I> ReferenceSequence for ReferenceSequence<I>where
I: Index,
impl<I: Eq> Eq for ReferenceSequence<I>
impl<I> StructuralPartialEq for ReferenceSequence<I>
Auto Trait Implementations§
impl<I> Freeze for ReferenceSequence<I>where
I: Freeze,
impl<I> RefUnwindSafe for ReferenceSequence<I>where
I: RefUnwindSafe,
impl<I> Send for ReferenceSequence<I>where
I: Send,
impl<I> Sync for ReferenceSequence<I>where
I: Sync,
impl<I> Unpin for ReferenceSequence<I>where
I: Unpin,
impl<I> UnwindSafe for ReferenceSequence<I>where
I: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.