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