Struct noodles_vcf::record::info::Info [−][src]
pub struct Info(_);
Expand description
VCF record information fields (INFO
).
Implementations
Parses raw VCF record info.
Returns the number of info fields.
Examples
use noodles_vcf::record::Info;
let info = Info::default();
assert_eq!(info.len(), 0);
Returns whether there are any info fields.
Examples
use noodles_vcf::record::Info;
let info = Info::default();
assert!(info.is_empty());
Returns a reference to the field with the given key.
Examples
use noodles_vcf::record::{info::{field::{Key, Value}, Field}, Info};
let ns = Field::new(Key::SamplesWithDataCount, Some(Value::Integer(2)));
let dp = Field::new(Key::TotalDepth, Some(Value::Integer(13)));
let info = Info::try_from(vec![ns, dp.clone()])?;
assert_eq!(info.get(&Key::TotalDepth), Some(&dp));
assert!(info.get(&Key::AlleleFrequencies).is_none());
Returns a mutable reference to the field with the given key.
Examples
use noodles_vcf::record::{info::{field::{Key, Value}, Field}, Info};
let ns = Field::new(Key::SamplesWithDataCount, Some(Value::Integer(2)));
let dp = Field::new(Key::TotalDepth, Some(Value::Integer(13)));
let mut info = Info::try_from(vec![ns, dp])?;
if let Some(dp) = info.get_mut(&Key::TotalDepth) {
*dp.value_mut() = Some(Value::Integer(8));
}
assert_eq!(
info.get(&Key::TotalDepth).map(|field| field.value()),
Some(Some(&Value::Integer(8)))
);
Returns a reference to the field at the given index.
Examples
use noodles_vcf::record::{info::{field::{Key, Value}, Field}, Info};
let ns = Field::new(Key::SamplesWithDataCount, Some(Value::Integer(2)));
let dp = Field::new(Key::TotalDepth, Some(Value::Integer(13)));
let info = Info::try_from(vec![ns, dp.clone()])?;
assert_eq!(info.get_index(1), Some(&dp));
assert!(info.get_index(5).is_none());
Returns a mutable reference to the field at the given index.
Examples
use noodles_vcf::record::{info::{field::{Key, Value}, Field}, Info};
let ns = Field::new(Key::SamplesWithDataCount, Some(Value::Integer(2)));
let dp = Field::new(Key::TotalDepth, Some(Value::Integer(13)));
let mut info = Info::try_from(vec![ns, dp])?;
if let Some(dp) = info.get_index_mut(1) {
*dp.value_mut() = Some(Value::Integer(8));
}
assert_eq!(
info.get_index(1).map(|field| field.value()),
Some(Some(&Value::Integer(8)))
);
Inserts a field into the info.
This uses the field key as the key and field as the value.
If the key already exists in the map, the existing field is replaced by the new one, and the existing field is returned.
Examples
use noodles_vcf::record::{info::{field::{Key, Value}, Field}, Info};
let ns = Field::new(Key::SamplesWithDataCount, Some(Value::Integer(2)));
let mut info = Info::try_from(vec![ns])?;
assert_eq!(info.len(), 1);
let dp = Field::new(Key::TotalDepth, Some(Value::Integer(13)));
info.insert(dp.clone());
assert_eq!(info.len(), 2);
assert_eq!(info.get(&Key::TotalDepth), Some(&dp));
Returns an iterator over all keys.
Examples
use noodles_vcf::record::{info::{field::{Key, Value}, Field}, Info};
let ns = Field::new(Key::SamplesWithDataCount, Some(Value::Integer(2)));
let dp = Field::new(Key::TotalDepth, Some(Value::Integer(13)));
let info = Info::try_from(vec![ns, dp.clone()])?;
let mut keys = info.keys();
assert_eq!(keys.next(), Some(&Key::SamplesWithDataCount));
assert_eq!(keys.next(), Some(&Key::TotalDepth));
assert!(keys.next().is_none());
Returns an interator over all fields.
Examples
use noodles_vcf::record::{info::{field::{Key, Value}, Field}, Info};
let ns = Field::new(Key::SamplesWithDataCount, Some(Value::Integer(2)));
let dp = Field::new(Key::TotalDepth, Some(Value::Integer(13)));
let info = Info::try_from(vec![ns.clone(), dp.clone()])?;
let mut values = info.values();
assert_eq!(values.next(), Some(&ns));
assert_eq!(values.next(), Some(&dp));
assert!(values.next().is_none());
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Info
impl UnwindSafe for Info
Blanket Implementations
Mutably borrows from an owned value. Read more