# Path: gffutils/create.py
# def deprecation_handler(kwargs):
#     def __init__(self, data, dbfn, force=False, verbose=False, id_spec=None,
#                  merge_strategy='error', checklines=10, transform=None,
#                  force_dialect_check=False, from_string=False, dialect=None,
#                  default_encoding='utf-8',
#                  disable_infer_genes=False,
#                  disable_infer_transcripts=False,
#                  infer_gene_extent=True,
#                  force_merge_fields=None,
#                  text_factory=sqlite3.OptimizedUnicode,
#                  pragmas=constants.default_pragmas, _keep_tempfiles=False,
#                  directives=None,
#                  **kwargs):
#     def set_verbose(self, verbose=None):
#     def _increment_featuretype_autoid(self, key):
#     def _id_handler(self, f):
#     def _get_feature(self, ID):
#     def _do_merge(self, f, merge_strategy, add_duplicate=False):
#     def _add_duplicate(self, idspecid, newid):
#     def _candidate_merges(self, f):
#     def _populate_from_lines(self, lines):
#     def _update_relations(self):
#     def _drop_indexes(self):
#     def set_pragmas(self, pragmas):
#     def _init_tables(self):
#     def _finalize(self):
#     def create(self):
#     def update(self, iterator):
#     def execute(self, query):
#     def _insert(self, feature, cursor):
#     def _replace(self, feature, cursor):
#     def __init__(self, *args, **kwargs):
#     def _populate_from_lines(self, lines):
#     def _update_relations(self):
#         def relations_generator():
#     def __init__(self, *args, **kwargs):
#     def _populate_from_lines(self, lines):
#     def _update_relations(self):
#         def derived_feature_generator():
# def create_db(data, dbfn, id_spec=None, force=False, verbose=False,
#               checklines=10, merge_strategy='error', transform=None,
#               gtf_transcript_key='transcript_id', gtf_gene_key='gene_id',
#               gtf_subfeature='exon', force_gff=False,
#               force_dialect_check=False, from_string=False, keep_order=False,
#               text_factory=sqlite3.OptimizedUnicode, force_merge_fields=None,
#               pragmas=constants.default_pragmas, sort_attribute_values=False,
#               dialect=None, _keep_tempfiles=False, infer_gene_extent=True,
#               disable_infer_genes=False, disable_infer_transcripts=False,
#               **kwargs):
# class _DBCreator(object):
# class _GFFDBCreator(_DBCreator):
# class _GTFDBCreator(_DBCreator):


import os
import logging
import gffutils
    import argparse
from collections import Counter
from gffutils.create import logger
                if len(exons) > 0:
                    exon_extent = [
                        min(i.start for i in exons),
                        max(i.stop for i in exons)
                    ]
                    gene_extent = [gene.start, gene.stop]
                    if exon_extent != gene_extent:
                        logger.warning(
                            "Exons of gene %s do not match gene annotation. "
                            "Gene extent: %s.  Exon extent: %s"
                            % (gene_id, exon_extent, gene_extent)
                        )

                    if args.fix_extent == 'gene':
                        new_exons = sorted(exons, key=lambda x: x.start)
                        new_exons[0].start = gene.start
                        new_exons[-1].stop = gene.stop
                        exons = new_exons

            for exon in exons:
                fields = str(grandchild).split('\t')[:-1]
                attributes = ('gene_id "{0}"; transcript_id "{1}"; '
                              'gene_name "{2}" transcript_type="{3}"'
                              ).format(
                                  gene_id,
                                  transcript_id,
                                  gene.attributes['Name'][0],
                                  child.featuretype)
                fields.append(attributes)
                fout.write('\t'.join(fields) + '\n')

# Path: gffutils/create.py
# def deprecation_handler(kwargs):
#     def __init__(self, data, dbfn, force=False, verbose=False, id_spec=None,
#                  merge_strategy='error', checklines=10, transform=None,
#                  force_dialect_check=False, from_string=False, dialect=None,
#                  default_encoding='utf-8',
#                  disable_infer_genes=False,
#                  disable_infer_transcripts=False,
#                  infer_gene_extent=True,
#                  force_merge_fields=None,
#                  text_factory=sqlite3.OptimizedUnicode,
#                  pragmas=constants.default_pragmas, _keep_tempfiles=False,
#                  directives=None,
#                  **kwargs):
#     def set_verbose(self, verbose=None):
#     def _increment_featuretype_autoid(self, key):
#     def _id_handler(self, f):
#     def _get_feature(self, ID):
#     def _do_merge(self, f, merge_strategy, add_duplicate=False):
#     def _add_duplicate(self, idspecid, newid):
#     def _candidate_merges(self, f):
#     def _populate_from_lines(self, lines):
#     def _update_relations(self):
#     def _drop_indexes(self):
#     def set_pragmas(self, pragmas):
#     def _init_tables(self):
#     def _finalize(self):
#     def create(self):
#     def update(self, iterator):
#     def execute(self, query):
#     def _insert(self, feature, cursor):
#     def _replace(self, feature, cursor):
#     def __init__(self, *args, **kwargs):
#     def _populate_from_lines(self, lines):
#     def _update_relations(self):
#         def relations_generator():
#     def __init__(self, *args, **kwargs):
#     def _populate_from_lines(self, lines):
#     def _update_relations(self):
#         def derived_feature_generator():
# def create_db(data, dbfn, id_spec=None, force=False, verbose=False,
#               checklines=10, merge_strategy='error', transform=None,
#               gtf_transcript_key='transcript_id', gtf_gene_key='gene_id',
#               gtf_subfeature='exon', force_gff=False,
#               force_dialect_check=False, from_string=False, keep_order=False,
#               text_factory=sqlite3.OptimizedUnicode, force_merge_fields=None,
#               pragmas=constants.default_pragmas, sort_attribute_values=False,
#               dialect=None, _keep_tempfiles=False, infer_gene_extent=True,
#               disable_infer_genes=False, disable_infer_transcripts=False,
#               **kwargs):
# class _DBCreator(object):
# class _GFFDBCreator(_DBCreator):
# class _GTFDBCreator(_DBCreator):


# Path: gffutils/scripts/gffutils-flybase-convert.py
import os
import logging
import gffutils
    import argparse
from collections import Counter
from gffutils.create import logger

                if len(exons) > 0:
                    exon_extent = [
                        min(i.start for i in exons),
                        max(i.stop for i in exons)
                    ]
                    gene_extent = [gene.start, gene.stop]
                    if exon_extent != gene_extent:
                        logger.warning(
                            "Exons of gene %s do not match gene annotation. "
                            "Gene extent: %s.  Exon extent: %s"
                            % (gene_id, exon_extent, gene_extent)
                        )

                    if args.fix_extent == 'gene':
                        new_exons = sorted(exons, key=lambda x: x.start)
                        new_exons[0].start = gene.start
                        new_exons[-1].stop = gene.stop
                        exons = new_exons

            for exon in exons:
                fields = str(grandchild).split('\t')[:-1]
                attributes = ('gene_id "{0}"; transcript_id "{1}"; '
                              'gene_name "{2}" transcript_type="{3}"'
                              ).format(
                                  gene_id,
                                  transcript_id,
                                  gene.attributes['Name'][0],
                                  child.featuretype)
                fields.append(attributes)
                fout.write('\t'.join(fields) + '\n')

    logger.info("Wrote %s" % args.gtf)