Skip to content

Commit 43f3412

Browse files
authored
Add with_info to BigBedRead and inner reader unwrapping methods (#80)
* Add with_info to BigBedRead and inner reader unwrapping methods * Remove get_ref and get_mut methods
1 parent 1dcd7a6 commit 43f3412

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

bigtools/src/bbi/bigbedread.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ impl<R> BigBedRead<R> {
146146
pub fn chroms(&self) -> &[ChromInfo] {
147147
&self.info.chrom_info
148148
}
149+
150+
/// Consumes this `BigWigRead`, returning the underlying reader.
151+
pub fn into_inner(self) -> R {
152+
self.read
153+
}
149154
}
150155

151156
impl BigBedRead<ReopenableFile> {
@@ -190,6 +195,11 @@ impl<R: BBIFileRead> BigBedRead<R> {
190195
Ok(BigBedRead { info, read })
191196
}
192197

198+
/// Does *not* check if the passed `R` matches the provided info (including if the `R` is a bigBed at all!)
199+
pub fn with_info(info: BBIFileInfo, read: R) -> Self {
200+
BigBedRead { info, read }
201+
}
202+
193203
/// Reads the autosql from this bigBed
194204
pub fn autosql(&mut self) -> Result<Option<String>, BBIReadError> {
195205
let auto_sql_offset = self.info.header.auto_sql_offset;

bigtools/src/bbi/bigwigread.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ impl<R> BigWigRead<R> {
191191
pub fn chroms(&self) -> &[ChromInfo] {
192192
&self.info.chrom_info
193193
}
194+
195+
/// Consumes this `BigWigRead`, returning the underlying reader.
196+
pub fn into_inner(self) -> R {
197+
self.read
198+
}
194199
}
195200

196201
impl BigWigRead<ReopenableFile> {

0 commit comments

Comments
 (0)