How to add line breaks before each ">" header line in fasta file
1
0
Entering edit mode
2.2 years ago
buhbs ▴ 30

Hello, I have a big fasta file with hundreds of sequences. In some cases the fasta sequences do not have line breaks between them. I would like to add a line break before each header.

For example, right now it looks like this:

">name ATCGCTGCGAT>name2 ATATCGTGA"

And I want it to look like this:

">name ATCGCTGCGAT"

">name2 ATATCGTGA"

Thank you for any help!

bash fasta • 960 views
ADD COMMENT
1
Entering edit mode
2.2 years ago
Marco Pannone ▴ 810
sed 's/>/\n&/g' file
ADD COMMENT
0
Entering edit mode

This worked perfectly! Thanks

ADD REPLY
0
Entering edit mode

that will work ... most of the time :-D

https://nsaunders.wordpress.com/2014/08/14/looking-for-in-all-the-wrong-places/

> dbj|AB047520.1| Homo sapiens gene for PER3, exon 1, 128+22(G->A) 
> gb|AF134414.1|AF134414 Homo sapiens B-specific alpha 1->3 galactosyltransferase (ABO) mRNA, ABO-*B101 allele, complete cds
ADD REPLY

Login before adding your answer.

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