code: def fixboundaries(args):
      
      p = OptionParser(fixboundaries.__doc__)
      p.add_option("--type", default="gene", type="str",
                   help="Feature type for which to adjust boundaries")
      p.add_option("--child_ftype", default="mRNA", type="str",
                   help="Child featuretype(s) to use for identifying boundaries")
      p.set_outfile()
  
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      gffile, = args
      gffdb = make_index(gffile)
  
      fw = must_open(opts.outfile, "w")
      for f in gffdb.all_features(order_by=('seqid', 'start')):
          if f.featuretype == opts.type:
              child_coords = []
              for cftype in opts.child_ftype.split(","):
                  for c in gffdb.children(f, featuretype=cftype, order_by=('start')):
                      child_coords.append((c.start, c.stop))
              f.start, f.stop = range_minmax(child_coords)
  
          print(f, file=fw)
  
      fw.close()
docs: %prog fixboundaries gffile --type="gene" --child_ftype="mRNA" > gffile.fixed
  
      Adjust the boundary coordinates of parents features based on
      range chained child features, extracting their min and max values