1 | #!/usr/bin/python2.6 |
---|
2 | |
---|
3 | """ |
---|
4 | Takes a list of maf filenames on the command line and prints a comma separated |
---|
5 | list of the species that occur in all of the mafs. |
---|
6 | |
---|
7 | usage %prog maf1 maf2 ... |
---|
8 | """ |
---|
9 | |
---|
10 | import operator |
---|
11 | import sys |
---|
12 | import bx.align.maf |
---|
13 | |
---|
14 | files = sys.argv[1:] |
---|
15 | sets = [] |
---|
16 | |
---|
17 | for file in files: |
---|
18 | sys.stderr.write( "." ) |
---|
19 | s = set() |
---|
20 | for block in bx.align.maf.Reader( open( file ) ): |
---|
21 | for comp in block.components: |
---|
22 | s.add( comp.src.split( '.' )[0] ) |
---|
23 | sets.append( s ) |
---|
24 | |
---|
25 | inter = reduce( operator.and_, sets ) |
---|
26 | print ",".join( inter ) |
---|