-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Description
Hello,
Thank you for this awesome crate.
I ran into an issue yesterday where I want to fetch an entire region from bed.gz file with a tabix file. As I always want to fetch the entire reference I set the end to be u64::MAX, however this creates a "Failed to fetch region" error.
use rust_htslib::tbx::{Reader};
let mut reader = Reader::from_path("sample.bed.gz");
const UNREASONABLE_MAX: u64 = i64::MAX as u64;
reader
.fetch(tid, 0, UNREASONABLE_MAX)
.map_err(|e| anyhow!("Failed to fetch contig '{}': {}", contig, e.to_string()))?;
The error arises from:
/// Fetch region given by numeric sequence number and 0-based begin and end position.
pub fn fetch(&mut self, tid: u64, start: u64, end: u64) -> Result<()> {
self.tid = tid as i64; <- HERE
self.start = start as i64; <- HERE
self.end = end as i64; <- HERE
if let Some(itr) = self.itr {
unsafe {
htslib::hts_itr_destroy(itr);
}
}
let itr = unsafe {
htslib::hts_itr_query(
(*self.tbx).idx,
tid as i32,
start as i64,
end as i64,
Some(htslib::tbx_readrec),
)
};
if itr.is_null() {
self.itr = None;
Err(Error::Fetch)
} else {
self.itr = Some(itr);
Ok(())
}
}
Is there a particular reason why the arguments are u64 but converted to i64 right after? In my case I could simply do i64::MAX as u64 and the error would be resolved.
Also do let me know if I can query more efficiently.
Kind regards, Sebastian
Metadata
Metadata
Assignees
Labels
No labels