pub struct Writer<W> { /* private fields */ }
Expand description

A VCF writer.

Examples

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

let mut writer = vcf::Writer::new(Vec::new());

let header = vcf::Header::builder()
    .add_contig(Contig::new("sq0"))
    .build();

writer.write_header(&header)?;

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

writer.write_record(&record);

let expected = b"##fileformat=VCFv4.3
##contig=<ID=sq0>
#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO
sq0\t1\t.\tA\t.\t.\t.\t.
";

assert_eq!(&writer.get_ref()[..], &expected[..]);

Implementations

Creates a VCF writer.

Examples
use noodles_vcf as vcf;
let writer = vcf::Writer::new(Vec::new());

Returns a reference to the underlying writer.

Examples
use noodles_vcf as vcf;
let writer = vcf::Writer::new(Vec::new());
assert!(writer.get_ref().is_empty());

Returns a mutable reference to the underlying writer.

Examples
use noodles_vcf as vcf;
let mut writer = vcf::Writer::new(Vec::new());
assert!(writer.get_mut().is_empty());

Unwraps and returns the underlying writer.

Examples
use noodles_vcf as vcf;
let writer = vcf::Writer::new(Vec::new());
assert!(writer.into_inner().is_empty());

Writes a VCF header.

Examples
use noodles_vcf as vcf;

let mut writer = vcf::Writer::new(Vec::new());

let header = vcf::Header::default();
writer.write_header(&header)?;

Writes a VCF record.

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

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

let mut writer = vcf::Writer::new(Vec::new());
writer.write_record(&record)?;

Trait Implementations

Formats the value using the given formatter. 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