Struct noodles::vcf::Writer[][src]

pub struct Writer<W> { /* fields omitted */ }
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());

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

Performs the conversion.

Performs the conversion.

Should always be Self

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.