pub struct Builder { /* private fields */ }
Expand description

A VCF record builder.

Implementations§

source§

impl Builder

source

pub fn set_chromosome(self, chromosome: Chromosome) -> Self

Sets the chromosome.

Examples
use noodles_vcf::{self as vcf, record::{Chromosome, Position}};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::from(1))
    .set_reference_bases("A".parse()?)
    .build()?;

assert_eq!(record.chromosome(), &Chromosome::Name(String::from("sq0")));
source

pub fn set_position(self, position: Position) -> Self

Sets the start position.

Examples
use noodles_vcf::{self as vcf, record::Position};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::from(8))
    .set_reference_bases("A".parse()?)
    .build()?;

assert_eq!(usize::from(record.position()), 8);
source

pub fn set_ids(self, ids: Ids) -> Self

Sets a list of IDs.

Examples
use noodles_vcf::{self as vcf, record::Position};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::from(1))
    .set_ids("nd0".parse()?)
    .set_reference_bases("A".parse()?)
    .build()?;

assert_eq!(*record.ids(), "nd0".parse()?);
source

pub fn set_reference_bases(self, reference_bases: ReferenceBases) -> Self

Sets the reference bases.

Examples
use noodles_vcf::{
    self as vcf,
    record::{reference_bases::Base, Position, ReferenceBases},
};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::from(1))
    .set_reference_bases("A".parse()?)
    .build()?;

assert_eq!(
    record.reference_bases(),
    &ReferenceBases::try_from(vec![Base::A])?,
);
source

pub fn add_reference_base(self, reference_base: Base) -> Self

Adds a base to reference bases.

Examples
use noodles_vcf::{
    self as vcf,
    record::{reference_bases::Base, Position, ReferenceBases},
};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::from(1))
    .add_reference_base(Base::A)
    .build()?;

assert_eq!(
    record.reference_bases(),
    &ReferenceBases::try_from(vec![Base::A])?,
);
source

pub fn set_alternate_bases(self, alternate_bases: AlternateBases) -> Self

Sets the alternate bases.

Examples
use noodles_vcf::{
    self as vcf,
    record::{alternate_bases::Allele, reference_bases::Base, AlternateBases, Position},
};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::from(1))
    .set_reference_bases("A".parse()?)
    .set_alternate_bases("C".parse()?)
    .build()?;

assert_eq!(
    record.alternate_bases(),
    &AlternateBases::from(vec![Allele::Bases(vec![Base::C])]),
);
source

pub fn set_quality_score(self, quality_score: QualityScore) -> Self

Sets the quality score.

Examples
use noodles_vcf::{self as vcf, record::{Position, QualityScore}};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::from(1))
    .set_reference_bases("A".parse()?)
    .set_quality_score(QualityScore::try_from(13.0)?)
    .build()?;

assert_eq!(record.quality_score().map(f32::from), Some(13.0));
source

pub fn set_filters(self, filters: Filters) -> Self

Sets the filters.

Examples
use noodles_vcf::{self as vcf, record::{Filters, Position}};

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::from(1))
    .set_reference_bases("A".parse()?)
    .set_filters(Filters::Pass)
    .build()?;

assert_eq!(record.filters(), Some(&Filters::Pass));
source

pub fn set_info(self, info: Info) -> Self

Sets additional information.

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

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::from(1))
    .set_reference_bases("A".parse()?)
    .set_alternate_bases("C".parse()?)
    .set_info("NS=3;AF=0.5".parse()?)
    .build()?;

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

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

pub fn set_genotypes(self, genotypes: Genotypes) -> Self

Sets the list of genotypes.

Examples
use noodles_vcf::{
    self as vcf,
    record::{genotypes::sample::Value, Genotypes, Position},
};

let keys = "GT:GQ".parse()?;
let genotypes = Genotypes::new(
    keys,
    vec![vec![Some(Value::from("0|0")), Some(Value::from(13))]],
);

let record = vcf::Record::builder()
    .set_chromosome("sq0".parse()?)
    .set_position(Position::from(1))
    .set_reference_bases("A".parse()?)
    .set_genotypes(genotypes.clone())
    .build()?;

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

pub fn build(self) -> Result<Record, BuildError>

Builds a VCF record.

Examples
use noodles_vcf as vcf;
let record = vcf::Record::builder().build();

Trait Implementations§

source§

impl Debug for Builder

source§

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

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

impl Default for Builder

source§

fn default() -> Builder

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

impl PartialEq<Builder> for Builder

source§

fn eq(&self, other: &Builder) -> 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 StructuralPartialEq for Builder

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more