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

A VCF record builder.

Implementations

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")));

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);

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()?);

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])?,
);

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])?,
);

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])]),
);

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));

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));

Sets additional information.

Examples
use noodles_vcf::{
    self as vcf,
    header::info::Key,
    record::{info::{field::Value, Field}, 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 = Info::try_from(vec![
    Field::new(Key::SamplesWithDataCount, Some(Value::Integer(3))),
    Field::new(Key::AlleleFrequencies, Some(Value::FloatArray(vec![Some(0.5)]))),
])?;

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

Sets the list of genotypes.

Examples
use noodles_vcf::{
    self as vcf,
    header::format::Key,
    record::{
        genotypes::{genotype::{field::Value, Field}, Genotype},
        Genotypes, Position,
    },
};

let keys = "GT:GQ".parse()?;
let genotypes = Genotypes::new(
    keys,
    vec![Genotype::try_from(vec![
        Field::new(Key::Genotype, Some(Value::String(String::from("0|0")))),
        Field::new(Key::ConditionalGenotypeQuality, Some(Value::Integer(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);

Builds a VCF record.

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

Trait Implementations

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more