# Path: ssbio/utils.py
# def is_ipynb():
#     def __init__(self):
# def todays_short_date():
# def todays_long_date():
#     def __init__(self, default_factory=None, *a, **kw):
#     def __getitem__(self, key):
#     def __missing__(self, key):
#     def __reduce__(self):
#     def copy(self):
#     def __copy__(self):
#     def __deepcopy__(self, memo):
#     def __repr__(self):
# def suppress_stdout():
# def clean_df(df, fill_nan=True, drop_empty_columns=True):
# def clean_single_dict(indict, prepend_to_keys=None, remove_keys_containing=None):
# def split_mutation_string(instring):
# def double_check_attribute(object, setter, backup_attribute, custom_error_text=None):
# def split_folder_and_path(filepath):
# def is_non_zero_file(fpath):
# def outfile_maker(inname, outext='.out', outname='', outdir='', append_to_name=''):
# def force_rerun(flag, outfile):
# def gunzip_file(infile, outfile=None, outdir=None, delete_original=False, force_rerun_flag=False):
# def request_file(link, outfile, force_rerun_flag=False):
# def request_json(link, outfile, force_rerun_flag, outdir=None):
# def program_exists(prog_name):
# def command_runner(shell_command, force_rerun_flag, outfile_checker, cwd=None, silent=False):
# def execute(cmd, cwd=None):
# def write_torque_script(command, outfile, walltime, queue, name, out, err, print_exec=True):
# def dict_head(d, N=5):
# def rank_dated_files(pattern, dir, descending=True):
# def find(lst, a, case_sensitive=True):
# def not_find(lst, a, case_sensitive=True):
# def filter_list(lst, takeout, case_sensitive=True):
# def filter_list_by_indices(lst, indices):
# def force_string(val=None):
# def force_list(val=None):
# def force_lower_list(val=None):
# def force_upper_list(val=None):
# def split_list_by_n(l, n):
# def split_list_into_n_lists(l, n):
# def input_list_parser(infile_list):
# def flatlist_dropdup(list_of_lists):
# def combinations(iterable, r):
# def percentage_to_float(x):
# def conv_to_float(indata, inf_str=''):
# def make_dir(path):
# def remap( x, oMin, oMax, nMin, nMax ):
# def scale_calculator(multiplier, elements, rescale=None):
# def label_sequential_regions(inlist):
# def check_condition(left, condition, right):
# class Date():
# class DefaultOrderedDict(OrderedDict):


import os
import subprocess
import pandas as pd
import os.path as op
import logging
from ssbio import utils
    from IPython.display import clear_output
    from tqdm import tqdm_notebook as tqdm
    from tqdm import tqdm
        else:
            log.error('Error running makeblastdb, exit code {}'.format(retval))


def run_bidirectional_blast(reference, other_genome, dbtype, outdir=''):
    """BLAST a genome against another, and vice versa.

    This function requires BLAST to be installed, do so by running:
    sudo apt install ncbi-blast+

    Args:
        reference (str): path to "reference" genome, aka your "base strain"
        other_genome (str): path to other genome which will be BLASTed to the reference
        dbtype (str): "nucl" or "prot" - what format your genome files are in
        outdir (str): path to folder where BLAST outputs should be placed

    Returns:
        Paths to BLAST output files.
        (reference_vs_othergenome.out, othergenome_vs_reference.out)

    """
    # TODO: add force_rerun option

    if dbtype == 'nucl':
        command = 'blastn'
    elif dbtype == 'prot':
        command = 'blastp'
    else:
        raise ValueError('dbtype must be "nucl" or "prot"')


# Path: ssbio/utils.py
# def is_ipynb():
#     def __init__(self):
# def todays_short_date():
# def todays_long_date():
#     def __init__(self, default_factory=None, *a, **kw):
#     def __getitem__(self, key):
#     def __missing__(self, key):
#     def __reduce__(self):
#     def copy(self):
#     def __copy__(self):
#     def __deepcopy__(self, memo):
#     def __repr__(self):
# def suppress_stdout():
# def clean_df(df, fill_nan=True, drop_empty_columns=True):
# def clean_single_dict(indict, prepend_to_keys=None, remove_keys_containing=None):
# def split_mutation_string(instring):
# def double_check_attribute(object, setter, backup_attribute, custom_error_text=None):
# def split_folder_and_path(filepath):
# def is_non_zero_file(fpath):
# def outfile_maker(inname, outext='.out', outname='', outdir='', append_to_name=''):
# def force_rerun(flag, outfile):
# def gunzip_file(infile, outfile=None, outdir=None, delete_original=False, force_rerun_flag=False):
# def request_file(link, outfile, force_rerun_flag=False):
# def request_json(link, outfile, force_rerun_flag, outdir=None):
# def program_exists(prog_name):
# def command_runner(shell_command, force_rerun_flag, outfile_checker, cwd=None, silent=False):
# def execute(cmd, cwd=None):
# def write_torque_script(command, outfile, walltime, queue, name, out, err, print_exec=True):
# def dict_head(d, N=5):
# def rank_dated_files(pattern, dir, descending=True):
# def find(lst, a, case_sensitive=True):
# def not_find(lst, a, case_sensitive=True):
# def filter_list(lst, takeout, case_sensitive=True):
# def filter_list_by_indices(lst, indices):
# def force_string(val=None):
# def force_list(val=None):
# def force_lower_list(val=None):
# def force_upper_list(val=None):
# def split_list_by_n(l, n):
# def split_list_into_n_lists(l, n):
# def input_list_parser(infile_list):
# def flatlist_dropdup(list_of_lists):
# def combinations(iterable, r):
# def percentage_to_float(x):
# def conv_to_float(indata, inf_str=''):
# def make_dir(path):
# def remap( x, oMin, oMax, nMin, nMax ):
# def scale_calculator(multiplier, elements, rescale=None):
# def label_sequential_regions(inlist):
# def check_condition(left, condition, right):
# class Date():
# class DefaultOrderedDict(OrderedDict):


# Path: ssbio/protein/sequence/utils/blast.py
import os
import subprocess
import pandas as pd
import os.path as op
import logging
from ssbio import utils
    from IPython.display import clear_output
    from tqdm import tqdm_notebook as tqdm
    from tqdm import tqdm

        else:
            log.error('Error running makeblastdb, exit code {}'.format(retval))


def run_bidirectional_blast(reference, other_genome, dbtype, outdir=''):
    """BLAST a genome against another, and vice versa.

    This function requires BLAST to be installed, do so by running:
    sudo apt install ncbi-blast+

    Args:
        reference (str): path to "reference" genome, aka your "base strain"
        other_genome (str): path to other genome which will be BLASTed to the reference
        dbtype (str): "nucl" or "prot" - what format your genome files are in
        outdir (str): path to folder where BLAST outputs should be placed

    Returns:
        Paths to BLAST output files.
        (reference_vs_othergenome.out, othergenome_vs_reference.out)

    """
    # TODO: add force_rerun option

    if dbtype == 'nucl':
        command = 'blastn'
    elif dbtype == 'prot':
        command = 'blastp'
    else:
        raise ValueError('dbtype must be "nucl" or "prot"')


    r_folder, r_name, r_ext = utils.split_folder_and_path(reference)