# Path: abtools/color.py
# def cmap_from_color(color, dark=False):
# def hex_to_rgb(hex_string):
# def rgb_to_hex(rgb_tuple):
# def hls(n_colors, hue=0.01, lightness=0.6, saturation=0.65):
# def husl(n_colors, hue=0.01, saturation=0.9, lightness=0.65):
# def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=256):
# def stack_colormap(lower, upper, n=256):
# def get_cmap(cmap=None, name=None, from_color=None, dark=False, n=256):
#     A = get_cmap(lower)
#     B = get_cmap(upper)
#         A = np.loadtxt(cmap, delimiter=None)  # None: white space
#         A = cmap  # numpy array or array-like
# 
# Path: abtools/log.py
# def setup_logging(logfile, print_log_location=True, debug=False):
# def get_logger(name=None):
# def add_stream_handler(logger):
# def make_dir(d):
# 
# Path: abtools/mongodb.py
# def get_connection(ip='localhost', port=27017, user=None, password=None):
# def get_db(db, ip='localhost', port=27017, user=None, password=None):
# def get_collections(db, collection=None, prefix=None, suffix=None):
# def rename_collection(db, collection, new_name):
# def update(field, value, db, collection, match=None):
# def unset(db, collection, field, match=None):
# def mongoimport(json, database,
#                 ip='localhost', port=27017,
#                 user=None, password=None,
#                 delim='_', delim1=None, delim2=None,
#                 delim_occurance=1, delim1_occurance=1, delim2_occurance=1):
# def index(db, collection, fields, directions=None, desc=False, background=False):
# def remove_padding(db, collection, field='padding'):
# def _get_import_collections(jsons, delim, delim_occurance,
#                             delim1, delim1_occurance,
#                             delim2, delim2_occurance):
# def _print_mongoimport_info(logger):
# def _print_remove_padding():
# 
# Path: abtools/utils/progbar.py
# def progress_bar(finished, total, start_time=None):


import multiprocessing as mp
import platform
import os
import subprocess as sp
import sys
import tempfile
import time
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
    import argparse
from threading import Thread
from pymongo import MongoClient
from Bio import SeqIO
from abtools import color, log, mongodb
from abtools.utils import progbar
    from abtools.queue.tasks import identity
    from abtools.queue.tasks import identity
                        help="Colormap to be used in the AbFinder hexbin plots. \
                        Can accept a matplotlib cmap or the name of one of matplotlib's builtin cmaps. \
                        Default is 'Blues'.")
    parser.add_argument('--mincount', dest='mincount', default=3, type=int,
                        help="Minimum number of sequences in a hexbin for that hexbin to be colored. \
                        Default is 3.")
    parser.add_argument('--skip-padding', dest='remove_padding', default=True, action='store_false',
                        help="If set, will not remove padding field from MongoDB.")
    parser.add_argument('-D', '--debug', dest="debug", action='store_true', default=False,
                        help="If set, will write all failed/exception sequences to file \
                        and should give more informative errors.")
    return parser


class Args(object):
    def __init__(self, db=None, collection=None,
                 output=None, temp=None, log=None, cluster=False,
                 ip='localhost', port=27017, user=None, password=None, update=True,
                 standard=None, chain='heavy', is_aa=True,
                 x_min=-1, x_max=35, y_min=65, y_max=101, gridsize=0, mincount=3,
                 colormap='Blues', debug=False):
        super(Args, self).__init__()
        if not all([db, output, temp, standard]):
            err = 'You must provide a MongoDB database name, output and temp directories, \
                and a file containing one or more comparison (standard) sequences in FASTA format.'
            raise RuntimeError(err)
        self.db = db
        self.collection = collection
        self.output_dir = output
        self.temp_dir = temp

# Path: abtools/color.py
# def cmap_from_color(color, dark=False):
# def hex_to_rgb(hex_string):
# def rgb_to_hex(rgb_tuple):
# def hls(n_colors, hue=0.01, lightness=0.6, saturation=0.65):
# def husl(n_colors, hue=0.01, saturation=0.9, lightness=0.65):
# def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=256):
# def stack_colormap(lower, upper, n=256):
# def get_cmap(cmap=None, name=None, from_color=None, dark=False, n=256):
#     A = get_cmap(lower)
#     B = get_cmap(upper)
#         A = np.loadtxt(cmap, delimiter=None)  # None: white space
#         A = cmap  # numpy array or array-like
# 
# Path: abtools/log.py
# def setup_logging(logfile, print_log_location=True, debug=False):
# def get_logger(name=None):
# def add_stream_handler(logger):
# def make_dir(d):
# 
# Path: abtools/mongodb.py
# def get_connection(ip='localhost', port=27017, user=None, password=None):
# def get_db(db, ip='localhost', port=27017, user=None, password=None):
# def get_collections(db, collection=None, prefix=None, suffix=None):
# def rename_collection(db, collection, new_name):
# def update(field, value, db, collection, match=None):
# def unset(db, collection, field, match=None):
# def mongoimport(json, database,
#                 ip='localhost', port=27017,
#                 user=None, password=None,
#                 delim='_', delim1=None, delim2=None,
#                 delim_occurance=1, delim1_occurance=1, delim2_occurance=1):
# def index(db, collection, fields, directions=None, desc=False, background=False):
# def remove_padding(db, collection, field='padding'):
# def _get_import_collections(jsons, delim, delim_occurance,
#                             delim1, delim1_occurance,
#                             delim2, delim2_occurance):
# def _print_mongoimport_info(logger):
# def _print_remove_padding():
# 
# Path: abtools/utils/progbar.py
# def progress_bar(finished, total, start_time=None):


# Path: abtools/_finder.py
import multiprocessing as mp
import platform
import os
import subprocess as sp
import sys
import tempfile
import time
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
    import argparse
from threading import Thread
from pymongo import MongoClient
from Bio import SeqIO
from abtools import color, log, mongodb
from abtools.utils import progbar
    from abtools.queue.tasks import identity
    from abtools.queue.tasks import identity

                        help="Colormap to be used in the AbFinder hexbin plots. \
                        Can accept a matplotlib cmap or the name of one of matplotlib's builtin cmaps. \
                        Default is 'Blues'.")
    parser.add_argument('--mincount', dest='mincount', default=3, type=int,
                        help="Minimum number of sequences in a hexbin for that hexbin to be colored. \
                        Default is 3.")
    parser.add_argument('--skip-padding', dest='remove_padding', default=True, action='store_false',
                        help="If set, will not remove padding field from MongoDB.")
    parser.add_argument('-D', '--debug', dest="debug", action='store_true', default=False,
                        help="If set, will write all failed/exception sequences to file \
                        and should give more informative errors.")
    return parser


class Args(object):
    def __init__(self, db=None, collection=None,
                 output=None, temp=None, log=None, cluster=False,
                 ip='localhost', port=27017, user=None, password=None, update=True,
                 standard=None, chain='heavy', is_aa=True,
                 x_min=-1, x_max=35, y_min=65, y_max=101, gridsize=0, mincount=3,
                 colormap='Blues', debug=False):
        super(Args, self).__init__()
        if not all([db, output, temp, standard]):
            err = 'You must provide a MongoDB database name, output and temp directories, \
                and a file containing one or more comparison (standard) sequences in FASTA format.'
            raise RuntimeError(err)
        self.db = db
        self.collection = collection
        self.output_dir = output
        self.temp_dir = temp

        self.log = log