Yup, that about covers it.
Order Sequences By Number Of Times Found
I have a large (~1 million) list of sequences 15 bp long and would like to be able
to:
1) Find the unique sequences
2) Find how many times each of these are in the list
3) Order the unique sequences by the number of times they occur
Any help greatly appreciated
• 3,768 views
•
link
2 answers
Assuming your sequences are in a plain text file (called input.txt) with one sequence per line, then it's a unix one-liner...
sort input.txt | uniq -c | sort -k1nr > output.txt
the first column in output.txt will show the number of occurrences of the sequence in the second column, and the whole file will be sorted decreasing by column 2.
• 226 views
•
link
Faster than using unix sort, still a one-liner:
awk '{cnt[$0]++}END{for (x in cnt){print cnt[x]"\t"x}}' input.txt|sort -k1nr > output.txt
• 186 views
•
link
Log in to answer this question.
please, accept the answer that you think is the most correct. It is a fair way to thank the people who answered you.