#!/usr/bin/env python2.4

import sys
from revfileiter import *
import bx.align.maf

maf_fname = sys.argv[1]

it = revfileiter( open( maf_fname ) )

lines = []
for line in it:
    lines.append( line )
    if line.startswith( "a " ):
        break
lines.append( "##maf\n" )

class FileLike( object ):
    def __init__( self, it ):
        self.it = it
    def readline( self ):
        return self.it.next()

block = bx.align.maf.Reader( FileLike( reversed( lines ) ) ).next()
print block.components[0].start, block.components[0].end

