Ejemplo n.º 1
0
    def test_group_adjacency_list(self):
        """
        adjlist: Check the adjacency list read/write functions for a full molecule.
        """
        adjlist = """1 C u0 {2,D}
2 O u1 p1 c[-1,0,+1] {1,D}
"""
        group = Group().from_adjacency_list("""
        1 C u0 {2,D} 
        2 O u1 p1 c[-1,0,+1] {1,D}
        """)
        self.assertEqual(adjlist, group.to_adjacency_list())
Ejemplo n.º 2
0
    def test_to_adjacency_list(self):
        """
        adjlist: Test the Group.to_adjacency_list() method.
        """
        adjlist = """
1 *2 [Cs,Cd]   u0 {2,[S,D]} {3,S}
2 *1 [O2s,O2d] u0 {1,[S,D]}
3    R!H       u0 {1,S}
            """
        group = Group().from_adjacency_list(adjlist)
        adjlist2 = group.to_adjacency_list()

        self.assertEqual(adjlist.strip(), adjlist2.strip())
Ejemplo n.º 3
0
    def test_atom_props(self):
        """Test that the atom props attribute can be properly read and written."""
        adjlist = """
1 *1 R!H u1 r0 {2,S}
2 *4 R!H u0 r0 {1,S} {3,S}
3 *2 Cb  u0 r1 {2,S} {4,B}
4 *3 Cb  u0 r1 {3,B}
        """
        group = Group().from_adjacency_list(adjlist)
        for atom in group.atoms:
            if atom.atomtype[0].label == 'R!H':
                self.assertFalse(atom.props['inRing'])
            elif atom.atomtype[0].label == 'Cb':
                self.assertTrue(atom.props['inRing'])
        adjlist2 = group.to_adjacency_list()

        self.assertEqual(adjlist.strip(), adjlist2.strip())