Hi Rm, i copied the fasta file here but it didn't show correctly. Actually it's a fasta file. So >1-5832000 should be on a single line. where 1 is the seq name and 5832000 is the frequency of this sequence. Could you show me how to calculate the total number in this format? Thanks a lot!
Get The Total Counts Number From A Collapsed File
Hi,
After adapter trimming, I collapsed my total reads to the following fasta format:
>1-5832000
AGGGCCCTTT
>2-124000
GGCCCTTTT
But now I want to get to total number of counts, not just the number of the unique reads. For example, for the above reads, I want to get the total number of (5832000+124000), not 2.
Could anybody tell me how to do it? Thanks.
Ran
• 3,461 views
•
link
1 answer
Assuming tab in between as above:
cut -f 1 inputfile.txt | awk -F"-" { SUM += $2} END { print SUM }'
EDIT: If it is a fasta file
>1-5832000
AGGGCCCTTT
>2-124000
GGCCCTTTT
Try this:
awk -F"-" '/>/{ SUM += $2} END { print SUM }' input.fasta
• 165 views
•
link
Log in to answer this question.