Hi all,
Currently, after mapping, I got a sam file which contained approximately 30 million mapped reads. Then, by using bedtool bamtobed, I was able to obtain a bed file. However, there were so many many similar reads.
Therefore, in order to reduce the size of the final bed file, is there any way that I can mention each read only once as well as its number of presentation in the sam file.


----------


For instance:


----------


var_1     0     15      ATGCATGCATGCCGTA


----------
var_1     0     15      ATGCATGCATGCCGTA


----------
var_1     0     15      ATGCATGCATGCCGTA


----------
var_2     5     20      ATGCATGCGGGCCCC


----------
Will become:

----------
var_1     0     15      ATGCATGCATGCCGTA   3


----------


var_2     5     20      ATGCATGCGGGCCCC    1

Thank you in advance!
Use `uniq -c` your bed file.

    uniq -c mybed.bed > uniqbed.bed 

or


    echo "var_1 0 38 ATGCATGCATGCCGTA
    var_1 0 38 ATGCATGCATGCCGTA
    var_1 0 38 ATGCATGCATGCCGTA
    var_2 5 40 ATGCATGCGGGCCCC" | uniq -c

    3 var_1 0 38 ATGCATGCATGCCGTA
    1 var_2 5 40 ATGCATGCGGGCCCC
