fasta header with leading zeros
1
1
Entering edit mode
8.8 years ago
rrsowmya ▴ 20

Hi, I would like to rename the sequences in my file to have leading zeros in front of the header name using unix or perl based on the number of sequences in the file. I am unable to open these files using a text editor since they are too large. Example.

>gmp-15 
>gmp-126
>gmp-127890 to
>gmp-000015
>gmp-000126
>gmp-127890

Thanks

sequence fasta • 2.1k views
ADD COMMENT
6
Entering edit mode
8.8 years ago
5heikki 11k


awk -F "-" '{if(/^>/)printf("%s-%06d\n",$1,$2); else print $0}' file.fasta > out.fasta

ADD COMMENT
0
Entering edit mode

That worked just great! Thanks so much! I really appreciate your help!

ADD REPLY
0
Entering edit mode

so validate 5heikiki's answer by clicking on the hand on the left please.

ADD REPLY
0
Entering edit mode

Please accept @5heikki's answer by clicking on the green check mark on the left of the answer.

ADD REPLY

Login before adding your answer.

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