text: #!/usr/bin/env python
  
  #Copyright (C) 2009-2011 by Benedict Paten (benedictpaten@gmail.com)
  #
  #Released under the MIT license, see LICENSE.txt
  #!/usr/bin/env python
  
  #nknguyen@soe.ucsc.edu
  #Test the bed records generated by cactus_bedGenerator.c:
  # 1/Total number of bases covered by all records = length of input sequence
  # 2/No base overlap between beds (not yet writen).
  
  import os
  import sys
  import re
  from optparse import OptionParser
  
  def test():
      totalBases = 0
      #go through input file (stdin) and get the sequences
      for line in sys.stdin.readlines():
          ptrack = re.compile('track')
          #pi = re.compile('i')
          if ptrack.match(line):
              sys.stdout.write("TotalBases = %d\n" %(totalBases))
              sys.stdout.write("Track: %s\n" %(line))
              continue
          else:
              # 0      1     2      3        4       5      6     7    8       9           10          11
              #chr, start, end, chainName, score, strand, start, end, bgr, blockCount, blockSizes, blockStarts
              list = line.split(' ')
  	if len(list) != 12:
  	    sys.stderr.write("wrong input format")
  	    continue
          blockCount = int(list[9])
  	blockSizes = list[10].split(',')
          for size in range(blockCount):
              totalBases += int(blockSizes[size])
      sys.stdout.write("TotalBases = %d\n" %(totalBases))
  
  if __name__ == "__main__" :
      test()
  
  
  