How to add a specific character into the specific location of header in fasta file?
1
0
Entering edit mode
8.6 years ago
seta ★ 1.9k

Hi all,

I have many fasta file with the header like 0001|X. y, 00021|M. s. There is a space between X. and y or M. and s causing a problem. I would like to add an underline character _ to the header instead of existing space. Could you please help me out to this end? Sorry if the issue is basic, I find no school better than here for learning.

Thanks in advance

sequence header • 3.3k views
ADD COMMENT
0
Entering edit mode

If a line starts with >, replace space with _.

ADD REPLY
0
Entering edit mode

The line starts with >, but sorry I didn't get your point

ADD REPLY
3
Entering edit mode
8.6 years ago
sed '/^>/s/ /_/' in.fasta > out.fasta

EDIT:

You need

sed '/^>/s/ /_/g' in.fasta > out.fasta
ADD COMMENT
0
Entering edit mode

Thanks a lot Goutham. However, I found that there is more than one space in the header file, the command replace just the first space with "_". Is it a way to replace all spaces in the header with "_"?

ADD REPLY
3
Entering edit mode
sed '/^>/s/ /_/g' in.fasta > out.fasta
ADD REPLY
0
Entering edit mode

Many thanks for your help.

ADD REPLY

Login before adding your answer.

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