annotate seqlens.py @ 2:dd2c54f4a12e draft default tip

"planemo upload for repository https://github.com/galaxy-works/shed-tools/tree/main/tools/seqprep commit 80ec6fb196df94824c51fc6b0357156182df541e"
author galaxyworks
date Sun, 28 Feb 2021 22:21:38 +0000
parents f25733322c54
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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))