<commit_before>"""
Make genome annotations in GFF[1] files semantically interoperable according to the RDF[2] specification.

References:
[1] Generic Feature Format specification, http://www.sequenceontology.org/gff3.shtml
[2] Resource Description Framework, https://www.w3.org/TR/rdf11-concepts/

Usage:
  siga.py -h | --help
  siga.py -v | --version
  siga.py [-f FORMAT] [-o PATH] [-e EXT] [-r] FILE...

Arguments:
  FILE...       Input file(s) in GFF.

Options:
  -h, --help
  -v, --version
  -f FORMAT, --format=FORMAT  Select RDF serialization/format for output file(s) [default: turtle].
  -o PATH, --outpath=PATH     Select output directory [default: ./].
  -e EXT, --extension=EXT     GFF database file extension [default: .sqlite]
  -r, --replace               Replace existing GFF database file.
"""

__author__  = '<NAME>'
__version__ = 0.1
__status__  = 'Prototype'
__license__ = 'Apache License, Version 2.0'

import gffutils as gff
import os
from docopt import docopt


if __name__ == '__main__':
    args = docopt(__doc__, version=__version__)
    #print(args)

    for gff_file in args['FILE']:
        base_name = os.path.splitext(gff_file)[0]
        file_ext = args['--extension']
        if not file_ext.startswith('.'):
            file_ext = '.' + file_ext
        db_file = os.path.join(args['--outpath'], base_name + file_ext)
        db = gff.create_db(gff_file, db_file, force=args['--replace'])
<commit_msg>Update CLI: generate one db per GFF file or import all GFF files into a single db.<commit_after>"""
Generate semantically interoperable genome annotations from GFF[1] files according to the RDF[2] specification.

References:
[1] Generic Feature Format specification, http://www.sequenceontology.org/gff3.shtml
[2] Resource Description Framework, https://www.w3.org/TR/rdf11-concepts/

Usage:
  siga.py -h | --help
  siga.py -v | --version
  siga.py [-f FORMAT] [-d FILE] FILE...

Arguments:
  FILE...                     Input file(s) in GFF.

Options:
  -h, --help
  -v, --version
  -f FORMAT, --format=FORMAT  Select RDF serialization/format [default: turtle].
  -d FILE, --database=FILE    Populate GFF database(s) in SQLite.

"""

from __future__ import print_function
from docopt import docopt

import os
import gffutils as gff

__author__  = '<NAME>'
__version__ = 0.1
__status__  = 'Prototype'
__license__ = 'Apache License, Version 2.0'


if __name__ == '__main__':
    args = docopt(__doc__, version=__version__)
    print(args)

    db_file = args['--database']
    for gff_file in args['FILE']:
        # generate one db per GFF file
        if args['--database'] is None:
            base_name = os.path.splitext(gff_file)[0]
            db_file = base_name + '.sqlite'
            db = gff.create_db(gff_file, db_file, force=True)

        # import all GFF files into a single db
        elif os.path.exists(db_file) is True:
            db = gff.FeatureDB(db_file)
            db.update(gff_file)
        else:
            db = gff.create_db(gff_file, db_file, force=False)

{'fraction_non_alphanumeric': 0.12669533575917963, 'fraction_numerical': 0.008600727753886867, 'mean_word_length': 2.886889460154242, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '688216', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1016, 'n_words': 295}