How to Clean and Format DNA, RNA, and Protein Sequences as FASTA
Sequences copied from papers, database pages, emails, and lab documents often include spaces, line numbers, inconsistent letter case, or other text that sequence software cannot use. This guide explains how to clean those sequences safely, validate their alphabets, and produce readable FASTA records with the FASTA Formatter and Sequence Cleaner.
The quick version
A FASTA record has a header line beginning with >, followed by one or more lines of sequence. A simple DNA record looks like this:
>sample_1 ATGCGTACGTTAGC
Cleaning removes formatting artifacts such as spaces and position numbers. Validation is a separate step: it checks whether every remaining character belongs to the selected DNA, RNA, or protein alphabet. Keeping those two steps separate helps prevent accidental changes to a biological sequence.
Example 1: Clean a numbered DNA sequence copied from a document
Suppose a document displays a sequence like this:
1 atgc gtac 9 10 ttag caac 17
- Paste the text into the formatter.
- Select DNA as the alphabet.
- Keep Remove whitespace and line breaks and Remove digits and line numbering selected.
- Choose uppercase letter case and FASTA output.
- Enter a generated header prefix such as sample.
The cleaned FASTA output is:
>sample_1 ATGCGTACTTAGCAAC
Check the change report before copying the result. It should describe the removed whitespace, digits, and any letters whose case changed.
Example 2: Reformat a multi-FASTA file without joining records
A multi-FASTA file contains two or more records, each beginning with its own header. Paste or load the file, leave Preserve existing headers selected, and choose a line width such as 60 or 80. The formatter cleans and wraps each record independently.
>control ATGCGTACGT >treated ATGCGTTCGT
Do not remove the header boundaries or join the records unless you truly intend to create one sequence. Separate records may represent different samples, genes, contigs, or proteins.
Example 3: Validate ambiguous DNA bases
DNA data may contain IUPAC ambiguity codes. For example, R means A or G, Y means C or T, and N means any nucleotide. These codes can be valid biological data rather than errors. Select DNA so the formatter can distinguish supported IUPAC codes from unexpected characters.
The safest default is Keep and warn. If an unsupported character appears, confirm what it represents before choosing to remove it or replace it with N. Silent deletion can shift positions and change the meaning of a sequence.
Example 4: Convert between RNA and DNA notation
RNA normally uses U, while DNA uses T. To convert an RNA sequence for a DNA-oriented workflow, select RNA and choose U → T. For the other direction, select DNA and choose T → U.
RNA: AUGCUUACG DNA: ATGCTTACG
This is a notation conversion only. It does not reverse the sequence, calculate its complement, or transcribe a coding strand. Use the DNA & RNA Reverse Complement Tool when strand orientation needs to change.
How to choose a FASTA line width
Wrapping changes how a sequence is displayed, not the sequence itself. Widths of 60, 70, and 80 characters are common because they are easy to read and compare. Use the width required by the program or submission system that will receive the file. Choose 0 only when you specifically need each record on one unwrapped line.
Step-by-step: using the FASTA Formatter
- Open the FASTA Formatter and Sequence Cleaner.
- Paste sequence text or load a plain-text FASTA file.
- Select DNA, RNA, or protein when you know the sequence type; otherwise, review the automatic detection carefully.
- Choose which formatting artifacts to remove and how unexpected characters should be handled.
- Select FASTA, plain text, or printable dsDNA output.
- Review warnings, record counts, sequence length, and the change report.
- Copy or download the cleaned result only after confirming that the changes are appropriate.
Common mistakes to avoid
- Deleting unexpected characters without reviewing them. A character may be a valid ambiguity code or a clue that the wrong alphabet was selected.
- Treating a header as sequence data. In FASTA, every header must begin with
>on its own line. - Joining separate FASTA records. Removing record boundaries can create a sequence that has no biological meaning.
- Confusing gaps with invalid bases. Hyphens and periods may be alignment gaps. Remove them only when an ungapped sequence is required.
- Assuming formatting changes strand direction. Cleaning and line wrapping do not reverse, complement, translate, or align a sequence.
Frequently asked questions
Does changing the FASTA line width change my sequence?
No. Line breaks are formatting. Removing them produces the same continuous sequence, provided no biological characters are added, removed, or reordered.
Can FASTA contain DNA, RNA, and protein sequences?
Yes. FASTA describes the record structure, not one specific alphabet. The receiving software still needs to know whether the characters represent nucleotides or amino acids.
Are spaces allowed in a FASTA header?
Descriptive text after the record identifier is common, but software differs in how it interprets spaces and punctuation. For the broadest compatibility, use a short, unique first identifier and check the requirements of the program or database receiving the file.
Are my sequences uploaded?
No. The Calcorium formatter processes pasted text and loaded files in your browser. Sequence contents are not uploaded or stored by the tool.