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):

    _locals = locals()

    # Check if any older kwargs made it in
    deprecation_handler(kwargs)

    kwargs = dict((i, _locals[i]) for i in constants._iterator_kwargs)

    # First construct an iterator so that we can identify the file format.
    # DataIterator figures out what kind of data was provided (string of lines,
    # filename, or iterable of Features) and checks `checklines` lines to
    # identify the dialect.
    iterator = iterators.DataIterator(**kwargs)

    kwargs.update(**_locals)

    if dialect is None:
        dialect = iterator.dialect

    if isinstance(iterator, iterators._FeatureIterator):
        # However, a side-effect of this is that  if `data` was a generator,
        # then we've just consumed `checklines` items (see
        # iterators.BaseIterator.__init__, which calls iterators.peek).
        #
        # But it also chains those consumed items back onto the beginning, and
        # the result is available as as iterator._iter.
        #
        # That's what we should be using now for `data:
        kwargs['data'] = iterator._iter

    # Since we've already checked lines, we don't want to do it again
    kwargs['checklines'] = 0

    if force_gff or (dialect['fmt'] == 'gff3'):
        cls = _GFFDBCreator
        id_spec = id_spec or 'ID'
        add_kwargs = dict(
            id_spec=id_spec,
        )

    elif dialect['fmt'] == 'gtf':
        cls = _GTFDBCreator
        id_spec = id_spec or {'gene': 'gene_id', 'transcript': 'transcript_id'}
        add_kwargs = dict(
            transcript_key=gtf_transcript_key,
            gene_key=gtf_gene_key,
            subfeature=gtf_subfeature,
            id_spec=id_spec,
        )

    kwargs.update(**add_kwargs)
    kwargs['dialect'] = dialect
    c = cls(**kwargs)

    c.create()
    if dbfn == ':memory:':
        db = interface.FeatureDB(c.conn,
                                 keep_order=keep_order,
                                 pragmas=pragmas,
                                 sort_attribute_values=sort_attribute_values,
                                 text_factory=text_factory)
    else:
        db = interface.FeatureDB(c,
                                 keep_order=keep_order,
                                 pragmas=pragmas,
                                 sort_attribute_values=sort_attribute_values,
                                 text_factory=text_factory)

    return db
Create a database from a GFF or GTF file.
dataset/ETHPy150Open daler/gffutils/gffutils/create.py/create_db