Struct noodles_vcf::header::string_maps::StringMaps
source · pub struct StringMaps { /* private fields */ }
Expand description
An indexed map of VCF strings.
This includes both the dictionary of strings and dictionary of contigs.
Implementations§
source§impl StringMaps
impl StringMaps
sourcepub fn strings(&self) -> &StringStringMap
pub fn strings(&self) -> &StringStringMap
Returns an indexed map of VCF strings (FILTER, FORMAT, and INFO).
The filter ID “PASS” is always the first entry in the string string map.
§Examples
use noodles_vcf::{
self as vcf,
header::{
record::value::{map::{Contig, Filter, Format, Info}, Map},
StringMaps,
},
variant::record::{info, samples},
};
let header = vcf::Header::builder()
.add_info(info::field::key::TOTAL_DEPTH, Map::<Info>::from(info::field::key::TOTAL_DEPTH))
.add_filter("q10", Map::<Filter>::new("Quality below 10"))
.add_format(samples::keys::key::READ_DEPTH, Map::<Format>::from(samples::keys::key::READ_DEPTH))
.add_contig("sq0", Map::<Contig>::new())
.build();
let string_maps = StringMaps::try_from(&header)?;
let string_string_map = string_maps.strings();
assert_eq!(string_string_map.get_index(0), Some("PASS"));
assert_eq!(string_string_map.get_index(1), Some("DP"));
assert_eq!(string_string_map.get_index(2), Some("q10"));
assert!(string_string_map.get_index(3).is_none());
sourcepub fn contigs(&self) -> &ContigStringMap
pub fn contigs(&self) -> &ContigStringMap
Returns an indexed map of contig names.
§Examples
use noodles_vcf::{
self as vcf,
header::{
record::value::{map::{Contig, Filter, Format, Info}, Map},
StringMaps,
},
variant::record::{info, samples},
};
let header = vcf::Header::builder()
.add_info(info::field::key::TOTAL_DEPTH, Map::<Info>::from(info::field::key::TOTAL_DEPTH))
.add_filter("q10", Map::<Filter>::new("Quality below 10"))
.add_format(samples::keys::key::READ_DEPTH, Map::<Format>::from(samples::keys::key::READ_DEPTH))
.add_contig("sq0", Map::<Contig>::new())
.build();
let string_maps = StringMaps::try_from(&header)?;
let contig_string_map = string_maps.contigs();
assert_eq!(contig_string_map.get_index(0), Some("sq0"));
assert!(contig_string_map.get_index(1).is_none());
Trait Implementations§
source§impl Clone for StringMaps
impl Clone for StringMaps
source§fn clone(&self) -> StringMaps
fn clone(&self) -> StringMaps
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 Debug for StringMaps
impl Debug for StringMaps
source§impl Default for StringMaps
impl Default for StringMaps
source§impl FromStr for StringMaps
impl FromStr for StringMaps
source§impl PartialEq for StringMaps
impl PartialEq for StringMaps
source§fn eq(&self, other: &StringMaps) -> bool
fn eq(&self, other: &StringMaps) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl TryFrom<&Header> for StringMaps
impl TryFrom<&Header> for StringMaps
impl Eq for StringMaps
impl StructuralPartialEq for StringMaps
Auto Trait Implementations§
impl Freeze for StringMaps
impl RefUnwindSafe for StringMaps
impl Send for StringMaps
impl Sync for StringMaps
impl Unpin for StringMaps
impl UnwindSafe for StringMaps
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.