예제 #1
0
def test_mol2graph_single_rings():
    mol = me.get_mol(
        'O=C(Cn1nc(C(=O)[O-])c2ccccc2c1=O)Nc1ccc2c(c1)C(=O)c1ccccc1C2=O')
    result = mr.mol2graph_single(mol, include_rings=True)

    assert 'ring_bond_idx' in result
    assert 'ring_bond_order' in result

    assert len(result['ring_bond_idx']) == 27 * 2
예제 #2
0
def test_combine_graphs_leaf_rings_singleton_sequence():
    mol = me.get_mol(
        'O=C(Cn1nc(C(=O)[O-])c2ccccc2c1=O)Nc1ccc2c(c1)C(=O)c1ccccc1C2=O')
    result = mr.mol2graph_single(mol, include_leaves=True)
    result = mr.combine_mol_graph([result])

    assert 'leaf_ring' in result
    assert 'leaf_atom' in result

    assert np.all(result['leaf_ring_scope'] == np.array([[0, 2]]))
예제 #3
0
def test_combine_graphs_bond_rings():
    mol = me.get_mol(
        'O=C(Cn1nc(C(=O)[O-])c2ccccc2c1=O)Nc1ccc2c(c1)C(=O)c1ccccc1C2=O')
    result = mr.mol2graph_single(mol, include_leaves=True, include_rings=True)
    result = mr.combine_mol_graph([result])

    assert 'ring_bond_idx' in result
    assert 'ring_bond_order' in result

    assert np.allclose(result['ring_scope'], np.array([[0, 27 * 2]]))
예제 #4
0
def test_combine_graphs(request):
    data = get_data(request)

    result = list(
        mr.combine_mol_graph([
            mr.mol2graph_single(me.get_mol(s)) for s in data['smiles']
        ]).values())
    expected = data['graph_stereo']

    def _compare_tensor(a, b):
        return np.allclose(a, b[:a.shape[0], :])

    assert _compare_tensor(result[0], expected[0])
예제 #5
0
def test_mol2graph_single(request):
    data = get_data(request)

    mol = me.get_mol(data['smiles'][0])

    result = list(mr.mol2graph_single(mol).values())
    expected = data['graph_nostereo']

    def _compare_tensor(a, b):
        return np.allclose(a, b[:a.shape[0], :])

    assert _compare_tensor(result[0], expected[0])
    assert _compare_tensor(result[1], expected[1][1:])
예제 #6
0
def test_mol2graph_single_rings_leaves():
    mol = me.get_mol(
        'O=C(Cn1nc(C(=O)[O-])c2ccccc2c1=O)Nc1ccc2c(c1)C(=O)c1ccccc1C2=O')
    result = mr.mol2graph_single(mol, include_leaves=True)

    assert 'leaf_ring' in result
    assert 'leaf_atom' in result

    assert result['leaf_atom'].tolist() == [0, 7, 8, 16, 25, 33]

    assert result['leaf_ring'][0][0].tolist() == [0] * 6 + [1] * 6
    assert result['leaf_ring'][0][1].tolist() == [9, 10, 11, 12, 13, 14
                                                  ] + [26, 27, 28, 29, 30, 31]
    assert result['leaf_ring'][1].tolist() == [pytest.approx(1 / np.sqrt(6))
                                               ] * 12