def objective(pArgs):

    if pArgs['dimensionsPCA'] <= pArgs['umap_n_components']:
        return 1

    intraChromosomalContactsOnly = ''
    noPCA = ''
    noUMAP = ''
    if pArgs['intraChromosomalContactsOnly']:
        intraChromosomalContactsOnly = '-ic'
    if pArgs['noPCA']:
        noPCA = '--noPCA'

    args = "-m {} -c {} -cm {} -o ramani_1mb_kmeans_c5.txt -t {} -k {} -nh {}  -dim_pca {} " \
        " -cct {} --colorMap glasbey_dark  {} {} {} "\
        "--umap_n_neighbors {} " \
        "--umap_n_components {}  " \
        "--umap_min_dist {}".format(
            pArgs['matrixFile'], pArgs['numberOfClusters'], pArgs['clusterMethod'], pArgs['threads'],
            pArgs['numberOfNearestNeighbors'], pArgs['numberOfHashFunctions'],
            pArgs['dimensionsPCA'], pArgs['cell_coloring_type'],
            intraChromosomalContactsOnly, noPCA, noUMAP,
            pArgs['umap_n_neighbors'], pArgs['umap_n_components'], pArgs['umap_min_dist']).split()
    scHicClusterMinHash.main(args)

    with open('correct_associated', 'r') as file:
        error_score = 1 - float(file.readline().strip())

    print('Error score: {}'.format(error_score))
    return error_score
def test_kmeans_exact():
    outfile = NamedTemporaryFile(suffix='.txt', delete=False)

    outfile.close()
    args = "--matrix {} --numberOfClusters {} --clusterMethod {} \
        --outFileName {} -t {} -nh {} --exactModeMinHash".format(
        ROOT + 'test_matrix.mcool', 3, 'kmeans', outfile.name, 2, 800).split()
    scHicClusterMinHash.main(args)
    assert are_files_equal(
        ROOT + "scHicClusterMinHash/cluster_kmeans_exact.txt", outfile.name)
def test_spectral_chromosomes():
    outfile = NamedTemporaryFile(suffix='.txt', delete=False)

    outfile.close()
    args = "--matrix {} --numberOfClusters {} --clusterMethod {} \
        --outFileName {} -t {} -nh {} --chromosomes {} ".format(
        ROOT + 'test_matrix.mcool', 3, 'spectral', outfile.name, 2, 800,
        "chr1 chr2").split()
    scHicClusterMinHash.main(args)
    assert are_files_equal(
        ROOT + "scHicClusterMinHash/cluster_spectral_chromosomes.txt",
        outfile.name)
def test_version():
    args = "--version".split()
    with pytest.raises(SystemExit) as pytest_wrapped_e:
        scHicClusterMinHash.main(args)
    assert pytest_wrapped_e.type == SystemExit
    assert pytest_wrapped_e.value.code == 0