Append two fasta sequences
1
0
Entering edit mode
7.1 years ago
tarakaramji ▴ 10

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 • 2.0k views
ADD COMMENT
0
Entering edit mode

And what have you tried?

ADD REPLY
1
Entering edit mode

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

ADD REPLY
3
Entering edit mode
7.1 years ago

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

paste f1.fasta f2.fasta | sed -e '/^>/s/\t>/:/' -e '/^[^>]/s/\t//'
ADD COMMENT
3
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Thank you..Both works perfect!!

ADD REPLY

Login before adding your answer.

Traffic: 1976 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6