Created
May 6, 2017 15:43
-
-
Save mtholder/cdc53bc8d328aebf83bc3d74df3ac81d to your computer and use it in GitHub Desktop.
count species ranked taxa in OTT with two word names from the output of the otcetera command in https://gist.github.com/mtholder/0ab3ef34ac96d4eec38fcfbefd4e66cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import sys | |
| inp = sys.stdin | |
| count = 0 | |
| for line in inp: | |
| ls = [i.strip() for i in line.split(' |')] | |
| if ls: | |
| assert len(ls) == 3 and ls[2] == '' | |
| rank = ls[0] | |
| if rank == 'species': | |
| name = ls[1] | |
| num_words = name.split() | |
| if len(num_words) == 2: | |
| count += 1 | |
| if count % 10000 == 0: | |
| sys.stderr.write(" ... count = {} ...\n".format(count)) | |
| sys.stdout.write('{}'.format(count)) | |
| sys.stdout.write('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment