Struct noodles_vcf::variant::record_buf::RecordBuf

source ·
pub struct RecordBuf { /* private fields */ }
Expand description

A variant record buffer.

Implementations§

source§

impl RecordBuf

source

pub fn try_from_variant_record<R>(header: &Header, record: &R) -> Result<Self>
where R: Record,

Converts a variant record to a buffer.

source§

impl RecordBuf

source

pub fn builder() -> Builder

Returns a builder to create a record from each of its fields.

§Examples
use noodles_vcf as vcf;
let builder = vcf::variant::RecordBuf::builder();
source

pub fn reference_sequence_name(&self) -> &str

Returns the reference sequence name.

§Examples
use noodles_vcf as vcf;

let record = vcf::variant::RecordBuf::builder()
    .set_reference_sequence_name("sq0")
    .build();

assert_eq!(record.reference_sequence_name(), "sq0");
source

pub fn reference_sequence_name_mut(&mut self) -> &mut String

Returns a mutable reference to the reference sequence name.

§Examples
use noodles_vcf as vcf;

let mut record = vcf::variant::RecordBuf::builder()
    .set_reference_sequence_name("sq0")
    .build();

*record.reference_sequence_name_mut() = String::from("sq1");

assert_eq!(record.reference_sequence_name(), "sq1");
source

pub fn variant_start(&self) -> Option<Position>

Returns the variant start position.

If the record represents the start of a telomeric breakend, this returns None.

§Examples
use noodles_core::Position;
use noodles_vcf as vcf;

let record = vcf::variant::RecordBuf::builder()
    .set_variant_start(Position::MIN)
    .build();

assert_eq!(record.variant_start(), Some(Position::MIN));
source

pub fn variant_start_mut(&mut self) -> &mut Option<Position>

Returns a mutable reference to the variant start position.

If the record represents the start of a telomeric breakend, this returns None.

§Examples
use noodles_core::Position;
use noodles_vcf as vcf;

let mut record = vcf::variant::RecordBuf::default();
*record.variant_start_mut() = Some(Position::MIN);
assert_eq!(record.variant_start(), Some(Position::MIN));
source

pub fn ids(&self) -> &Ids

Returns a list of IDs of the record.

§Examples
use noodles_vcf::{self as vcf, variant::record_buf::Ids};

let ids: Ids = [String::from("nd0")].into_iter().collect();

let record = vcf::variant::RecordBuf::builder()
    .set_ids(ids.clone())
    .build();

assert_eq!(record.ids(), &ids);
source

pub fn ids_mut(&mut self) -> &mut Ids

Returns a mutable reference to the IDs.

§Examples
use noodles_vcf::{self as vcf, variant::record_buf::Ids};

let mut record = vcf::variant::RecordBuf::default();

let ids: Ids = [String::from("nd0")].into_iter().collect();
*record.ids_mut() = ids.clone();

assert_eq!(record.ids(), &ids);
source

pub fn reference_bases(&self) -> &str

Returns the reference bases of the record.

§Examples
use noodles_vcf as vcf;

let record = vcf::variant::RecordBuf::builder()
    .set_reference_bases("A")
    .build();

assert_eq!(record.reference_bases(), "A");
source

pub fn reference_bases_mut(&mut self) -> &mut String

Returns a mutable reference to the reference bases of the record.

§Examples
use noodles_vcf as vcf;

let mut record = vcf::variant::RecordBuf::builder()
    .set_reference_bases("A")
    .build();

*record.reference_bases_mut() = String::from("T");

assert_eq!(record.reference_bases(), "T");
source

pub fn alternate_bases(&self) -> &AlternateBases

Returns the alternate bases of the record.

§Examples
use noodles_vcf::{self as vcf, variant::record_buf::AlternateBases};

let alternate_bases = AlternateBases::from(vec![String::from("C")]);

let record = vcf::variant::RecordBuf::builder()
    .set_alternate_bases(alternate_bases.clone())
    .build();

assert_eq!(record.alternate_bases(), &alternate_bases);
source

pub fn alternate_bases_mut(&mut self) -> &mut AlternateBases

Returns a mutable reference to the alternate bases of the record.

§Examples
use noodles_vcf::{self as vcf, variant::record_buf::AlternateBases};

let mut record = vcf::variant::RecordBuf::builder()
    .set_reference_bases("A")
    .build();

let alternate_bases = AlternateBases::from(vec![String::from("C")]);
*record.alternate_bases_mut() = alternate_bases.clone();

assert_eq!(record.alternate_bases(), &alternate_bases);
source

pub fn quality_score(&self) -> Option<f32>

Returns the quality score of the record.

§Examples
use noodles_vcf as vcf;

let record = vcf::variant::RecordBuf::builder()
    .set_quality_score(13.0)
    .build();

assert_eq!(record.quality_score(), Some(13.0));
source

pub fn quality_score_mut(&mut self) -> &mut Option<f32>

Returns a mutable reference to the quality score.

§Examples
use noodles_vcf as vcf;

let mut record = vcf::variant::RecordBuf::default();
*record.quality_score_mut() = Some(13.0);
assert_eq!(record.quality_score(), Some(13.0));
source

pub fn filters(&self) -> &Filters

Returns the filters of the record.

The filters can either be pass (PASS), a list of filter names that caused the record to fail, (e.g., q10), or missing (.).

§Examples
use noodles_vcf::{self as vcf, variant::record_buf::Filters};

let record = vcf::variant::RecordBuf::builder()
    .set_filters(Filters::pass())
    .build();

