#!/usr/bin/env python3
__author__ = "Fredrik Boulund"
__date__ = "2016"
__doc__ = """Merge taxonomic read assignments produced by Kaiju, Kraken, and CLARK-S."""
__version__ = "1.0"

from sys import argv, exit, stdout
from os import path
import argparse
import sqlite3
import logging
import time
from itertools import chain, combinations, islice
from collections import namedtuple, defaultdict


def grouper(n, iterable):
    """Groups an iterable into n-sized chunks.

    :param n:  number of items per chunk.
    :param iterable:  an iterable to divide into chunks of size n.
    :return:  n-sized chunks from the iterable.
    """
    it = iter(iterable)
    while True:
       chunk = tuple(islice(it, n))
       if not chunk:
           return
       yield chunk


def parse_args():
    """Parse command line arguments.

    Returns: 
        options  argparse options namespace
        logger   logger instance
    """

    desc = """Merge read classifications from Kaiju, Kraken, and CLARK-S. 
              Copyright (c) {author} {date}. 
              Version {version}.""".format(author=__author__, 
                                           date=__date__,
                                           version=__version__)
    epilog = """Redefine merge order to decide classification priority; 
    classifications are overwritten according to merge order.