Skip to content

Wrap sequence in output file #508

Open
@alvanuffelen

Description

@alvanuffelen

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(())
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions