code: def sizes(args):
      
      p = OptionParser(sizes.__doc__)
      p.set_outfile()
      p.add_option("--parents", dest="parents", default="mRNA",
              help="parent feature(s) for which size is to be calculated")
      p.add_option("--child", dest="child", default="CDS",
              help="child feature to use for size calculations")
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      gffile, = args
      parents, cftype = set(opts.parents.split(",")), opts.child
  
      gff = make_index(gffile)
  
      fw = must_open(opts.outfile, "w")
      for parent in parents:
          for feat in gff.features_of_type(parent, order_by=('seqid', 'start')):
              fsize = 0
              fsize = feat.end - feat.start + 1 \
                      if cftype == parent else \
                      gff.children_bp(feat, child_featuretype=cftype)
              print("\t".join(str(x) for x in (feat.id, fsize)), file=fw)
          fw.close()
docs: %prog sizes gffile
  
      Given a gff file of features, calculate the sizes of chosen parent feature
      based on summation of sizes of child features.
  
      For example, for parent 'mRNA' and child 'CDS' feature types, calcuate sizes of
      mRNA by summing the sizes of the disjoint CDS parts.