What would I have to change the regular expression to if I just need the
Genus_species
• 1 views
•
link
Hi,
I am new to regular expressions and programming in general and I need help with reformatting FASTA files from
>AB000667.1.2469.3417 root;Eukaryota;Chordata;Actinopteri;Pleuronectiformes;Paralichthyidae;Paralichthys;Paralichthys olivaceus
CAAAGGCTTGGTCCTGACTTTACTGTCGACTCTAACTAGACTTACACATGCAAGTATCCG
CCCCCCTGTGAGAATGCCCATAACGCCCTGCTCGGGAACAAGGAGCTGGCATCAGGCACA
...
some of them have:
>AB002132.1._1.403
in the header
and I want to change it to:
>AccessionNumber.Version SpeciesName
nucleotide sequence
nucleotide sequence, continued
nucleotide sequence, continued
etc...
The requirments include:
Thanks!
$ sed '/>/ s/\(.*\)\s.*;\(.*\)$/\1\2/g' test.fa
>AB000667.1.2469.3417 Paralichthys olivaceus
CAAAGGCTTGGTCCTGACTTTACTGTCGACTCTAACTAGACTTACACATGCAAGTATCCG
CCCCCCTGTGAGAATGCCCATAACGCCCTGCTCGGGAACAAGGAGCTGGCATCAGGCACA
input:
$ cat test.fa
>AB000667.1.2469.3417 root;Eukaryota;Chordata;Actinopteri;Pleuronectiformes;Paralichthyidae;Paralichthys;Paralichthys olivaceus
CAAAGGCTTGGTCCTGACTTTACTGTCGACTCTAACTAGACTTACACATGCAAGTATCCG
CCCCCCTGTGAGAATGCCCATAACGCCCTGCTCGGGAACAAGGAGCTGGCATCAGGCACA
More the test data is provided, better would be the solution to OP. Gritz122
What would I have to change the regular expression to if I just need the
Genus_species
$ sed '/>/ s/.*;\(.*\)$/>\1/g;s/ /_/g' test.fa
>Paralichthys_olivaceus
CAAAGGCTTGGTCCTGACTTTACTGTCGACTCTAACTAGACTTACACATGCAAGTATCCG
CCCCCCTGTGAGAATGCCCATAACGCCCTGCTCGGGAACAAGGAGCTGGCATCAGGCACA
Log in to answer this question.