Convert a FASTA sequence file to PHYLIP alignment (interleaved).
Writing an aligned FASTA file as interleaved PHYLIP
Yes, this page converts FASTA to PHYLIP alignment (interleaved), provided the sequences are already aligned to the same length; the converter does not align them. IDs longer than 10 characters are cut, and any description after the ID is dropped. No sequence-type question is asked for this pair.
What carries over into the PHYLIP file
| Data in your file | In the output | Details |
|---|---|---|
| Aligned sequence rows | Kept | Written as the rows of one interleaved alignment; in the sample, every letter comes through unchanged. |
| Record IDs | Changed if needed | Shortened if longer than 10 characters; a colon or semicolon becomes a vertical bar. |
| Header description text | Lost | Words after the ID on a header line are not kept. |
Rules the converter applies before writing
- Every sequence must have the same length; a record that differs is refused, and the message gives both lengths. The converter does not align or pad anything.
- A record with no sequence letters is refused.
- A period in a sequence is refused. The message asks you to replace each
.with-, the gap symbol, and convert again. - Two IDs that become identical after shortening to 10 characters are refused. The message asks you to rename the records so that their first 10 characters differ.
The sample on this page converts
The sample file holds three records of 39 letters each, named seq1 to seq3. It converts to a three-row interleaved alignment whose first line reads 3 39; the IDs seq1 to seq3 stay as they are, the letters come through unchanged, and the words after each ID are gone.
Longer names, sequential layout, and the way back
FASTA to PHYLIP alignment (relaxed names) does not shorten IDs to 10 characters; instead, every ID must be present, unique, and free of spaces or other whitespace. It has the same equal-length, no-empty-record, and no-period rules and still drops descriptions. FASTA to PHYLIP alignment (sequential) writes the sequential layout with the same 10-character rule as this page. Both convert the sample as well.
The reverse route, PHYLIP alignment (interleaved) to FASTA, is available and has no loss notices, but it cannot restore characters cut from the IDs or descriptions dropped here.
If the file is refused for another reason
If the upload cannot be read at all, the page says only that it could not be read as FASTA and asks you to check that it is a valid FASTA file; no cause is given. Uploads are limited to 50 MB.
Run it with Biopython
For batch work, you can use Biopython's SeqIO.convert function. This pair needs no molecule type argument.
from Bio import SeqIO
count = SeqIO.convert("input.fasta", "fasta",
"output.phylip", "phylip")
print("Converted %i records" % count)
Sample input file: FASTA
Copy this example into a file, or download it, to try a FASTA conversion.
Download sample (sample.fasta, 210 bytes)
Samples are small illustrative files. Some come from the Biopython test suite (see the project's sample notes); they are not real study data.