$ awk -F '|' '/^>/ {gsub(/ /,"_",$6);print ">"$6;next}1' fasta_file may suffice to print scientific name separated by _
• 0 views
•
link
I have a MSA (fasta format) with hundreds of sequences , and the descriptions are this format:
>gi|AY015275.1|taxonid|154401|organism|Leuenbergeria guamacho|seqid|AY015275.1|description|Pereskia guamacho tRNA-Lys (trnK) gene partial sequence; and maturase K (matK) gene complete cds; chloroplast genes for chloroplast products
How can I change the description of each entry to look like this?
>Leuenbergeria_guamacho
Edited to add an underscore between genus and species.
awk -F '|' '/^>/ { print ">"$6; next; } { print $0; }' fasta_file
You also might want to replace the space with a _
awk -F '|' '/^>/ { print ">"$6; next; } { print $0; }' fasta_file | tr " " "_"
$ awk -F '|' '/^>/ {gsub(/ /,"_",$6);print ">"$6;next}1' fasta_file may suffice to print scientific name separated by _
Log in to answer this question.
Assuming that scientific name is always sandwiched between organism and seqid:
with sed: