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

Canonical way to convert between formats? #440

Open
lskatz opened this issue Jul 11, 2021 · 4 comments
Open

Canonical way to convert between formats? #440

lskatz opened this issue Jul 11, 2021 · 4 comments

Comments

@lskatz
Copy link

lskatz commented Jul 11, 2021

Hi, what is the right way to convert from, e.g., fastq to fasta format? I think it's to use the bio::io::fasta::Record and bio::io::fastq::Record classes but it's not entirely clear to me.

@natir
Copy link
Contributor

natir commented Jul 12, 2021

It's a very good question.

I can propose a solution like this:

use bio::io::fasta;
use std::io;

let mut reader = fastq::Reader::new(io::stdin());

for result in reader.records() {
    let record = result.expect("Error during fasta record parsing");

    println!(">{}\n{}\n", record.id(), record.seq());
}

My solution isn't a full rust-bio solution other people could have a different solution.

@lskatz
Copy link
Author

lskatz commented Jul 12, 2021

Thanks! Yes I am hoping for something similar but with some kind of conversion step on the record like

let fasta_record = fastq_record.as_fasta();

@natir
Copy link
Contributor

natir commented Jul 12, 2021

I can review your pull request :)

@lskatz
Copy link
Author

lskatz commented Jul 12, 2021

I took you up on that @natir ! I am not a great programmer but this is a fun way to learn more rust :)

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