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

Wrap sequence in output file #508

Open
alvanuffelen opened this issue Dec 9, 2022 · 1 comment
Open

Wrap sequence in output file #508

alvanuffelen opened this issue Dec 9, 2022 · 1 comment

Comments

@alvanuffelen
Copy link

A common convention is to wrap lines at 60 characters in a FASTA file.
Would it be possible to add an option to wrap the sequences when writing out to a file?
For example:

/// Write a Fasta record with given id, optional description and sequence.
    pub fn write(&mut self, id: &str, desc: Option<&str>, seq: TextSlice<'_>) -> io::Result<()> {
        self.writer.write_all(b">")?;
        self.writer.write_all(id.as_bytes())?;
        if let Some(desc) = desc {
            self.writer.write_all(b" ")?;
            self.writer.write_all(desc.as_bytes())?;
        }
        self.writer.write_all(b"\n")?;
        for chunk in seq.chunks(wrap) {
            self.writer.write_all(chunk)?;
            self.writer.write_all(b"\n")?;
        }
        self.writer.write_all(b"\n")?;

        Ok(())
    }
@dcroote
Copy link
Contributor

dcroote commented Dec 9, 2022

Yes and in fact there is an open PR for this by @openpaul: #490

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