Mercurial > repos > galaxyworks > seqprep
annotate seqlens.py @ 0:f25733322c54 draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
| author | galaxyworks |
|---|---|
| date | Fri, 26 Feb 2021 04:26:20 +0000 |
| parents | |
| children |
| rev | line source |
|---|---|
|
0
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
1 #!/usr/bin/env python |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
2 from collections import defaultdict |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
3 from operator import itemgetter |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
4 from sys import stdin |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
5 |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
6 |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
7 seqlens = defaultdict(int) |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
8 next_line_seq = False |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
9 count = 0 |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
10 for line in stdin: |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
11 count += 1 |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
12 if line.startswith("@"): |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
13 count = 0 |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
14 next_line_seq = True |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
15 |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
16 if next_line_seq and count == 1: |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
17 next_line_seq = False |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
18 seqlens[len(line)] += 1 |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
19 |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
20 for (length, count) in sorted(seqlens.items(), key=itemgetter(0), reverse=True): |
|
f25733322c54
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iqtree/ commit 85099b149e64f24060848cb04c680e0ac8061d76"
galaxyworks
parents:
diff
changeset
|
21 print("%d\t%d" % (length, count)) |
