code: def split_gtf(gtf, sample_size=None, out_dir=None):
      
      if out_dir:
          part1_fn = os.path.basename(os.path.splitext(gtf)[0]) + ".part1.gtf"
          part2_fn = os.path.basename(os.path.splitext(gtf)[0]) + ".part2.gtf"
          part1 = os.path.join(out_dir, part1_fn)
          part2 = os.path.join(out_dir, part2_fn)
          if file_exists(part1) and file_exists(part2):
              return part1, part2
      else:
          part1 = tempfile.NamedTemporaryFile(delete=False, suffix=".part1.gtf").name
          part2 = tempfile.NamedTemporaryFile(delete=False, suffix=".part2.gtf").name
  
      db = get_gtf_db(gtf)
      gene_ids = set([x['gene_id'][0] for x in db.all_features()])
      if not sample_size or (sample_size and sample_size > len(gene_ids)):
          sample_size = len(gene_ids)
      gene_ids = set(random.sample(gene_ids, sample_size))
      part1_ids = set(random.sample(gene_ids, sample_size / 2))
      part2_ids = gene_ids.difference(part1_ids)
      with open(part1, "w") as part1_handle:
          for gene in part1_ids:
              for feature in db.children(gene):
                  part1_handle.write(str(feature) + "\n")
      with open(part2, "w") as part2_handle:
          for gene in part2_ids:
              for feature in db.children(gene):
                  part2_handle.write(str(feature) + "\n")
      return part1, part2
docs: split a GTF file into two equal parts, randomly selecting genes.
      sample_size will select up to sample_size genes in total