# Path: picrust/evaluate_test_datasets.py
# def calculate_accuracy_stats_from_observations(obs,exp,success_criterion='binary',\
#   verbose=False):
#     """Return statistics derived from the confusion matrix
#     obs -- a list of floats representing observed values
#     exp -- a list of floats for expected values (same order as obs)
#     verbose -- print verbose output
#     """
# 
#     tp,fp,fn,tn =\
#       confusion_matrix_from_data(obs,exp,success_criterion=success_criterion,verbose=verbose)
# 
#     result =\
#       calculate_accuracy_stats_from_confusion_matrix(tp,fp,fn,tn,verbose=verbose)
# 
#     result['sum_expected']=sum(exp)
#     result['sum_observed']=sum(obs)
# 
#     #pearson correlation (using new method from pycogent 1.5.3)
#     pearson_r,pearson_para_p,pearson_permuted_r,pearson_nonpara_p,pearson_ci =correlation_test(obs,exp,method='pearson',permutations=0)
#     result['pearson_r']=pearson_r
#     #result['pearson_permuted_r']=pearson_permuted_r
#     #result['pearson_nonpara_p']=pearson_nonpara_p
#     result['pearson_p']=pearson_para_p
#     #result['pearson_ci']=pearson_ci
#     result['pearson_r2']=pearson_r**2
# 
#     #spearman correlation (using new method from pycogent 1.5.3)
#     spearman_r,spearman_para_p,spearman_permuted_r,spearman_nonpara_p,spearman_ci =correlation_test(obs,exp,method='spearman',permutations=0)
#     result['spearman_r']=spearman_r
#     #result['spearman_permuted_r']=spearman_permuted_r
#     #result['spearman_nonpara_p']=spearman_nonpara_p
#     result['spearman_p']=spearman_para_p
#     #result['spearman_ci']=spearman_ci
#     result['spearman_r2']=spearman_r**2
# 
#     #add in correlations (old)
#     #pearson_r,pearson_t_prob =correlation(obs,exp)
#     #result['pearson']=pearson_r
#     #result['pearson_prob']=pearson_t_prob
#     #result['pearson_r2']=pearson_r**2
# 
#     #spearman_r,spearman_t_prob =spearman_correlation(obs,exp)
#     #result['spearman']=spearman_r
#     #result['spearman_prob']=spearman_t_prob
#     #result['spearman_r2']=spearman_r**2
#     return result
# 
# Path: picrust/util.py
# def make_output_dir_for_file(filepath):
#     """Create sub-directories for a new file if they don't already exist"""
#     dirpath = dirname(filepath)
#     if not isdir(dirpath) and not dirpath == '':
#         makedirs(dirpath)


from collections import defaultdict
from os import listdir
from numpy import array,ravel,asarray
from os.path import join,basename
from cogent.util.option_parsing import parse_command_line_parameters,\
  make_option
from picrust.evaluate_test_datasets import calculate_accuracy_stats_from_observations
from biom import load_table, Table
from picrust.util import make_output_dir_for_file
from random import shuffle


    if shuffle_samples:
        if verbose:
            print "Randomly shufflying sample ids..."
        sample_ids_to_shuffle=overlapping_sample_ids[:]
        shuffle(sample_ids_to_shuffle)

        for index in range(len(overlapping_sample_ids)):
            obs_data[overlapping_sample_ids[index]]=observed_table.data(sample_ids_to_shuffle[index])
    else:
        for sample_id in overlapping_sample_ids:
            obs_data[sample_id]=observed_table.data(sample_id)

    return obs_data,exp_data



def main():
    option_parser, opts, args =\
       parse_command_line_parameters(**script_info)

    verbose=opts.verbose

    min_args = 1
    if len(args) < min_args:
       option_parser.error('One or more predicted biom files must be provided.')
    observed_files=args



# Path: picrust/evaluate_test_datasets.py
# def calculate_accuracy_stats_from_observations(obs,exp,success_criterion='binary',\
#   verbose=False):
#     """Return statistics derived from the confusion matrix
#     obs -- a list of floats representing observed values
#     exp -- a list of floats for expected values (same order as obs)
#     verbose -- print verbose output
#     """
# 
#     tp,fp,fn,tn =\
#       confusion_matrix_from_data(obs,exp,success_criterion=success_criterion,verbose=verbose)
# 
#     result =\
#       calculate_accuracy_stats_from_confusion_matrix(tp,fp,fn,tn,verbose=verbose)
# 
#     result['sum_expected']=sum(exp)
#     result['sum_observed']=sum(obs)
# 
#     #pearson correlation (using new method from pycogent 1.5.3)
#     pearson_r,pearson_para_p,pearson_permuted_r,pearson_nonpara_p,pearson_ci =correlation_test(obs,exp,method='pearson',permutations=0)
#     result['pearson_r']=pearson_r
#     #result['pearson_permuted_r']=pearson_permuted_r
#     #result['pearson_nonpara_p']=pearson_nonpara_p
#     result['pearson_p']=pearson_para_p
#     #result['pearson_ci']=pearson_ci
#     result['pearson_r2']=pearson_r**2
# 
#     #spearman correlation (using new method from pycogent 1.5.3)
#     spearman_r,spearman_para_p,spearman_permuted_r,spearman_nonpara_p,spearman_ci =correlation_test(obs,exp,method='spearman',permutations=0)
#     result['spearman_r']=spearman_r
#     #result['spearman_permuted_r']=spearman_permuted_r
#     #result['spearman_nonpara_p']=spearman_nonpara_p
#     result['spearman_p']=spearman_para_p
#     #result['spearman_ci']=spearman_ci
#     result['spearman_r2']=spearman_r**2
# 
#     #add in correlations (old)
#     #pearson_r,pearson_t_prob =correlation(obs,exp)
#     #result['pearson']=pearson_r
#     #result['pearson_prob']=pearson_t_prob
#     #result['pearson_r2']=pearson_r**2
# 
#     #spearman_r,spearman_t_prob =spearman_correlation(obs,exp)
#     #result['spearman']=spearman_r
#     #result['spearman_prob']=spearman_t_prob
#     #result['spearman_r2']=spearman_r**2
#     return result
# 
# Path: picrust/util.py
# def make_output_dir_for_file(filepath):
#     """Create sub-directories for a new file if they don't already exist"""
#     dirpath = dirname(filepath)
#     if not isdir(dirpath) and not dirpath == '':
#         makedirs(dirpath)


# Path: scripts/compare_biom.py
from collections import defaultdict
from os import listdir
from numpy import array,ravel,asarray
from os.path import join,basename
from cogent.util.option_parsing import parse_command_line_parameters,\
  make_option
from picrust.evaluate_test_datasets import calculate_accuracy_stats_from_observations
from biom import load_table, Table
from picrust.util import make_output_dir_for_file
from random import shuffle



    if shuffle_samples:
        if verbose:
            print "Randomly shufflying sample ids..."
        sample_ids_to_shuffle=overlapping_sample_ids[:]
        shuffle(sample_ids_to_shuffle)

        for index in range(len(overlapping_sample_ids)):
            obs_data[overlapping_sample_ids[index]]=observed_table.data(sample_ids_to_shuffle[index])
    else:
        for sample_id in overlapping_sample_ids:
            obs_data[sample_id]=observed_table.data(sample_id)

    return obs_data,exp_data



def main():
    option_parser, opts, args =\
       parse_command_line_parameters(**script_info)

    verbose=opts.verbose

    min_args = 1
    if len(args) < min_args:
       option_parser.error('One or more predicted biom files must be provided.')
    observed_files=args



    make_output_dir_for_file(opts.output_fp)