Struct consprob_trained::Writer
source · pub struct Writer<W>where
W: Write,{ /* private fields */ }
Expand description
A Fasta writer.
Implementations§
source§impl<W> Writer<W>where
W: Write,
impl<W> Writer<W>where W: Write,
sourcepub fn with_capacity(capacity: usize, writer: W) -> Writer<W>
pub fn with_capacity(capacity: usize, writer: W) -> Writer<W>
Create a new Fasta writer with a capacity of write buffer
sourcepub fn from_bufwriter(bufwriter: BufWriter<W>) -> Writer<W>
pub fn from_bufwriter(bufwriter: BufWriter<W>) -> Writer<W>
Create a new Fasta writer with a given BufWriter
sourcepub fn write_record(&mut self, record: &Record) -> Result<(), Error>
pub fn write_record(&mut self, record: &Record) -> Result<(), Error>
Directly write a fasta::Record
.
Errors
If there is an issue writing to the Writer
.
Examples
use bio::io::fasta::{Record, Writer};
use std::fs;
use std::io;
use std::path::Path;
let path = Path::new("test.fa");
let file = fs::File::create(path).unwrap();
{
let handle = io::BufWriter::new(file);
let mut writer = Writer::new(handle);
let record = Record::with_attrs("id", Some("desc"), b"ACGT");
let write_result = writer.write_record(&record);
assert!(write_result.is_ok());
}
let actual = fs::read_to_string(path).unwrap();
let expected = ">id desc\nACGT\n";
assert!(fs::remove_file(path).is_ok());
assert_eq!(actual, expected)
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.