| 1 | #!/usr/bin/python2.6 |
|---|
| 2 | |
|---|
| 3 | """ |
|---|
| 4 | Read a maf from stdin and print the chromosome number for each alignment. It |
|---|
| 5 | searches for 'chr' in each alignment block src, and may not be robust if other |
|---|
| 6 | src formats are used. |
|---|
| 7 | |
|---|
| 8 | NOTE: See 'align_print_template.py' for a more general variation of this |
|---|
| 9 | program. |
|---|
| 10 | |
|---|
| 11 | usage: %prog refindex [options] |
|---|
| 12 | """ |
|---|
| 13 | |
|---|
| 14 | from __future__ import division |
|---|
| 15 | |
|---|
| 16 | import sys |
|---|
| 17 | from bx.cookbook import doc_optparse |
|---|
| 18 | from bx.align import maf |
|---|
| 19 | from optparse import OptionParser |
|---|
| 20 | |
|---|
| 21 | def __main__(): |
|---|
| 22 | |
|---|
| 23 | # Parse command line arguments |
|---|
| 24 | options, args = doc_optparse.parse( __doc__ ) |
|---|
| 25 | |
|---|
| 26 | try: |
|---|
| 27 | refindex = int( args[0] ) |
|---|
| 28 | except: |
|---|
| 29 | doc_optparse.exit() |
|---|
| 30 | |
|---|
| 31 | maf_reader = maf.Reader( sys.stdin ) |
|---|
| 32 | |
|---|
| 33 | for m in maf_reader: |
|---|
| 34 | c = m.components[ refindex ].src |
|---|
| 35 | print c[ c.rfind( "chr" ) + 3 : ] |
|---|
| 36 | |
|---|
| 37 | if __name__ == "__main__": __main__() |
|---|