Renaming Entry In Fasta File
2
0
Entering edit mode
3.8 years ago
stan.aanhane ▴ 30

I want to change my entries in my fasta file, but I want to keep certain numbers. I work with Linux

For example

Current names:

>NODE_1_length_140009_cov_0.223002

>NODE_2_length_119367_cov_0.245541

>NODE_3_length_108076_cov_0.169347

And I want them to change to:

>lclav_contig 1 lengte 140009 cov 0.223002

>lclav_contig 2 lengte 119367 cov 0.245541

>lclav_contig 3 lengte 108076 cov 0.169347

I know i have to work with awk but I'm stuck at the moment. Thank you for the help in advance!

Fasta Linux • 679 views
ADD COMMENT
0
Entering edit mode

You can use sed to make two changes. Replace _ with space and then NODE with lclav_contig. I assume lengte is an error but if not that will be the third replacement.

ADD REPLY
1
Entering edit mode

Thank you!

lengte is length in my native langue so no error ;)

ADD REPLY
1
Entering edit mode
3.8 years ago
Biogeek ▴ 470

sed 's/NODE/lclav_contig/' {INPUT FILE} | sed 's/_/ /g' | sed 's/ /_/1' > {OUTPUT FILE}

*Apologies, should have replied inline.

ADD COMMENT
0
Entering edit mode

Thank you! This worked fine!

ADD REPLY
0
Entering edit mode

You can accept this answer (green checkmark) to provide closure to this thread.

ADD REPLY
0
Entering edit mode
3.8 years ago
echo '>NODE_1_length_140009_cov_0.223002' | sed -re 's/>[A-Z]+_([0-9])_[a-z]+_([0-9]+)_([a-z]+)_(.*)/>lclav_contig \1 lengte \2 \3 \4/g'

>lclav_contig 1 lengte 140009 cov 0.223002

Most of the tools stop handling characters after first space. New headers (new format) may create a problem, in future.

ADD COMMENT

Login before adding your answer.

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