<filename>test/test_cluster.py
from hw2skeleton import cluster
from hw2skeleton import io
import os


def test_similarity():
    filename_a = os.path.join("data", "276.pdb")
    filename_b = os.path.join("data", "4629.pdb")

    activesite_a = io.read_active_site(filename_a)
    activesite_b = io.read_active_site(filename_b)

    # update this assertion
    assert cluster.compute_similarity(activesite_a, activesite_b) == 7.6923076923076925

def test_distance(): #test that similarity between two same ones is 100%
    filename_a = os.path.join("data", "276.pdb")
    filename_b = os.path.join("data", "276.pdb")

    activesite_a = io.read_active_site(filename_a)
    activesite_b = io.read_active_site(filename_b)

     # update this assertion
    assert cluster.compute_similarity(activesite_a, activesite_b) == 100.0

def test_partition_clustering():
    # tractable subset
    pdb_ids = [276, 4629, 10701]

    active_sites = []
    for id in pdb_ids:
        filepath = os.path.join("data", "%i.pdb"%id)
        active_sites.append(io.read_active_site(filepath))

    # update this assertion
    assert cluster.cluster_by_partitioning(active_sites) == [[2], [], [0, 1]]
    #K = 3, expect 3 clusters, get 3 clusters

def test_hierarchical_clustering():
    # tractable subset
    pdb_ids = [276, 4629, 10701]

    active_sites = []
    for id in pdb_ids:
        filepath = os.path.join("data", "%i.pdb"%id)
        active_sites.append(io.read_active_site(filepath))

    # update this assertion
    assert cluster.cluster_hierarchically(active_sites) == [[1, 0], 2]

def test_clustering_comparison():
    # tractable subset
    pdb_ids = [276, 4629, 10701]

    active_sites = []
    for id in pdb_ids:
        filepath = os.path.join("data", "%i.pdb"%id)
        active_sites.append(io.read_active_site(filepath))

    # update this assertion
    assert cluster.comparison([[active_sites[0]], active_sites[1:]], active_sites) == -1.0675813711911358

<filename>test/test_cluster.py
from hw2skeleton import cluster
from hw2skeleton import io
import os


def test_similarity():
    filename_a = os.path.join("data", "276.pdb")
    filename_b = os.path.join("data", "4629.pdb")

    activesite_a = io.read_active_site(filename_a)
    activesite_b = io.read_active_site(filename_b)

    # update this assertion
    assert cluster.compute_similarity(activesite_a, activesite_b) == 7.6923076923076925

def test_distance(): #test that similarity between two same ones is 100%
    filename_a = os.path.join("data", "276.pdb")
    filename_b = os.path.join("data", "276.pdb")

    activesite_a = io.read_active_site(filename_a)
    activesite_b = io.read_active_site(filename_b)

     # update this assertion
    assert cluster.compute_similarity(activesite_a, activesite_b) == 100.0

def test_partition_clustering():
    # tractable subset
    pdb_ids = [276, 4629, 10701]

    active_sites = []
    for id in pdb_ids:
        filepath = os.path.join("data", "%i.pdb"%id)
        active_sites.append(io.read_active_site(filepath))

    # update this assertion
    assert cluster.cluster_by_partitioning(active_sites) == [[2], [], [0, 1]]
    #K = 3, expect 3 clusters, get 3 clusters

def test_hierarchical_clustering():
    # tractable subset
    pdb_ids = [276, 4629, 10701]

    active_sites = []
    for id in pdb_ids:
        filepath = os.path.join("data", "%i.pdb"%id)
        active_sites.append(io.read_active_site(filepath))

    # update this assertion
    assert cluster.cluster_hierarchically(active_sites) == [[1, 0], 2]

def test_clustering_comparison():
    # tractable subset
    pdb_ids = [276, 4629, 10701]

    active_sites = []
    for id in pdb_ids:
        filepath = os.path.join("data", "%i.pdb"%id)
        active_sites.append(io.read_active_site(filepath))

    # update this assertion
    assert cluster.comparison([[active_sites[0]], active_sites[1:]], active_sites) == -1.0675813711911358

# update this assertion #test that similarity between two same ones is 100% # update this assertion # tractable subset # update this assertion #K = 3, expect 3 clusters, get 3 clusters # tractable subset # update this assertion # tractable subset # update this assertion