Biostar Beta. Not for public use.
How do concatenate different fasta file
0
Entering edit mode
16 months ago
lkianmehr • 30
France

Does anybody know what is the best and trustable way to concatenate different FASTA files for making them index together?

3
Entering edit mode
7 weeks ago
genomax 68k
United States

Just cat them together. I am not sure what you mean by trustable?

If you have spaces in the headers (e.g. words separated by names) make sure to change the space to _. Most aligners will drop things past first space when reporting alignments (e.g. bbmap is an exception and will keep the entire name by default unless you use trd=t). You may get confusing results if the part of name up to first space is common to more than one record.

2
Entering edit mode
14 months ago
Belgium, Brussels

As Genomax commented :

In a unix shell :

cat file1.fasa file2.fastq file3.fasta > merged_file.fasta


or even easier if all your fasta files are in a directory and ends by .fasta

cat *.fasta > merged_file.fasta

1
Entering edit mode

I tend to remember that there were cases (also reported here on Biostars) when cat *.fasta somehow caused an infinity loop because the output file would be constantly appended to itself (as it also ends on .fasta). To avoid this, consider to use:

find . -maxdepth 1 -name \*.fasta | xargs cat > output.fasta