assert!(record.filters().is_pass());
source

pub fn filters_mut(&mut self) -> &mut Filters

Returns a mutable reference to the filters.

§Examples
use noodles_vcf::{self as vcf, variant::record_buf::Filters};

let mut record = vcf::variant::RecordBuf::default();
*record.filters_mut() = Filters::pass();
assert!(record.filters().is_pass());
source

pub fn info(&self) -> &Info

Returns the addition information of the record.

§Examples
use noodles_vcf::{
    self as vcf,
    variant::{
        record::info::field::key,
        record_buf::{info::field::Value, Info},
    },
};

let info: Info = [
    (String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::from(3))),
    (String::from(key::ALLELE_FREQUENCIES), Some(Value::from(vec![Some(0.5)]))),
]
.into_iter()
.collect();

let record = vcf::variant::RecordBuf::builder()
    .set_info(info.clone())
    .build();

assert_eq!(record.info(), &info);
source

pub fn info_mut(&mut self) -> &mut Info

Returns a mutable reference to the additional info fields.

§Examples
use noodles_vcf::{
    self as vcf,
    variant::{
        record::info::field::key,
        record_buf::{info::field::Value, Info},
    }
};

let info: Info = [
    (String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::from(3))),
    (String::from(key::ALLELE_FREQUENCIES), Some(Value::from(vec![Some(0.5)]))),
]
.into_iter()
.collect();

let mut record = vcf::variant::RecordBuf::builder()
    .set_info(info)
    .build();

record.info_mut().insert(String::from(key::TOTAL_DEPTH), Some(Value::Integer(13)));

let expected = [
    (String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::Integer(3))),
    (String::from(key::ALLELE_FREQUENCIES), Some(Value::from(vec![Some(0.5)]))),
    (String::from(key::TOTAL_DEPTH), Some(Value::Integer(13))),
]
.into_iter()
.collect();

assert_eq!(record.info(), &expected);
source

pub fn format(&self) -> &Keys

Returns the format of the genotypes of the record.

§Examples
use noodles_vcf::{
    self as vcf,
    variant::{
        record::samples::keys::key,
        record_buf::{samples::{sample::Value, Keys}, Samples},
    },
};

let keys: Keys = [
    String::from(key::GENOTYPE),
    String::from(key::CONDITIONAL_GENOTYPE_QUALITY),
].into_iter().collect();
let samples = Samples::new(
    keys.clone(),
    vec![vec![Some(Value::from("0|0")), Some(Value::from(13))]],
);

let record = vcf::variant::RecordBuf::builder()
    .set_samples(samples)
    .build();

assert_eq!(record.format(), &keys);
source

pub fn samples(&self) -> &Samples

Returns the genotypes of the record.

§Examples
use noodles_vcf::{
    self as vcf,
    variant::{
        record::samples::keys::key,
        record_buf::{samples::sample::Value, Samples},
    },
};

let keys = [
    String::from(key::GENOTYPE),
    String::from(key::CONDITIONAL_GENOTYPE_QUALITY),
].into_iter().collect();
let samples = Samples::new(
    keys,
    vec![vec![Some(Value::from("0|0")), Some(Value::from(13))]],
);

let record = vcf::variant::RecordBuf::builder()
    .set_samples(samples.clone())
    .build();

assert_eq!(record.samples(), &samples);
source

pub fn samples_mut(&mut self) -> &mut Samples

Returns a mutable reference to the genotypes of the record.

§Examples
use noodles_vcf::{
    self as vcf,
    variant::{
        record::samples::keys::key,
        record_buf::{samples::sample::Value, Samples},
    },
};

let mut record = vcf::variant::RecordBuf::default();

let keys = [
    String::from(key::GENOTYPE),
    String::from(key::CONDITIONAL_GENOTYPE_QUALITY),
].into_iter().collect();
let samples = Samples::new(
    keys,
    vec![vec![Some(Value::from("0|0")), Some(Value::from(13))]],
);

*record.samples_mut() = samples.clone();

assert_eq!(record.samples(), &samples);

Trait Implementations§

source§

impl Clone for RecordBuf

source§

fn clone(&self) -> RecordBuf

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RecordBuf

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for RecordBuf

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq for RecordBuf

source§

fn eq(&self, other: &RecordBuf) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Record for RecordBuf

source§

fn reference_sequence_name<'a, 'h: 'a>( &'a self, _: &'h Header, ) -> Result<&'a str>

Returns the reference sequence name.
source§

fn variant_start(&self) -> Option<Result<Position>>

Returns the variant start position.
source§

fn ids(&self) -> Box<dyn Ids + '_>

Returns the IDs.
source§

fn reference_bases(&self) -> Box<dyn ReferenceBases + '_>

Returns the reference bases.
source§

fn alternate_bases(&self) -> Box<dyn AlternateBases + '_>

Returns the alternate bases.
source§

fn quality_score(&self) -> Option<Result<f32>>

Returns the quality scores.
source§

fn filters(&self) -> Box<dyn Filters + '_>

Returns the filters.
source§

fn info(&self) -> Box<dyn Info + '_>

Return the info fields.
source§

fn samples(&self) -> Result<Box<dyn Samples + '_>>

Returns the samples.
source§

fn variant_span(&self, header: &Header) -> Result<usize>

Returns the variant span.
source§

fn variant_end(&self, header: &Header) -> Result<Position>

Returns or calculates the variant end position. Read more
source§

impl StructuralPartialEq for RecordBuf

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.