def test_count_by_type_multiple_link(self):
        '''
        This test tests if count_by_type() can assemble linkage from water network.
        :return:
        '''
        grofile = '''Test gro file
5
    1ALA      N    1   0.000   0.000   0.000
    1ALA      H    2   0.100   0.000   0.000
    2SOL     OW    3   0.300   0.000   0.000
    2SOL    HW2    4   0.400   0.000   0.000
    4ALA      O    5   0.600   0.000   0.000
 1.0   1.0   1.0'''
        u = MDAnalysis.Universe(StringIO(grofile), format='gro')
        wb = WaterBridgeAnalysis(u, 'protein and (resid 1)',
                                 'protein and (resid 4)')
        # Build an dummy WaterBridgeAnalysis object for testing
        wb._timeseries = True
        wb.timesteps = [0]
        wb._water_network = [{
            ('SOL', 2):
            [{(2, 0, ('SOL', 2, 'HW1'), ('ALA', 1, 'O'), 2.0, 179.99998),
              (1, 2, ('ALA', 1, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)},
             {(3, 4, ('SOL', 2, 'HW2'), ('ALA', 4, 'O'), 2.0, 179.99998),
              (3, 2, ('ALA', 4, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)}]
        }]
        result = [(0, 3, 'ALA', 1, 'O', 'ALA', 4, 'H', 1.0),
                  (0, 4, 'ALA', 1, 'O', 'ALA', 4, 'O', 1.0),
                  (1, 3, 'ALA', 1, 'H', 'ALA', 4, 'H', 1.0),
                  (1, 4, 'ALA', 1, 'H', 'ALA', 4, 'O', 1.0)]
        assert_equal(sorted(wb.count_by_type().tolist()), result)
Ejemplo n.º 2
0
    def test_count_by_type_multiple_link(self):
        '''
        This test tests if count_by_type() can assemble linkage from water network.
        :return:
        '''
        grofile = '''Test gro file
5
    1ALA      N    1   0.000   0.000   0.000
    1ALA      H    2   0.100   0.000   0.000
    2SOL     OW    3   0.300   0.000   0.000
    2SOL    HW2    4   0.400   0.000   0.000
    4ALA      O    5   0.600   0.000   0.000
 1.0   1.0   1.0'''
        u = MDAnalysis.Universe(StringIO(grofile), format='gro')
        wb = WaterBridgeAnalysis(u, 'protein and (resid 1)', 'protein and (resid 4)')
        # Build an dummy WaterBridgeAnalysis object for testing
        wb._timeseries = True
        wb.timesteps = [0]
        wb._water_network = [{('SOL', 2): [{(2, 0, ('SOL', 2, 'HW1'), ('ALA', 1, 'O'), 2.0, 179.99998),
                                            (1, 2, ('ALA', 1, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)},
                                           {(3, 4, ('SOL', 2, 'HW2'), ('ALA', 4, 'O'), 2.0, 179.99998),
                                            (3, 2, ('ALA', 4, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)}]}]
        result = [(0, 3, 'ALA', 1, 'O', 'ALA', 4, 'H', 1.0),
                  (0, 4, 'ALA', 1, 'O', 'ALA', 4, 'O', 1.0),
                  (1, 3, 'ALA', 1, 'H', 'ALA', 4, 'H', 1.0),
                  (1, 4, 'ALA', 1, 'H', 'ALA', 4, 'O', 1.0)]
        assert_equal(sorted(wb.count_by_type().tolist()), result)
Ejemplo n.º 3
0
    def test_count_by_type_multiple_frame(self):
        '''
        This test tests if count_by_type() works in multiply situations.
        :return:
        '''
        grofile = '''Test gro file
5
    1ALA      N    1   0.000   0.000   0.000
    1ALA      H    2   0.100   0.000   0.000
    2SOL     OW    3   0.300   0.000   0.000
    2SOL    HW2    4   0.400   0.000   0.000
    4ALA      O    5   0.600   0.000   0.000
 1.0   1.0   1.0'''
        u = MDAnalysis.Universe(StringIO(grofile), format='gro')
        wb = WaterBridgeAnalysis(u, 'protein and (resid 1)', 'protein and (resid 4)')
        # Build an dummy WaterBridgeAnalysis object for testing
        wb._timeseries = True
        wb.timesteps = [0, 1, 2, 3, 4, 5]
        wb._water_network = [# a 2 * 2 water netwrok consists of all four links
                             {('SOL', 2): [{(2, 0, ('SOL', 2, 'HW1'), ('ALA', 1, 'O'), 2.0, 179.99998),
                                            (1, 2, ('ALA', 1, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)},
                                           {(3, 4, ('SOL', 2, 'HW2'), ('ALA', 4, 'O'), 2.0, 179.99998),
                                            (3, 2, ('ALA', 4, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)}]},
                             # a repeat
                             {('SOL', 2): [{(2, 0, ('SOL', 2, 'HW1'), ('ALA', 1, 'O'), 2.0, 179.99998),
                                            (1, 2, ('ALA', 1, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)},
                                           {(3, 4, ('SOL', 2, 'HW2'), ('ALA', 4, 'O'), 2.0, 179.99998),
                                            (3, 2, ('ALA', 4, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)}]},
                             # single link 1
                             {('SOL', 2): [{(2, 0, ('SOL', 2, 'HW1'), ('ALA', 1, 'O'), 2.0, 179.99998)},
                                           {(3, 4, ('SOL', 2, 'HW2'), ('ALA', 4, 'O'), 2.0, 179.99998)}]},
                             # single link 2
                             {('SOL', 2): [{(2, 0, ('SOL', 2, 'HW1'), ('ALA', 1, 'O'), 2.0, 179.99998)},
                                           {(3, 1, ('ALA', 4, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)}]},
                             # single link 3
                             {('SOL', 2): [{(1, 2, ('ALA', 1, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)},
                                           {(3, 4, ('SOL', 2, 'HW2'), ('ALA', 4, 'O'), 2.0, 179.99998)}]},
                             # single link 4
                             {('SOL', 2): [{(1, 2, ('ALA', 1, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)},
                                           {(3, 2, ('ALA', 4, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)}]}]
        result = [(0, 3, 'ALA', 1, 'O', 'ALA', 4, 'H', 0.5),
                  (0, 4, 'ALA', 1, 'O', 'ALA', 4, 'O', 0.5),
                  (1, 3, 'ALA', 1, 'H', 'ALA', 4, 'H', 0.5),
                  (1, 4, 'ALA', 1, 'H', 'ALA', 4, 'O', 0.5)]
        assert_equal(sorted(wb.count_by_type().tolist()), result)
    def test_count_by_type_multiple_frame(self):
        '''
        This test tests if count_by_type() works in multiply situations.
        :return:
        '''
        grofile = '''Test gro file
5
    1ALA      N    1   0.000   0.000   0.000
    1ALA      H    2   0.100   0.000   0.000
    2SOL     OW    3   0.300   0.000   0.000
    2SOL    HW2    4   0.400   0.000   0.000
    4ALA      O    5   0.600   0.000   0.000
 1.0   1.0   1.0'''
        u = MDAnalysis.Universe(StringIO(grofile), format='gro')
        wb = WaterBridgeAnalysis(u, 'protein and (resid 1)',
                                 'protein and (resid 4)')
        # Build an dummy WaterBridgeAnalysis object for testing
        wb._timeseries = True
        wb.timesteps = [0, 1, 2, 3, 4, 5]
        wb._water_network = [  # a 2 * 2 water netwrok consists of all four links
            {
                ('SOL', 2):
                [{(2, 0, ('SOL', 2, 'HW1'), ('ALA', 1, 'O'), 2.0, 179.99998),
                  (1, 2, ('ALA', 1, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)},
                 {(3, 4, ('SOL', 2, 'HW2'), ('ALA', 4, 'O'), 2.0, 179.99998),
                  (3, 2, ('ALA', 4, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)}]
            },
            # a repeat
            {
                ('SOL', 2):
                [{(2, 0, ('SOL', 2, 'HW1'), ('ALA', 1, 'O'), 2.0, 179.99998),
                  (1, 2, ('ALA', 1, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)},
                 {(3, 4, ('SOL', 2, 'HW2'), ('ALA', 4, 'O'), 2.0, 179.99998),
                  (3, 2, ('ALA', 4, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)}]
            },
            # single link 1
            {
                ('SOL', 2):
                [{(2, 0, ('SOL', 2, 'HW1'), ('ALA', 1, 'O'), 2.0, 179.99998)},
                 {(3, 4, ('SOL', 2, 'HW2'), ('ALA', 4, 'O'), 2.0, 179.99998)}]
            },
            # single link 2
            {
                ('SOL', 2):
                [{(2, 0, ('SOL', 2, 'HW1'), ('ALA', 1, 'O'), 2.0, 179.99998)},
                 {(3, 1, ('ALA', 4, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)}]
            },
            # single link 3
            {
                ('SOL', 2):
                [{(1, 2, ('ALA', 1, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)},
                 {(3, 4, ('SOL', 2, 'HW2'), ('ALA', 4, 'O'), 2.0, 179.99998)}]
            },
            # single link 4
            {
                ('SOL', 2):
                [{(1, 2, ('ALA', 1, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)},
                 {(3, 2, ('ALA', 4, 'H'), ('SOL', 2, 'OW'), 2.0, 179.99998)}]
            }
        ]
        result = [(0, 3, 'ALA', 1, 'O', 'ALA', 4, 'H', 0.5),
                  (0, 4, 'ALA', 1, 'O', 'ALA', 4, 'O', 0.5),
                  (1, 3, 'ALA', 1, 'H', 'ALA', 4, 'H', 0.5),
                  (1, 4, 'ALA', 1, 'H', 'ALA', 4, 'O', 0.5)]
        assert_equal(sorted(wb.count_by_type().tolist()), result)