Struct noodles_bcf::Writer
source · [−]pub struct Writer<W> { /* private fields */ }
Expand description
A BCF writer.
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_bcf as bcf;
let writer = bcf::Writer::from(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_bcf as bcf;
let mut writer = bcf::Writer::from(Vec::new());
assert!(writer.get_mut().is_empty());
sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Returns the underlying writer.
Examples
use noodles_bcf as bcf;
let mut writer = bcf::Writer::from(Vec::new());
assert!(writer.into_inner().is_empty());
sourcepub fn write_file_format(&mut self) -> Result<()>
pub fn write_file_format(&mut self) -> Result<()>
Writes a BCF file format.
Examples
use noodles_bcf as bcf;
let mut writer = bcf::Writer::new(Vec::new());
writer.write_file_format()?;
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_bcf as bcf;
use noodles_vcf as vcf;
let mut writer = bcf::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 record.
Examples
use noodles_bcf as bcf;
let mut writer = bcf::Writer::new(Vec::new());
let record = bcf::Record::default();
writer.write_record(&record)?;
sourcepub fn write_vcf_record(
&mut self,
header: &Header,
string_maps: &StringMaps,
record: &Record
) -> Result<()>
pub fn write_vcf_record(
&mut self,
header: &Header,
string_maps: &StringMaps,
record: &Record
) -> Result<()>
Writes a VCF record.
Examples
use noodles_bcf::{self as bcf, header::StringMaps};
use noodles_vcf::{self as vcf, header::Contig, record::Position};
let mut writer = bcf::Writer::new(Vec::new());
let header = vcf::Header::builder()
.add_contig(Contig::new("sq0"))
.build();
writer.write_header(&header)?;
let string_maps = StringMaps::from(&header);
let record = vcf::Record::builder()
.set_chromosome("sq0".parse()?)
.set_position(Position::try_from(8)?)
.set_reference_bases("A".parse()?)
.build()?;
writer.write_vcf_record(&header, &string_maps, &record)?;
sourceimpl<W> Writer<Writer<W>> where
W: Write,
impl<W> Writer<Writer<W>> where
W: Write,
sourcepub fn new(writer: W) -> Self
pub fn new(writer: W) -> Self
Creates a BCF writer with a default compression level.
The given stream is wrapped in a BGZF encoder.
Examples
use noodles_bcf as bcf;
let writer = bcf::Writer::new(Vec::new());
sourcepub fn try_finish(&mut self) -> Result<()>
pub fn try_finish(&mut self) -> Result<()>
Attempts to finish the output stream.
This is typically only manually called if the underlying stream is needed before the writer is dropped.
Examples
use noodles_bcf as bcf;
let mut writer = bcf::Writer::new(Vec::new());
writer.try_finish()?;
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