informationsea / bgzip-rs Goto Github PK
View Code? Open in Web Editor NEWbgzip support for Rust
Home Page: https://crates.io/crates/bgzip
License: MIT License
bgzip support for Rust
Home Page: https://crates.io/crates/bgzip
License: MIT License
Really nice crate!! I was playing around with some bgzip implementations and ran into your crate. It's really nice. I was getting some random 'Prepare' in my output stream, and I think (?) this is from an uncommented println making it into the crate. I see it's commented out in the source here. Thanks again!
Hello!
Interesting looking library.
I'm trying to read a header from a bgzip file. Also new to rust. Any help would be appreciated.
fn load_header(infile: PathBuf) -> Result<(), bgzip::BGZFError> {
use bgzip::header;
let f = fs::File::open(&infile)?;
let mut reader = io::BufReader::new(f)
let header = header::BGZFHeader::from_reader(&mut reader)?;
// ...
}
cargo build/rustc alerts me that the from_reader function is private, but its declared with pub(crate).
I understand this makes the function accessible from within the crate. But I'd like to read a header on my own!
Is there another way to do this with the BGZFReader?
Hi @informationsea,
failure crate is deprecated and unmaintained as pointed out by RUSTSEC. Can you please update the crate to rather use anyhow
or thiserror
? I can also fix that for you if you are too busy.
Waiting for your feedback.
I'm getting panics such as these, both for versions 0.1.0 and 0.2.0:
thread 'main' panicked at 'internal error: entered unreachable code', /home/oliverr/.cargo/registry/src/github.com-1ecc6299db9ec823/bgzip-0.2.0/src/read.rs:130:9
stack backtrace:
0: rust_begin_unwind
at /rustc/88f19c6dab716c6281af7602e30f413e809c5974/library/std/src/panicking.rs:493:5
1: core::panicking::panic_fmt
at /rustc/88f19c6dab716c6281af7602e30f413e809c5974/library/core/src/panicking.rs:92:14
2: core::panicking::panic
at /rustc/88f19c6dab716c6281af7602e30f413e809c5974/library/core/src/panicking.rs:50:5
3: <bgzip::read::BGZFReader<R> as std::io::BufRead>::fill_buf
at /home/oliverr/.cargo/registry/src/github.com-1ecc6299db9ec823/bgzip-0.2.0/src/read.rs:130:9
4: std::io::read_until
at /rustc/88f19c6dab716c6281af7602e30f413e809c5974/library/std/src/io/mod.rs:1766:35
5: std::io::BufRead::read_line::{{closure}}
at /rustc/88f19c6dab716c6281af7602e30f413e809c5974/library/std/src/io/mod.rs:2025:35
6: std::io::append_to_string
at /rustc/88f19c6dab716c6281af7602e30f413e809c5974/library/std/src/io/mod.rs:333:19
7: std::io::BufRead::read_line
at /rustc/88f19c6dab716c6281af7602e30f413e809c5974/library/std/src/io/mod.rs:2025:9
8: selene::join::join_input_with_data
at ./src/join.rs:93:52
9: selene::run
at ./src/lib.rs:41:5
10: selene::main
at ./src/main.rs:2:11
11: core::ops::function::FnOnce::call_once
at /rustc/88f19c6dab716c6281af7602e30f413e809c5974/library/core/src/ops/function.rs:227:5
Just checking: this is supposed to be able to read across block boundaries, right? Thanks!
I think this is the same problem as #3, and that it's unrelated to reading across blocks.
The following test fails when added to lib.rs
:
#[test]
fn test_read_all() -> Result<(), BGZFError> {
let reader =
BGZFReader::new(fs::File::open("testfiles/common_all_20180418_half.vcf.gz")?);
for _line in reader.lines() {}
Ok(())
}
with the following backtrace:
thread 'test::test_read_all' panicked at 'internal error: entered unreachable code', src/read.rs:130:9
stack backtrace:
0: rust_begin_unwind
at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:493:5
1: core::panicking::panic_fmt
at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/panicking.rs:92:14
2: core::panicking::panic
at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/panicking.rs:50:5
3: <bgzip::read::BGZFReader<R> as std::io::BufRead>::fill_buf
at ./src/read.rs:130:9
4: std::io::read_until
at /homes/ransh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/mod.rs:1766:35
5: std::io::BufRead::read_line::{{closure}}
at /homes/ransh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/mod.rs:2025:35
6: std::io::append_to_string
at /homes/ransh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/mod.rs:333:19
7: std::io::BufRead::read_line
at /homes/ransh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/mod.rs:2025:9
8: <std::io::Lines<B> as core::iter::traits::iterator::Iterator>::next
at /homes/ransh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/mod.rs:2562:15
9: bgzip::test::test_read_all
at ./src/lib.rs:127:22
10: bgzip::test::test_read_all::{{closure}}
at ./src/lib.rs:124:5
11: core::ops::function::FnOnce::call_once
at /homes/ransh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
12: core::ops::function::FnOnce::call_once
at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/ops/function.rs:227:5
As a more minimal test, generating a really small bgzip file, like:
$ printf "hello\nworld\n" | bgzip > test.gz
and using reader.read_line()
on it more than twice panics.
I like this crate, and could use it, as it seems relatively light on dependencies and builds for me on multiple systems I use. But I need the functionality you have in AdaptiveReader, which as far as I can tell is not in a tagged release. I think means I can't get it directly from cargo. Please correct me on this if I'm wrong on this. I'd rather not reimplement that functionality (or copy your code into my app) if you will soon be releasing a new version.
Do you have plans to update the crate with this functionality in the near future?
When wrapping the reader with a io::BufReader
, the word "Prepare" is being printed to stdout for each compressed block.
It appears to be a forgotten println
in the io::Read
impl block.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.