#!/usr/bin/env python
# -*- coding: utf-8

import argparse

import anvio
import anvio.terminal as terminal
import anvio.clustering as clustering


__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()

parser = argparse.ArgumentParser(description='Takes an observation matrix, returns a newick tree')
parser.add_argument('input_matrix', metavar = 'PATH', default = None,
                    help = 'Input matrix')

parser.add_argument(*anvio.A('output-file'), **anvio.K('output-file'))
parser.add_argument(*anvio.A('transpose'), **anvio.K('transpose'))

args = parser.parse_args()

if not args.output_file:
    args.output_file = args.input_matrix + '.newick'

run.info('Input matrix file', args.input_matrix)
progress.new('Analyzing input file')
clustering.get_newick_tree_data(args.input_matrix, args.output_file, transpose = args.transpose, progress = progress)
progress.end()
run.info('Output newick', args.output_file)
