예제 #1
0
def test_similarity():
    """FP similarity"""
    mols = list(
        oddt.toolkit.readfile(
            'sdf',
            os.path.join(test_data_dir, 'data/dude/xiap/actives_docked.sdf')))
    mols = list(filter(lambda x: x.title == '312335', mols))
    list(map(lambda x: x.addh(only_polar=True), mols))
    receptor = next(
        oddt.toolkit.readfile(
            'pdb',
            os.path.join(test_data_dir, 'data/dude/xiap/receptor_rdkit.pdb')))
    receptor.protein = True
    receptor.addh(only_polar=True)
    ref = SimpleInteractionFingerprint(mols[0], receptor)

    outcome = [
        dice(ref, SimpleInteractionFingerprint(mol, receptor))
        for mol in mols[1:]
    ]
    if oddt.toolkit.backend == 'ob':
        target_outcome = np.array([
            0.8, 0.625, 0.764706, 0.628571, 0.764706, 0.611111, 0.787879, 0.6,
            0.62069, 0.6875, 0.555556, 0.727273, 0.642857, 0.685714, 0.736842,
            0.666667, 0.484848, 0.533333, 0.588235
        ])
    else:
        target_outcome = np.array([
            0.810811, 0.625, 0.777778, 0.611111, 0.777778, 0.648649, 0.787879,
            0.6, 0.6, 0.666667, 0.578947, 0.742857, 0.62069, 0.628571,
            0.736842, 0.645161, 0.571429, 0.580645, 0.628571
        ])
    assert_array_almost_equal(outcome, target_outcome)

    outcome = [
        tanimoto(ref, SimpleInteractionFingerprint(mol, receptor))
        for mol in mols[1:]
    ]
    if oddt.toolkit.backend == 'ob':
        target_outcome = np.array([
            0.75, 0.5, 0.727273, 0.538462, 0.727273, 0.727273, 0.8, 0.636364,
            0.545455, 0.636364, 0.636364, 0.636364, 0.7, 0.727273, 0.75,
            0.636364, 0.454545, 0.454545, 0.416667
        ])
    else:
        target_outcome = np.array([
            0.75, 0.416667, 0.727273, 0.538462, 0.727273, 0.727273, 0.7,
            0.636364, 0.545455, 0.545455, 0.636364, 0.636364, 0.6, 0.636364,
            0.75, 0.545455, 0.545455, 0.454545, 0.416667
        ])
    assert_array_almost_equal(outcome, target_outcome)
예제 #2
0
def test_SimpleInteractionFingerprint():
    """Simple Interaction Fingerprint test """
    if oddt.toolkit.backend == 'ob':
        SIFP = np.array([
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3,
            1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0
        ])
    else:
        SIFP = np.array([
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0
        ])

    assert_array_equal(SIFP, SimpleInteractionFingerprint(ligand, protein))
예제 #3
0
def test_SimpleInteractionFingerprint():
    """Simple Interaction Fingerprint test """
    SIFP = [
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0
    ]
    assert_array_equal(SIFP, SimpleInteractionFingerprint(ligand, protein))
예제 #4
0
def test_similarity():
    """FP similarity"""
    mols = list(
        oddt.toolkit.readfile(
            'sdf',
            os.path.join(test_data_dir, 'data/dude/xiap/actives_docked.sdf')))
    mols = list(filter(lambda x: x.title == '312335', mols))
    list(map(lambda x: x.addh(only_polar=True), mols))
    receptor = next(
        oddt.toolkit.readfile(
            'pdb',
            os.path.join(test_data_dir, 'data/dude/xiap/receptor_rdkit.pdb')))
    receptor.protein = True
    receptor.addh(only_polar=True)
    ref = SimpleInteractionFingerprint(mols[0], receptor)

    outcome = [
        dice(ref, SimpleInteractionFingerprint(mol, receptor))
        for mol in mols[1:]
    ]
    target_outcome = np.array([
        0.742857, 0.645161, 0.727273, 0.571429, 0.727273, 0.588235, 0.75,
        0.551724, 0.551724, 0.6875, 0.514286, 0.6875, 0.592593, 0.647059,
        0.736842, 0.62069, 0.545455, 0.533333, 0.606061
    ])
    assert_array_almost_equal(outcome, target_outcome)

    outcome = [
        tanimoto(ref, SimpleInteractionFingerprint(mol, receptor))
        for mol in mols[1:]
    ]
    target_outcome = np.array([
        0.636364, 0.5, 0.666667, 0.384615, 0.666667, 0.545455, 0.666667, 0.5,
        0.363636, 0.666667, 0.555556, 0.555556, 0.625, 0.6, 0.727273, 0.555556,
        0.5, 0.4, 0.363636
    ])
    assert_array_almost_equal(outcome, target_outcome)
예제 #5
0
def test_IFP_SIFP_Folding_cum_sum():
    """Checks, whether InteractionFingerprint and SimpleInteractionFingerprint outcomes matches"""
    IFP = np.sum(InteractionFingerprint(ligand, protein), axis=0)
    SIFP = np.sum(SimpleInteractionFingerprint(ligand, protein), axis=0)
    assert_array_equal(IFP, SIFP)