Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Index for bam::IndexedReader #387

Merged
merged 20 commits into from
May 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clippy lints
  • Loading branch information
tedil committed May 2, 2023
commit 5d16863daeaaa3d025dc3937472c9689f40e9327
19 changes: 5 additions & 14 deletions src/bam/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,12 +706,7 @@ impl IndexedReader {
match tid {
Some(tid) => {
//'large position' spec says target len must will fit into an i64.
let len: i64 = self
.header
.target_len(tid as u32)
.unwrap()
.try_into()
.unwrap();
let len: i64 = self.header.target_len(tid).unwrap().try_into().unwrap();
self._fetch_by_coord_tuple(tid as i32, 0, len)
}
None => self._fetch_by_str(s),
Expand All @@ -726,9 +721,7 @@ impl IndexedReader {
if let Some(itr) = self.itr {
unsafe { htslib::hts_itr_destroy(itr) }
}
let itr = unsafe {
htslib::sam_itr_queryi(self.index().inner_ptr(), tid as i32, beg as i64, end as i64)
};
let itr = unsafe { htslib::sam_itr_queryi(self.index().inner_ptr(), tid, beg, end) };
if itr.is_null() {
self.itr = None;
Err(Error::Fetch)
Expand Down Expand Up @@ -855,11 +848,9 @@ impl IndexView {

impl Drop for IndexView {
fn drop(&mut self) {
unsafe {
if self.owned {
unsafe {
htslib::hts_idx_destroy(self.inner);
}
if self.owned {
unsafe {
htslib::hts_idx_destroy(self.inner);
}
}
}
Expand Down