Entering edit mode
5.3 years ago
baurumon
▴
30
Hi,
i have used awk '/^>/{if (l!="") print l; print; l=0; next}{l+=length($0)}END{print l}' seq.fasta
to count sequence length. How can i get the output in below format.
Thanks in advance
head length
NC_035897.1:11929374-11930116 742
NC_035897.1:11929384-11930116 732
Use
tr
command to change the new line characters to a tab. It is unclear if you want to go in the other direction but if that is the case then switch tab and new lines.hi genomax, I want head and length column. tr command is printing one after another. sorry for mistake.
See RamRS's solution on: Sequence length from Fasta
i asked my colleague to install seqkit but it going to take time. is there any way to do it with sed or awk?
It is advisable to search for this sort of problems on Google first before it is posted on this platform, please take a look at Brief Reminder On How To Ask A Good Question.
A simple Google search provided this and it could be the solution you're after - https://www.danielecook.com/generate-fasta-sequence-lengths/