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

Better API #18

Open
bovee opened this issue Aug 24, 2018 · 2 comments
Open

Better API #18

bovee opened this issue Aug 24, 2018 · 2 comments

Comments

@bovee
Copy link
Contributor

bovee commented Aug 24, 2018

Rather than the callback-style we have now, it would be nice to write something like:

let processor = NeedletailFile::new("test.fasta");
assert_eq!(processor.file_type, NeedletailTypes::FASTA);
assert_eq!(processor.compression_type, NeedletailCompressionTypes::None);

while let record = processor.next()? {
   ...
}

The major issues with this are keeping the state of the iterator and the underlying buffer synced up (Rust's streaming iterator problem; this is also why we can't use for record in ...) and more importantly, the polymorphic nature of record (is it a FASTA? FASTQ? maybe we can do something clever with Into here to allow the processor to spit out a SeqRecord?). I've never been a huge fan of the callbacks and with the big v0.2.0 rewrite I think we're closer to having a decent solution here, but there's still a bit of type-fu necessary to make it work.

@boydgreenfield
Copy link
Contributor

@bovee It'd also be nice to have a function for evaluating a NeedletailFile as a stream of bytes and records (or maybe just the former and a method for conversion). Then you could trivially do a few nice things like compute rolling md5/sha256 checksums, etc. Thoughts?

@bovee
Copy link
Contributor Author

bovee commented Aug 24, 2018

Yeah, that's a really good idea. It's a bit more complicated, but we should split the compression stuff off into it's own transparent Read + Seek -> Read handler and then you could write a "middleware" to do rolling checksums on either the input or output from that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants