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

import sys

import anvio
import anvio.utils as utils
import anvio.terminal as terminal

from anvio.errors import ConfigError, FilesNPathsError

__author__ = "Developers of anvi'o (see AUTHORS.txt)"
__copyright__ = "Copyleft 2015-2018, the Meren Lab (http://merenlab.org/)"
__credits__ = []
__license__ = "GPL 3.0"
__version__ = anvio.__version__
__maintainer__ = "A. Murat Eren"
__email__ = "a.murat.eren@gmail.com"


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


def main(args):
    utils.transpose_tab_delimited_file(args.input_file, args.output_file)


if __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser(description="Transpose a TAB-delimited file")

    parser.add_argument('input_file', help="Input matrix.", metavar='MATRIX_FILE')
    parser.add_argument(*anvio.A('output-file'), **anvio.K('output-file', {'required': True, 'metavar':'MATRIX_FILE'}))

    args = anvio.get_args(parser)

    try:
        main(args)
    except ConfigError as e:
        print(e)
        sys.exit(-1)
    except FilesNPathsError as e:
        print(e)
        sys.exit(-2)
