This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to split fasta file by ID, making sure to keep two entrys in each file

Hi, I have a fasta file which looks like:

>reference
AGCT
>entry1
AGCT
>entry2
AGCT

I want to split the fasta file by ID, but also include the reference in each file.

So far I am using seqkit split --by-id file.fasta and then cat reference.fasta file1.fasta > results.fasta

However this is quite slow, is there a way of doing this in one command?

fasta split seqkit bash

1 answer

If you have already split your files then it is just a question of looping through the list, you can loop in bash or more elegantly with parallel:

ls -1 *.fa | parallel 'cat reference.fa {}.fa > {}.merged.fasta'

Log in to answer this question.