This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Append two fasta sequences

I have two fasta files with different header and sequences and would like to append them one after the other in the same sequential order

Input: first file

>RNA1
AATGACGATGACGATGACAGAT
>RNA2
ATAGATGGGCAGTAGAGA

File2:

>mRNA1
ATGGAGATGAGAT
>mRNA2
AGATGGGGATGA

Ouput file should be

>RNA1:mRNA1
AATGACGATGACGATGACAGATATGGAGATGAGAT
>RNA2:mRNA2
ATAGATGGGCAGTAGAGAAGATGGGGATGA
fasta bioperl biopython

I have tried the EMBOSS tool pasteseq which appends only the first sequence but does not retrieve the identifiers

I don't think that is what OP has in mind. Sequences should be concatenated together and identifiers too.

that is right my bad

1 answer

assuming all fasta have two lines per record (name+seq)

paste f1.fasta f2.fasta | sed -e '/^>/s/\t>/:/' -e '/^[^>]/s/\t//'

Alternatively: paste -d '' file1 file2 | sed 's/>/:/2' or e.g. paste -d '' file1 <(tr ">" ":" <file2)

Log in to answer this question.