Source

bx-python / scripts / maf_species_in_all_files.py

#!/usr/bin/env python2.4

"""
Takes a list of maf filenames on the command line and prints a comma separated
list of the species that occur in all of the mafs. 

usage %prog maf1 maf2 ...
"""

import operator
import sys
import bx.align.maf

files = sys.argv[1:]
sets = []

for file in files:
    sys.stderr.write( "." )
    s = set()
    for block in bx.align.maf.Reader( open( file ) ):
        for comp in block.components:
            s.add( comp.src.split( '.' )[0] )
    sets.append( s )

inter = reduce( operator.and_, sets )
print ",".join( inter )
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.