Entering edit mode
5.8 years ago
MB
▴
50
Hi,
I have a fasta file input.fa which has duplicate fasta headers.
>UID584_Org_name_strain
JGTTQEWEILYNMCCDASSHHGTQEFGRKKQLAADBNGTAVQEGFN
>JGH1236_Org_name
HFHGTSNNIGLTTREKKQLAADBNGTAVQEGFNMENDLALFVTYGAHLVDGNVLTDRLSIGGKTALTGVDP
>JGH1236_Org_name
FHGTSNNIGLTTREKKQLAADBNGTAVQEGFNMENDLALFVTYGAHLVDGNVLTDRLSIGGKTALTGV
>KIL563.2_Org_name
TTFWLMAFDSCVIIPPTREWWQQLGTGTSNNIGLTTREKKQLAADBN
>KIL563.2_Org_name
TTFWLMAFDSCVIIPPTREWWQQLGTGTSEKKQLAADBNGTAVQEGFNMENDLALFVTYGAHLV
>KIL563.2_Org_name
TTFWLMAFDSCVIIPPTREWWQQLGTGTSEKKQLAADBNGTAVQEGFNMENDLALFVTY
>GTK584_Org_name_str
KKQLAADBNGTAVQEGFNMENDLALFVTYGHFHGTSNNIGLTTREKKQLAAWLMAFDSCVIIPPTRE
>GTK584_Org_name_str
DBNGTAVQEGFNMENDLALFVTYGHFHGTSNNIGLTTREKKQLAAWLMAFDSCVIIPPTREADBNGTAVQEGFNME
>EAD5624_Org_nam
LTTREKKQLAADBNGTAVQEGFNMENDLALFVTYBNGTAVQEGFNMENDLALFVTYGAAWLMAFDSCVIIPPT
>EAD5624_Org_nam
LTTREKKQLAADBNGTAVQEGFNMENDLALFVTYBNGTAVQVIIPPTREWWQQLGTGTSEKKQLAADBNGTAVQEGF
I want to rename all the headers with numbers before the first underscore '_' like this:
>UID584.1_Org_name_strain
JGTTQEWEILYNMCCDASSHHGTQEFGRKKQLAADBNGTAVQEGFN
>JGH1236.1_Org_name
HFHGTSNNIGLTTREKKQLAADBNGTAVQEGFNMENDLALFVTYGAHLVDGNVLTDRLSIGGKTALTGVDP
>JGH1236.2_Org_name
FHGTSNNIGLTTREKKQLAADBNGTAVQEGFNMENDLALFVTYGAHLVDGNVLTDRLSIGGKTALTGV
>KIL563.2.1_Org_name
TTFWLMAFDSCVIIPPTREWWQQLGTGTSNNIGLTTREKKQLAADBN
>KIL563.2.2_Org_name
TTFWLMAFDSCVIIPPTREWWQQLGTGTSEKKQLAADBNGTAVQEGFNMENDLALFVTYGAHLV
>KIL563.2.3_Org_name
TTFWLMAFDSCVIIPPTREWWQQLGTGTSEKKQLAADBNGTAVQEGFNMENDLALFVTY
>GTK584.1_Org_name_str
KKQLAADBNGTAVQEGFNMENDLALFVTYGHFHGTSNNIGLTTREKKQLAAWLMAFDSCVIIPPTRE
>GTK584.2_Org_name_str
DBNGTAVQEGFNMENDLALFVTYGHFHGTSNNIGLTTREKKQLAAWLMAFDSCVIIPPTREADBNGTAVQEGFNME
>EAD5624.1_Org_nam
LTTREKKQLAADBNGTAVQEGFNMENDLALFVTYBNGTAVQEGFNMENDLALFVTYGAAWLMAFDSCVIIPPT
>EAD5624.2_Org_nam
LTTREKKQLAADBNGTAVQEGFNMENDLALFVTYBNGTAVQVIIPPTREWWQQLGTGTSEKKQLAADBNGTAVQEGF
It would be convenient if anybody could suggest me sed/awk/grep
command for this.
Any help would be appreciated. Thanks!
Thanks! worked perfectly!