pub struct Reader { /* private fields */ }
Expand description
A Fasta reader.
Implementations§
Source§impl Reader
impl Reader
Sourcepub fn fetch_seq<N: AsRef<str>>(
&self,
name: N,
begin: usize,
end: usize,
) -> Result<&[u8]>
pub fn fetch_seq<N: AsRef<str>>( &self, name: N, begin: usize, end: usize, ) -> Result<&[u8]>
Fetch the sequence as a byte array.
§Arguments
name
- the name of the template sequence (e.g., “chr1”)begin
- the offset within the template sequence (starting with 0)end
- the end position to return (if smaller thanbegin
, the behavior is undefined).
Sourcepub fn fetch_seq_string<N: AsRef<str>>(
&self,
name: N,
begin: usize,
end: usize,
) -> Result<String>
pub fn fetch_seq_string<N: AsRef<str>>( &self, name: N, begin: usize, end: usize, ) -> Result<String>
Fetches the sequence and returns it as string.
§Arguments
name
- the name of the template sequence (e.g., “chr1”)begin
- the offset within the template sequence (starting with 0)end
- the end position to return (if smaller thanbegin
, the behavior is undefined).
Sourcepub fn fetch_seq_len<N: AsRef<str>>(&self, name: N) -> u64
pub fn fetch_seq_len<N: AsRef<str>>(&self, name: N) -> u64
Fetches the length of the given sequence name.
§Arguments
name
- the name of the template sequence (e.g., “chr1”)
Sourcepub fn seq_names(&self) -> Result<Vec<String>>
pub fn seq_names(&self) -> Result<Vec<String>>
Returns a Result<Vector
§Errors
errors::Error::FaidxBadSeqName
- missing sequence name for sequence id.
If thrown, the index is malformed, and the number of sequences in the index does not match the number of sequence names available.
use rust_htslib::faidx::build;
let path = std::path::PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"),"/test/test_cram.fa"));
build(&path).expect("Failed to build fasta index");
let reader = rust_htslib::faidx::Reader::from_path(path).expect("Failed to open faidx");
assert_eq!(reader.seq_names(), Ok(vec!["chr1".to_string(), "chr2".to_string(), "chr3".to_string()]));
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Reader
impl RefUnwindSafe for Reader
impl !Send for Reader
impl !Sync for Reader
impl Unpin for Reader
impl UnwindSafe for Reader
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