Modify chromosome name in fasta file
2
0
Entering edit mode
4.0 years ago
tothepoint ▴ 800

I have a fasta file with chromosome naming starting with

NW_018085366.1, NW_018085367.1, ..NC_010450.4

and I want to add chr ahead of it.

chrNW_018085366.1, chrNW_018085367.1, ..chrNC_010450.4

I tried to fix but it just rename whole chromosome. Is there a way to ass chr ahead of it. I will be thankful for the suggestion.

fasta chromosome genome name • 5.7k views
ADD COMMENT
2
Entering edit mode
4.0 years ago
vkkodali_ncbi ★ 3.7k

Using sed

cat genome.fa | sed -r 's/(N[CTW]_[0-9]*)/chr\1/g' > genome.modified.fa
ADD COMMENT
1
Entering edit mode
4.0 years ago
ccj0410 ▴ 10

If you are familiar with command line working environment, then the following command might help you:

perl -lpe '/>(\S+)/ and $_=qq{>chr$1}' in.fa > out.fa

If you want to make this easier, try TBtools with it functions "ID Rename".

enter image description here

ADD COMMENT

Login before adding your answer.

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