code: def rebuild(args):
      
      p = OptionParser(rebuild.__doc__)
      p.add_option("--header", default=False, action="store_true",
                   help="First line is header [default: %default]")
      p.add_option("--write_blast", default=False, action="store_true",
                   help="Get blast records of rebuilt anchors [default: %default]")
      p.set_beds()
  
      opts, args = p.parse_args(args)
  
      if len(args) != 2:
          sys.exit(not p.print_help())
  
      blocksfile, blastfile = args
      bk = BlockFile(blocksfile, header=opts.header)
      fw = open("pairs", "w")
      for a, b, h in bk.iter_all_pairs():
          print("\t".join((a, b)), file=fw)
      fw.close()
  
      if opts.write_blast:
          AnchorFile("pairs").blast(blastfile, "pairs.blast")
  
      fw = open("tracks", "w")
      for g, col in bk.iter_gene_col():
          print("\t".join(str(x) for x in (g, col)), file=fw)
      fw.close()
docs: %prog rebuild blocksfile blastfile
  
      Rebuild anchors file from pre-built blocks file.