Struct noodles_bcf::record::Info
source · [−]pub struct Info { /* private fields */ }
Expand description
BCF record info.
Implementations
sourceimpl Info
impl Info
sourcepub fn try_into_vcf_record_info(
&self,
header: &Header,
string_string_map: &StringStringMap
) -> Result<Info>
pub fn try_into_vcf_record_info(
&self,
header: &Header,
string_string_map: &StringStringMap
) -> Result<Info>
Converts BCF record info to VCF record info.
Examples
use noodles_bcf as bcf;
use noodles_vcf as vcf;
let bcf_info = bcf::record::Info::default();
let header = vcf::Header::default();
let string_maps = bcf::header::StringMaps::default();
let vcf_info = bcf_info.try_into_vcf_record_info(&header, string_maps.strings())?;
assert!(vcf_info.is_empty());
sourcepub fn new(buf: Vec<u8>, field_count: usize) -> Self
pub fn new(buf: Vec<u8>, field_count: usize) -> Self
Creates an info map by wrapping the given buffer.
Examples
use noodles_bcf::record::Info;
let data = vec![
0x11, 0x01, 0x11, 0x05, // AC=5
0x11, 0x02, 0x11, 0x08, // DP=8
];
let info = Info::new(data, 2);
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of info fields.
Examples
use noodles_bcf::record::Info;
let info = Info::default();
assert_eq!(info.len(), 0);
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether there are any info fields.
Examples
use noodles_bcf::record::Info;
let info = Info::default();
assert!(info.is_empty());
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Removes all fields from the info map.
This does not affect the capacity of the map.
Examples
use noodles_bcf::record::Info;
let mut info = Info::default();
info.clear();
assert!(info.is_empty());
sourcepub fn get(
&self,
header: &Header,
string_string_map: &StringStringMap,
key: &Key
) -> Option<Result<Field>>
pub fn get(
&self,
header: &Header,
string_string_map: &StringStringMap,
key: &Key
) -> Option<Result<Field>>
Returns the field with the given key.
Examples
use noodles_bcf::{header::StringMaps, record::Info};
use noodles_vcf::{self as vcf, record::info::{field::{Key, Value}, Field}, Header};
let header = vcf::Header::builder()
.add_info(vcf::header::Info::from(Key::AlleleCount))
.add_info(vcf::header::Info::from(Key::TotalDepth))
.build();
let string_maps = StringMaps::from(&header);
let data = vec![
0x11, 0x01, 0x11, 0x05, // AC=5
0x11, 0x02, 0x11, 0x08, // DP=8
];
let info = Info::new(data, 2);
assert_eq!(
info.get(&header, string_maps.strings(), &Key::AlleleCount).transpose()?,
Some(Field::new(Key::AlleleCount, Some(Value::Integer(5))))
);
assert!(info.get(&header, string_maps.strings(), &Key::AncestralAllele).is_none());
sourcepub fn values<'a>(
&'a self,
header: &'a Header,
string_string_map: &'a StringStringMap
) -> impl Iterator<Item = Result<Field>> + 'a
pub fn values<'a>(
&'a self,
header: &'a Header,
string_string_map: &'a StringStringMap
) -> impl Iterator<Item = Result<Field>> + 'a
Returns an iterator over all info fields.
Examples
use noodles_bcf::{header::StringMaps, record::Info};
use noodles_vcf::{self as vcf, record::info::{field::{Key, Value}, Field}, Header};
let header = vcf::Header::builder()
.add_info(vcf::header::Info::from(Key::AlleleCount))
.add_info(vcf::header::Info::from(Key::TotalDepth))
.build();
let string_maps = StringMaps::from(&header);
let data = vec![
0x11, 0x01, 0x11, 0x05, // AC=5
0x11, 0x02, 0x11, 0x08, // DP=8
];
let info = Info::new(data, 2);
let mut fields = info.values(&header, string_maps.strings());
assert_eq!(
fields.next().transpose()?,
Some(Field::new(Key::AlleleCount, Some(Value::Integer(5))))
);
assert_eq!(
fields.next().transpose()?,
Some(Field::new(Key::TotalDepth, Some(Value::Integer(8))))
);
assert!(fields.next().is_none());
Trait Implementations
impl Eq for Info
impl StructuralEq for Info
impl StructuralPartialEq for Info
Auto Trait Implementations
impl RefUnwindSafe for Info
impl Send for Info
impl Sync for Info
impl Unpin for Info
impl UnwindSafe for Info
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more