Ejemplo n.º 1
0
def test_isomorphism_sulfur_group_sulfur_molecule():
    """
    Test isormophism check of a CS group vs. a sulfur containing molecule
    """
    gp1 = Group().from_adjacency_list("""
1 S  u0 {2,S} {3,S}
2 H  u0 {1,S}
3 C u0 {1,S} {4,D}
4 S  u0 {3,D}
""")

    gp2 = Group().from_adjacency_list("""
1 S  u0 {2,S} {3,S}
2 H  u0 {1,S}
3 CS u0 {1,S} {4,D}
4 S  u0 {3,D}
""")

    mol = Molecule().from_adjacency_list("""
1 S  0 {2,S} {3,S}
2 H  0 {1,S}
3 C 0 {1,S} {4,D} {5,S}
4 S 0 {3,D}
5 H 0 {3,S}
""")
    assert_true(mol.is_subgraph_isomorphic(gp1))

    assert_true(mol.is_subgraph_isomorphic(gp2))
Ejemplo n.º 2
0
def test_isotope_subgraph_isomorphism_molecule_and_group():
    """
    Checks that subgraph isomorphism works with enriched molecules and groups
    """
    methanei = Molecule().from_adjacency_list("""
    1 C u0 p0 c0 i13 {2,S} {3,S} {4,S} {5,S}
    2 H u0 p0 c0 {1,S}
    3 H u0 p0 c0 {1,S}
    4 H u0 p0 c0 {1,S}
    5 H u0 p0 c0 {1,S}
    """)
    methane = Molecule().from_adjacency_list("""
    1 C u0 p0 c0 {2,S} {3,S} {4,S} {5,S}
    2 H u0 p0 c0 {1,S}
    3 H u0 p0 c0 {1,S}
    4 H u0 p0 c0 {1,S}
    5 H u0 p0 c0 {1,S}
    """)
    group_methane = Group().from_adjacency_list("""
    1 C  u0 {2,S} {3,S} {4,S} {5,S}
    2 H  u0 {1,S}
    3 H  u0 {1,S}
    4 H  u0 {1,S}
    5 H  u0 {1,S}
    """)
    assert_true(methanei.is_subgraph_isomorphic(group_methane))
    assert_true(methane.is_subgraph_isomorphic(group_methane))
    assert_false(methanei.is_isomorphic(methane))
Ejemplo n.º 3
0
def test_isomorphism_mol_group_not_identical():
    """
    Testing multiplicities in mol and group that don't match
    """
    mol = Molecule().from_adjacency_list("""
    1 C u0 p0 c0
    """, saturate_h=True)

    gp = Group().from_adjacency_list("""
    multiplicity [2]
    1 R u0 p0 c0
    """)
    assert_false(mol.is_subgraph_isomorphic(gp))
    assert_false(len(mol.find_subgraph_isomorphisms(gp)) > 0)