pub fn from_reader(reader: &mut dyn BufRead) -> Result<Box<dyn FastXRead>>Expand description
Create a record reader with automatic format detection.
This function peeks at the first byte of the input to determine whether it’s FASTA or FASTQ format, then returns an appropriate record reader.
§Arguments
reader- A buffered reader positioned at the start of sequence data
§Returns
A boxed trait object implementing FastXRead (either FastARecord or FastQRecord).
§Example
use fastx::FastX::{from_reader, FastXRead};
use std::io::BufReader;
use std::fs::File;
let file = File::open("unknown_format.txt").unwrap();
let mut reader = BufReader::new(file);
let mut record = from_reader(&mut reader).unwrap();
while record.read(&mut reader).unwrap() > 0 {
println!("{}", record.id());
}