import os
import numpy
import shutil
import json
from shock import Client as ShockClient
from biokbase.CompressionBasedDistance.Helpers import extract_seq, run_command, make_job_dir, timestamp, CommandError
from biokbase.userandjobstate.client import UserAndJobState
from multiprocessing import Pool
from itertools import combinations
from biokbase import log

# String used to separate components in paired file names.
PairSeparator = '-cbdpair-'

# Exception thrown when extract sequences failed
class ExtractError(Exception):
    pass

# Exception thrown when sorting a sequence file failed
class SortError(Exception):
    pass

# Exception thrown when merging sequence files failed
class MergeError(Exception):
    pass

# Exception thrown when compressing a sequence file failed
class CompressError(Exception):
    pass

# Exception thrown when sequence files have different sequence lengths.
class SeqLenError(Exception):
    pass

# Exception thrown when saving a file to Shock failed.
class ShockError(Exception):
    pass

class CompressionBasedDistance:
    
    ''' Calculate the compression based distance metric and save distance matrix to a file.

        @param fileList List of paths to compressed files
        @param scale Scale of distance values, 'std' for 0 to 1, 'inf' for 0 to infinity