pub struct ChainMap {
pub map: FxHashMap<u32, Chain>,
}Expand description
A map of chains
Fields§
§map: FxHashMap<u32, Chain>Implementations§
Source§impl ChainMap
impl ChainMap
Sourcepub fn get(&self, key: &u32) -> Option<&Chain>
pub fn get(&self, key: &u32) -> Option<&Chain>
Get a chain from the map
§Arguments
key- A chain id
§Returns
- Option<&Chain>
§Example
use chaintools::cmap::ChainMap;
use chaintools::io::reader::Reader;
let chains = Reader::from_file("file.chain").unwrap();
let chain = chains.get(&123);
println!("{:?}", chain);
>>> Some(Chain { score: 0, refs: ChainHead { size: 0, start: 0, end: 0, strand: 0 },
query: ChainHead { size: 0, start: 0, end: 0, strand: 0 }, alinment: [], id: 123 })Sourcepub fn get_mut(&mut self, key: &u32) -> Option<&mut Chain>
pub fn get_mut(&mut self, key: &u32) -> Option<&mut Chain>
Get a mutable chain from the map
§Arguments
key- A chain id
§Returns
- Option<&mut Chain>
§Example
use chaintools::cmap::ChainMap;
use chaintools::io::reader::Reader;
let chains = Reader::from_file("file.chain").unwrap();
let chain = chains.get_mut(&123);
println!("{:?}", chain);
>>> Some(Chain { score: 0, refs: ChainHead { size: 0, start: 0, end: 0, strand: 0 },
query: ChainHead { size: 0, start: 0, end: 0, strand: 0 }, alinment: [], id: 123 })Sourcepub fn filter<F>(&self, fc: F) -> Self
pub fn filter<F>(&self, fc: F) -> Self
Generalized filtering function
§Arguments
fc- A closure that takes a reference to a Chain and returns a boolean
§Returns
- ChainMap
§Example
use chaintools::cmap::ChainMap;
use chaintools::cmap::chain::Chain;
use chaintools::io::reader::Reader;
let chains = Reader::from_file("file.chain").unwrap();
let filt_chains = chains.filter(|chain| chain.score > 100);Sourcepub fn insert(&mut self, key: u32, value: Chain) -> &mut ChainMap
pub fn insert(&mut self, key: u32, value: Chain) -> &mut ChainMap
Insert a chain into a ChainMap
§Arguments
key- A chain idvalue- A Chain
§Returns
- &mut ChainMap
§Example
use chaintools::cmap::ChainMap;
use chaintools::io::reader::Reader;
let chains = Reader::from_file("file.chain").unwrap();
chains.insert(123, Chain{ score: 0, refs: ChainHead { size: 0, start: 0, end: 0, strand: 0 }, ..., id: 123});Sourcepub fn values_mut(&mut self) -> impl Iterator<Item = &mut Chain>
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut Chain>
Iterate over mut values of the ChainMap
§Returns
- Iterator<Item = &mut Chain>
§Example
use chaintools::cmap::ChainMap;
use chaintools::io::reader::Reader;
let chains = Reader::from_file("file.chain").unwrap();
for chain in chains.values_mut() {
println!("{:?}", chain);
chain.score = 100;
println!("{:?}", chain);
break;
}Sourcepub fn filter_by_score(&self, score: i64) -> Self
pub fn filter_by_score(&self, score: i64) -> Self
Sourcepub fn filter_ref_by_size(&self, size: u64) -> Self
pub fn filter_ref_by_size(&self, size: u64) -> Self
Sourcepub fn filter_query_by_size(&self, size: u64) -> Self
pub fn filter_query_by_size(&self, size: u64) -> Self
Sourcepub fn filter_id(&self, ids: Vec<u32>) -> Self
pub fn filter_id(&self, ids: Vec<u32>) -> Self
Filter the ChainMap by chain ids
§Arguments
ids- A vector of chain ids
§Returns
- ChainMap
§Example
use chaintools::cmap::ChainMap;
use chaintools::io::reader::Reader;
let chains = Reader::from_file("file.chain").unwrap();
let ids = vec![123, 456];
let filt_chains = chains.filter(ids).len();
println!("{:?}", filt_chains);
>>> 2Trait Implementations§
Source§impl<'de> Deserialize<'de> for ChainMap
impl<'de> Deserialize<'de> for ChainMap
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ChainMap
impl RefUnwindSafe for ChainMap
impl Send for ChainMap
impl Sync for ChainMap
impl Unpin for ChainMap
impl UnwindSafe for ChainMap
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more