Skip to content

Commit 6439569

Browse files
Allow to clone the header. Minor formatting.
1 parent 93aabfc commit 6439569

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/bam/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Header {
2525
// header which samtools (<=1.6) will complain
2626
// about
2727
while let Some(&last_char) = record.last() {
28-
if last_char==b'\n' {
28+
if last_char == b'\n' {
2929
record.pop();
3030
} else {
3131
break;

src/bam/mod.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl Drop for Reader {
171171

172172
pub struct IndexedReader {
173173
bgzf: *mut htslib::Struct_BGZF,
174-
pub header: HeaderView,
174+
header: HeaderView,
175175
idx: *mut htslib::hts_idx_t,
176176
itr: Option<*mut htslib:: hts_itr_t>,
177177
}
@@ -219,7 +219,7 @@ impl IndexedReader {
219219
if idx.is_null() {
220220
Err(IndexedReaderError::InvalidIndex)
221221
} else {
222-
Ok(IndexedReader { bgzf: bgzf, header : HeaderView::new(header), idx: idx, itr: None })
222+
Ok(IndexedReader { bgzf: bgzf, header: HeaderView::new(header), idx: idx, itr: None })
223223
}
224224
}
225225

@@ -660,6 +660,17 @@ impl HeaderView {
660660
}
661661
}
662662

663+
664+
impl Clone for HeaderView {
665+
fn clone(&self) -> Self {
666+
HeaderView {
667+
inner: unsafe { htslib::bam_hdr_dup(self.inner) },
668+
owned: true
669+
}
670+
}
671+
}
672+
673+
663674
impl Drop for HeaderView {
664675
fn drop(&mut self) {
665676
if self.owned {
@@ -668,6 +679,7 @@ impl Drop for HeaderView {
668679
}
669680
}
670681

682+
671683
#[cfg(test)]
672684
mod tests {
673685
extern crate tempdir;

0 commit comments

Comments
 (0)