Example #1
0
    def test_adds_maps_to_force(self):
        with mock.patch("meld.runner.transform.cmap.np.loadtxt") as mock_loadtxt:
            # this is a bit hacky and depends on what order the maps are loaded in
            expected_gly = 3.0 * 0.0 + 7.0 * 1.0 + np.zeros((24, 24)).flatten()
            expected_pro = 3.0 * 2.0 + 7.0 * 3.0 + np.zeros((24, 24)).flatten()
            expected_ala = 3.0 * 4.0 + 7.0 * 5.0 + np.zeros((24, 24)).flatten()
            expected_gen = 3.0 * 6.0 + 7.0 * 7.0 + np.zeros((24, 24)).flatten()
            mock_loadtxt.side_effect = self.maps

            opt = options.RunOptions()
            opt.use_amap = True
            opt.amap_alpha_bias = 3.0
            opt.amap_beta_bias = 7.0
            adder = cmap.CMAPTransformer(opt, self.system.top_string)

            adder.add_interactions(mock.Mock(), self.mock_openmm_system, mock.Mock())

            self.assertEqual(self.MockCMAP.call_count, 1)
            self.assertEqual(self.mock_cmap.addMap.call_count, 4)

            # make sure all of the sizes are correct
            add_map_args = self.mock_cmap.addMap.call_args_list
            self.assertEqual(add_map_args[0][0][0], 24)
            self.assertEqual(add_map_args[1][0][0], 24)
            self.assertEqual(add_map_args[2][0][0], 24)
            self.assertEqual(add_map_args[3][0][0], 24)

            # make sure the maps are correct
            np.testing.assert_almost_equal(add_map_args[0][0][1], expected_gly)
            np.testing.assert_almost_equal(add_map_args[1][0][1], expected_pro)
            np.testing.assert_almost_equal(add_map_args[2][0][1], expected_ala)
            np.testing.assert_almost_equal(add_map_args[3][0][1], expected_gen)
Example #2
0
    def test_force_should_be_added_to_system(self):
        opt = options.RunOptions()
        opt.use_amap = True

        adder = cmap.CMAPTransformer(opt, self.system.top_string)
        adder.add_interactions(mock.Mock(), self.mock_openmm_system, mock.Mock())

        self.mock_openmm_system.addForce.assert_called_once_with(self.mock_cmap)
Example #3
0
    def test_correct_torsions_should_be_added_to_force(self):
        opt = options.RunOptions()
        opt.use_amap = True

        adder = cmap.CMAPTransformer(opt, self.system.top_string)
        adder.add_interactions(mock.Mock(), self.mock_openmm_system, mock.Mock())

        # map should be #2 for alanine
        # all atom indices are zero-based in openmm
        self.mock_cmap.addTorsion.assert_called_once_with(
            2, 10, 12, 14, 20, 12, 14, 20, 22
        )
Example #4
0
    def test_correct_map_used_for_ALA(self):
        self.make_system("ALA")

        opt = options.RunOptions()
        opt.use_amap = True

        adder = cmap.CMAPTransformer(opt, self.system.top_string)
        adder.add_interactions(mock.Mock(), self.mock_openmm_system, mock.Mock)

        self.mock_cmap.addTorsion.assert_called_once_with(
            2, ANY, ANY, ANY, ANY, ANY, ANY, ANY, ANY
        )
Example #5
0
    def test_correct_map_used_for_general_case(self):
        res_names = [
            "CYS",
            "CYX",
            "ASP",
            "ASH",
            "GLU",
            "GLH",
            "PHE",
            "HIS",
            "HID",
            "HIE",
            "HIP",
            "LYS",
            "LYN",
            "MET",
            "SER",
            "TRP",
            "TYR",
            "ILE",
            "ASN",
            "GLN",
            "THR",
            "TRP",
            "LEU",
            "ARG",
        ]
        for res in res_names:
            self.mock_cmap.reset_mock()
            self.make_system(res)

            opt = options.RunOptions()
            opt.use_amap = True

            adder = cmap.CMAPTransformer(opt, self.system.top_string)
            adder.add_interactions(mock.Mock(), self.mock_openmm_system, mock.Mock())

            self.mock_cmap.addTorsion.assert_called_once_with(
                3, ANY, ANY, ANY, ANY, ANY, ANY, ANY, ANY
            )