FASTA cleaner
Fixes sequences, headers and line width in a messy FASTA. Paste it or choose a file; nothing is uploaded.
Fixes sequences, headers and line width in a messy FASTA. Paste it or choose a file; nothing is uploaded.
Sequences copied from GenBank, a paper, a spreadsheet or an email are rarely valid FASTA. They carry position numbers, spaces, mixed case, stray symbols, long descriptive headers and sometimes two records with the same name. Alignment programs, BLAST database builders and tree builders then stop with an error, or worse, read the file wrongly without saying so. This tool repairs the file in the browser and tells you exactly what it changed.
"Try an example" loads four records: a GenBank-numbered contig in lower case, a second record with the same name, a fragment with gaps, a stray @@ and two ?, and a failed read that is only question marks. With the default settings the numbers and spaces go, @@ and the question marks are removed, the second contig_1 becomes contig_1_2, and the failed read is dropped because nothing is left of it. The result is 3 records and213 nt (gap characters included). Switch "Invalid characters" to "Replace" and the question marks become N instead, so the failed read survives as eight N.
| Type | Accepted letters | Replacement |
|---|---|---|
| DNA or RNA | A C G T U R Y S W K M B D H V N | N |
| Protein | A C D E F G H I K L M N P Q R S T V W Y B Z X J U O * | X |
| Both | - and . as gaps | kept unless removed |
With "Detect", a file is read as DNA or RNA when at least 90% of its letters are A, C, G, T, U or N, and as protein otherwise. Set the type yourself for short or unusual sequences.
The header is the line that starts with >. Most programs take the text up to the first space as the sequence ID and ignore the rest, so two records that differ only after the space look identical to them. Characters with a meaning in other formats cause trouble as well: parentheses, commas, colons and semicolons in Newick trees, pipes in NCBI-style IDs, and anything beyond 10 characters in strict PHYLIP.
Identical sequences are reported but not removed; theFASTA deduplicator does that. To join records into one sequence use Combine FASTA, and for numbered or grouped output for a figure use the sequence formatter.
Paste the file or choose it from your device. Position numbers, spaces and line breaks inside the sequences are removed, characters that are not valid DNA, RNA or protein codes are removed or replaced with N or X, headers can be shortened or made safe, and the result is rewrapped to the line width you set. Copy it or download it as a .fasta file.
For DNA and RNA the IUPAC nucleotide codes: A, C, G, T, U and the ambiguity codes R, Y, S, W, K, M, B, D, H, V, N. For protein the 20 amino acid letters plus B, Z, X, J, U, O and * for a stop. A gap is written as - or a dot. Digits, spaces and other symbols are not part of the sequence.
Many tools read only the first word of the header as the sequence ID, and some fail on spaces, pipes, brackets, colons, commas or semicolons, which have a meaning in Newick trees and PHYLIP files. Two records with the same ID are another common cause. Use "ID only" or "Safe characters", and turn on "Make names unique".
Replace them when positions matter, for example in an alignment or when coordinates refer to the sequence, because removing a character shifts everything after it. Remove them when the character is clearly junk, such as a stray symbol from copy and paste.
Files up to 50 MB work. The file is read and cleaned by the browser on your device, so the limit is the memory of the tab rather than an upload quota. For larger files use a command-line tool such as seqkit.