Struct noodles_vcf::Writer
source · [−]pub struct Writer<W> { /* private fields */ }
Expand description
A VCF writer.
Examples
use noodles_vcf::{
self as vcf,
header::record::value::{map::Contig, Map},
record::Position,
};
let mut writer = vcf::Writer::new(Vec::new());
let header = vcf::Header::builder()
.add_contig(Map::<Contig>::new("sq0".parse()?))
.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
sourceimpl<W> Writer<W> where
W: Write,
impl<W> Writer<W> where
W: Write,
sourcepub fn get_ref(&self) -> &W
pub fn get_ref(&self) -> &W
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());
sourcepub fn get_mut(&mut self) -> &mut W
pub fn get_mut(&mut self) -> &mut W
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());
sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
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());
sourcepub fn write_header(&mut self, header: &Header) -> Result<()>
pub fn write_header(&mut self, header: &Header) -> Result<()>
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)?;
sourcepub fn write_record(&mut self, record: &Record) -> Result<()>
pub fn write_record(&mut self, record: &Record) -> Result<()>
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
Auto Trait Implementations
impl<W> RefUnwindSafe for Writer<W> where
W: RefUnwindSafe,
impl<W> Send for Writer<W> where
W: Send,
impl<W> Sync for Writer<W> where
W: Sync,
impl<W> Unpin for Writer<W> where
W: Unpin,
impl<W> UnwindSafe for Writer<W> where
W: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more