# 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():


from collections import Counter
from StringIO import StringIO
from abtools import log, mongodb
import itertools
import math
import multiprocessing as mp
import os
import random
import sqlite3
import subprocess as sp
import sys
import tempfile
import time
import urllib
import uuid
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
    import argparse
        s1, s2 = pair
        curr1 = s1
        if prev1 != curr1:
            print_collection_info(s1)
            s1_all_vgenes = get_vgenes(db, s1, args.chain)
        print_pair_info(s1, s2)
        s1_vgenes, s2_vgenes = get_vgenes(db, s2, args.chain, prev_data=s1_all_vgenes)
        logger.info('')
        logger.info('Calculating similarities...')
        median, counts, bins, similarities = calculate_similarities(s1_vgenes,
                                                                    s2_vgenes,
                                                                    args)
        write_output(s1, s2, median, counts, bins, similarities, args)
        scores = update_scores(s1, s2, median, scores)
        if args.control_similarity:
            logger.info('')
            logger.info('Calculating control similarities...')
            cmedian, ccounts, cbins, csimilarities = calculate_control_similarities(s1_vgenes,
                                                                                    s2_vgenes,
                                                                                    args)
            write_output(s1, s2, cmedian, ccounts, cbins, csimilarities, args)
            cscores = update_scores(s1, s2, cmedian, cscores)
        prev1 = s1
    print_final_results(scores)
    print_final_results(cscores, control=True)


if __name__ == '__main__':
    parser = parse_args()
    args = parser.parse_args()

# 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/_compare.py
from collections import Counter
from StringIO import StringIO
from abtools import log, mongodb
import itertools
import math
import multiprocessing as mp
import os
import random
import sqlite3
import subprocess as sp
import sys
import tempfile
import time
import urllib
import uuid
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
    import argparse

        s1, s2 = pair
        curr1 = s1
        if prev1 != curr1:
            print_collection_info(s1)
            s1_all_vgenes = get_vgenes(db, s1, args.chain)
        print_pair_info(s1, s2)
        s1_vgenes, s2_vgenes = get_vgenes(db, s2, args.chain, prev_data=s1_all_vgenes)
        logger.info('')
        logger.info('Calculating similarities...')
        median, counts, bins, similarities = calculate_similarities(s1_vgenes,
                                                                    s2_vgenes,
                                                                    args)
        write_output(s1, s2, median, counts, bins, similarities, args)
        scores = update_scores(s1, s2, median, scores)
        if args.control_similarity:
            logger.info('')
            logger.info('Calculating control similarities...')
            cmedian, ccounts, cbins, csimilarities = calculate_control_similarities(s1_vgenes,
                                                                                    s2_vgenes,
                                                                                    args)
            write_output(s1, s2, cmedian, ccounts, cbins, csimilarities, args)
            cscores = update_scores(s1, s2, cmedian, cscores)
        prev1 = s1
    print_final_results(scores)
    print_final_results(cscores, control=True)


if __name__ == '__main__':
    parser = parse_args()
    args = parser.parse_args()

    logfile = args.log if args.log else os.path.join(args.output, 'abcompare.log')