pub trait Sequences {
type Container<'a>: 'a
where Self: 'a;
type Slice<'a>;
// Required methods
fn seqnames(&self) -> Vec<String>;
fn get_sequence(
&self,
seqname: &str,
) -> Result<Self::Container<'_>, GRangesError>;
fn get_sequence_length(
&self,
seqname: &str,
) -> Result<Position, GRangesError>;
fn region_map<V, F>(
&self,
func: &F,
seqname: &str,
start: Position,
end: Position,
) -> Result<V, GRangesError>
where F: Fn(<Self as Sequences>::Slice<'_>) -> V;
// Provided methods
fn seqlens(&self) -> Result<IndexMap<String, Position>, GRangesError> { ... }
fn region_map_into_granges<'b, C, F, V, T: 'b>(
&self,
granges: &'b impl AsGRangesRef<'b, C, T>,
func: &F,
) -> Result<GRanges<VecRangesIndexed, Vec<V>>, GRangesError>
where V: Clone,
C: IterableRangeContainer + 'b,
F: Fn(<Self as Sequences>::Slice<'_>) -> V { ... }
}Expand description
The Sequences trait defines generic functionality for per-basepair data, e.g. nucleotide sequences or some per-basepair numeric score.
Required Associated Types§
Required Methods§
fn seqnames(&self) -> Vec<String>
fn get_sequence( &self, seqname: &str, ) -> Result<Self::Container<'_>, GRangesError>
fn get_sequence_length(&self, seqname: &str) -> Result<Position, GRangesError>
Sourcefn region_map<V, F>(
&self,
func: &F,
seqname: &str,
start: Position,
end: Position,
) -> Result<V, GRangesError>
fn region_map<V, F>( &self, func: &F, seqname: &str, start: Position, end: Position, ) -> Result<V, GRangesError>
Apply a function on a Sequences::Slice of a sequence.
§Arguments
func- a function that takes aSelf::Sliceand returns aResult<V, GRangesError>seqname- sequence name.start- aPositionstart position.end- aPositioninclusive end position.
If you’re implementing this trait method, it must being with:
use granges::prelude::try_range;
// let seq = self.get_sequence(seqname)?; // e.g. this normally
let seq = "GATAGAGAGTAGAGTA";
let range = try_range(0, 10, seq.len().try_into().unwrap()).unwrap();to validate the range and to avoid panics.
Provided Methods§
fn seqlens(&self) -> Result<IndexMap<String, Position>, GRangesError>
Sourcefn region_map_into_granges<'b, C, F, V, T: 'b>(
&self,
granges: &'b impl AsGRangesRef<'b, C, T>,
func: &F,
) -> Result<GRanges<VecRangesIndexed, Vec<V>>, GRangesError>
fn region_map_into_granges<'b, C, F, V, T: 'b>( &self, granges: &'b impl AsGRangesRef<'b, C, T>, func: &F, ) -> Result<GRanges<VecRangesIndexed, Vec<V>>, GRangesError>
Create a new GRanges<C, Vec<V>> by apply the function func on
the genomic ranges from granges.
§Arguments
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.