Source

bx-python / scripts / tfloc_summary.py

#!/usr/bin/env python2.3

"""
Read TFLOC output from stdin and write out a summary in which the nth line 
contains the number of sites found in the nth alignment of the input.

TODO: This is very special case, should it be here?
"""

import sys

counts = dict()

max_index = -1

for line in sys.stdin:
    if line[0].isdigit():
        current_index = int( line )
        max_index = max( current_index, max_index )        
    elif line[0] == "'":
        try: counts[ current_index ] += 1
        except: counts[ current_index ] = 1
    else:
        raise "Invalid input line " + line

for i in range( max_index + 1 ):
    print counts.get( i, 0 )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.