コード例 #1
0
    def test_count_by_time_weight(self, universe_AWA_AWWA):
        '''
        This test tests if modyfing the analysis_func allows the weight to be changed
        in count_by_type().
        :return:
        '''
        wb = WaterBridgeAnalysis(universe_AWA_AWWA,
                                 'protein and (resid 1 or resid 5)',
                                 'protein and (resid 4 or resid 8)',
                                 order=2)
        wb.run(verbose=False)

        def analysis(current, output, u):
            sele1_index, sele1_heavy_index, atom2, heavy_atom2, dist, angle = current[
                0]
            atom1, heavy_atom1, sele2_index, sele2_heavy_index, dist, angle = current[
                -1]
            sele1 = u.atoms[sele1_index]
            sele2 = u.atoms[sele2_index]
            (s1_resname, s1_resid, s1_name) = (sele1.resname, sele1.resid,
                                               sele1.name)
            (s2_resname, s2_resid, s2_name) = (sele2.resname, sele2.resid,
                                               sele2.name)
            key = (s1_resname, s1_resid, s2_resname, s2_resid)
            output[key] += len(current) - 1

        assert_equal(wb.count_by_time(analysis_func=analysis), [
            (0, 3),
        ])
コード例 #2
0
 def test_nodata(self, universe_DA):
     '''Test if the funtions can run when there is no data.
     This is achieved by not runing the run() first.'''
     wb = WaterBridgeAnalysis(universe_DA,
                              'protein and (resid 1)',
                              'protein and (resid 4)',
                              order=0)
     wb.generate_table()
     assert_equal(wb.timesteps_by_type(), None)
     assert_equal(wb.count_by_time(), None)
     assert_equal(wb.count_by_type(), None)
コード例 #3
0
    def test_count_by_time_empty(self, universe_AWA_AWWA):
        '''
        See if count_by_time() can handle zero well.
        :return:
        '''
        wb = WaterBridgeAnalysis(universe_AWA_AWWA,
                                 'protein and (resid 1 or resid 5)',
                                 'protein and (resid 4 or resid 8)',
                                 order=2)
        wb.run(verbose=False)

        def analysis(current, output, u):
            pass

        assert_equal(wb.count_by_time(analysis_func=analysis), [
            (0, 0),
        ])