rust_htslib::bam

Struct Writer

Source
pub struct Writer { /* private fields */ }
Expand description

A BAM writer.

Implementations§

Source§

impl Writer

Source

pub fn from_path<P: AsRef<Path>>( path: P, header: &Header, format: Format, ) -> Result<Self>

Create a new SAM/BAM/CRAM file.

§Arguments
  • path - the path.
  • header - header definition to use
  • format - the format to use (SAM/BAM/CRAM)
Source

pub fn from_stdout(header: &Header, format: Format) -> Result<Self>

Create a new SAM/BAM/CRAM file at STDOUT.

§Arguments
  • header - header definition to use
  • format - the format to use (SAM/BAM/CRAM)
Source

pub fn set_threads(&mut self, n_threads: usize) -> Result<()>

Activate multi-threaded BAM write support in htslib. This should permit faster writing of large BAM files.

§Arguments
  • n_threads - number of extra background writer threads to use, must be > 0.
Source

pub fn set_thread_pool(&mut self, tpool: &ThreadPool) -> Result<()>

Use a shared thread-pool for writing. This permits controlling the total thread count when multiple readers and writers are working simultaneously. A thread pool can be created with crate::tpool::ThreadPool::new(n_threads)

§Arguments
  • tpool - thread pool to use for compression work.
Source

pub fn write(&mut self, record: &Record) -> Result<()>

Write record to BAM.

§Arguments
  • record - the record to write
Source

pub fn header(&self) -> &HeaderView

Return the header.

Source

pub fn set_reference<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Set the reference path for reading CRAM files.

§Arguments
  • path - path to the FASTA reference
Source

pub fn set_compression_level( &mut self, compression_level: CompressionLevel, ) -> Result<()>

Set the compression level for writing BAM/CRAM files.

§Arguments
  • compression_level - CompressionLevel enum variant

Trait Implementations§

Source§

impl Debug for Writer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Writer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Writer

Auto Trait Implementations§

§

impl Freeze for Writer

§

impl !RefUnwindSafe for Writer

§

impl !Sync for Writer

§

impl Unpin for Writer

§

impl !UnwindSafe for Writer

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T