How to merge multiple .fasta flies retaining the file headers
1
0
Entering edit mode
4.0 years ago
Azuretimes • 0

Hi anyone has an idea about merging multiple .fasta flies retaining the file headers? I tried cat command but it will only keep the 1st header. What I want to do:

FileA

>Header1
Sequence1
>Header2
Sequence2

FileB

>Header3
Sequence3

FileC

>Header4
  Sequence4
>Header5
  Sequence5

What I want:

New File

>Header1
  Sequence1
>Header2
  Sequence2
>Header3
  Sequence3
>Header4
  Sequence4
>Header5
  Sequence5

Thank you so much for your help!

Assembly sequencing • 735 views
ADD COMMENT
0
Entering edit mode

Why do you think cat doesn't work for this?

ADD REPLY
0
Entering edit mode

Hi Joe, I tried cat, but the problem is that it will only Header1 and lose other header information...

ADD REPLY
0
Entering edit mode

If you are using it correctly, as per genomax's answer, this cannot happen.

If it is the case, you're doing something else you aren't telling us.

ADD REPLY
0
Entering edit mode

Hi Joe, thanks for the reply. I followed genomax's answer and it worked finally,

ADD REPLY
2
Entering edit mode
4.0 years ago
GenoMax 141k
cat fileA fileB fileC > final_file
ADD COMMENT
0
Entering edit mode

Hi, thanks for the reply. I tried cat, but the problem is that it will only Header1 and lose other header information..

ADD REPLY
0
Entering edit mode

No it won't. Not unless your files are made on some other OS and don't have correct unix endings. You should try to reformat your files using dos2unix command before cat.

ADD REPLY
0
Entering edit mode

Thanks for your suggestion! I tried dos2unix and it works!

ADD REPLY
0
Entering edit mode

You can accept the answer "green checkmark" to provide closure to this thread.

ADD REPLY

Login before adding your answer.

Traffic: 2102 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