#!/opt/anaconda1anaconda2anaconda3/bin/python
# -*- coding: utf-8

import sys

import anvio
import anvio.dbops as dbops
import anvio.terminal as terminal

from anvio.errors import ConfigError, FilesNPathsError, SamplesError


__author__ = "A. Murat Eren"
__copyright__ = "Copyright 2015, The anvio Project"
__credits__ = []
__license__ = "GPL 3.0"
__version__ = anvio.__version__
__maintainer__ = "A. Murat Eren"
__email__ = "a.murat.eren@gmail.com"


run = terminal.Run()
progress = terminal.Progress()


if __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser(description="Create a new anvi'o samples information database.")

    parser.add_argument(*anvio.A('samples-information'), **anvio.K('samples-information'))
    parser.add_argument(*anvio.A('samples-order'), **anvio.K('samples-order'))
    parser.add_argument(*anvio.A('output-db-path'), **anvio.K('output-db-path', {'default': 'SAMPLES.db'}))

    args = parser.parse_args()

    try:
        s = dbops.SamplesInformationDatabase(args.output_db_path, run, progress, quiet=False)
        s.create(args.samples_information, args.samples_order)
    except ConfigError as e:
        print(e)
        sys.exit(-1)
    except FilesNPathsError as e:
        print(e)
        sys.exit(-2)
    except SamplesError as e:
        print(e)
        sys.exit(-3)
