Struct noodles_bcf::AsyncReader[][src]

pub struct AsyncReader<R> where
    R: AsyncRead
{ /* fields omitted */ }
Expand description

An async BCF reader.

Examples

use futures::TryStreamExt;
use noodles_bcf as bcf;
use tokio::fs::File;

let mut reader = File::open("sample.bcf").await.map(bcf::AsyncReader::new)?;
reader.read_file_format().await?;
reader.read_header().await?;

let mut records = reader.records();

while let Some(record) = records.try_next().await? {
    // ...
}

Implementations

Creates an async BCF reader builder.

Examples
use noodles_bcf as bcf;
let data = [];
let builder = bcf::AsyncReader::builder(&data[..]);
let reader = builder.build();

Creates an async BCF reader.

Examples
use noodles_bcf as bcf;
let data = [];
let reader = bcf::AsyncReader::new(&data[..]);

Reads the BCF file format.

The BCF magic number is also checked.

The position of the stream is expected to be at the start.

This returns the major and minor format versions as a tuple.

Examples
use noodles_bcf as bcf;
use tokio::fs::File;
let mut reader = File::open("sample.bcf").await.map(bcf::AsyncReader::new)?;
let (major, minor) = reader.read_file_format().await?;

Reads the raw VCF header.

The position of the stream is expected to be directly after the file format.

This returns the raw VCF header as a String. It can subsequently be parsed as a noodles_vcf::Header.

Examples
use noodles_bcf as bcf;
use tokio::fs::File;

let mut reader = File::open("sample.bcf").await.map(bcf::AsyncReader::new)?;
reader.read_file_format().await?;

let header = reader.read_header().await?;

Reads a single record.

The stream is expected to be directly after the header or at the start of another record.

It is more ergonomic to read records using a stream (see Self::records), but using this method directly allows the reuse of a single Record buffer.

If successful, the record size is returned. If a record size of 0 is returned, the stream reached EOF.

use noodles_bcf as bcf;
use tokio::fs::File;

let mut reader = File::open("sample.bcf").await.map(bcf::AsyncReader::new)?;
reader.read_file_format().await?;
reader.read_header().await?;

let mut record = bcf::Record::default();
reader.read_record(&mut record).await?;

Returns an (async) stream over records starting from the current (input) stream position.

The (input) stream is expected to be directly after the header or at the start of another record.

Examples
use futures::TryStreamExt;
use noodles_bcf as bcf;
use tokio::fs::File;

let mut reader = File::open("sample.bcf").await.map(bcf::AsyncReader::new)?;
reader.read_file_format().await?;
reader.read_header().await?;

let mut records = reader.records();

while let Some(record) = records.try_next().await? {
    // ...
}

Returns the current virtual position of the underlying BGZF reader.

Examples
use noodles_bcf as bcf;
use noodles_bgzf as bgzf;

let data = Vec::new();
let reader = bcf::AsyncReader::new(&data[..]);
let virtual_position = reader.virtual_position();

assert_eq!(reader.virtual_position(), bgzf::VirtualPosition::from(0));

Seeks the underlying BGZF reader to the given virtual position.

Virtual positions typically come from an associated index file.

Examples
use noodles_bcf as bcf;
use noodles_bgzf as bgzf;

let data = [];
let mut reader = bcf::AsyncReader::new(Cursor::new(data));

let virtual_position = bgzf::VirtualPosition::default();
reader.seek(virtual_position).await?;

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.