Example #1
0
    def test_adds_maps_to_force(self):
        with mock.patch(
                "meld.system.openmm_runner.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. + 7.0 * 1. + np.zeros((24, 24)).flatten()
            expected_pro = 3.0 * 2. + 7.0 * 3. + np.zeros((24, 24)).flatten()
            expected_ala = 3.0 * 4. + 7.0 * 5. + np.zeros((24, 24)).flatten()
            expected_gen = 3.0 * 6. + 7.0 * 7. + np.zeros((24, 24)).flatten()
            mock_loadtxt.side_effect = self.maps
            adder = CMAPAdder(self.system.top_string,
                              alpha_bias=3.0,
                              beta_bias=7.0)

            adder.add_to_openmm(self.mock_openmm_system)

            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)
    def test_correct_torsions_should_be_added_to_force(self):
        adder = CMAPAdder(self.system.top_string)
        adder.add_to_openmm(self.mock_openmm_system)

        # 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)
    def test_adds_maps_to_force(self):
        with mock.patch('meld.system.openmm_runner.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. + 7.0 * 1. + np.zeros((24, 24)).flatten()
            expected_pro = 3.0 * 2. + 7.0 * 3. + np.zeros((24, 24)).flatten()
            expected_ala = 3.0 * 4. + 7.0 * 5. + np.zeros((24, 24)).flatten()
            expected_gen = 3.0 * 6. + 7.0 * 7. + np.zeros((24, 24)).flatten()
            mock_loadtxt.side_effect = self.maps
            adder = CMAPAdder(self.system.top_string, alpha_bias=3.0, beta_bias=7.0)

            adder.add_to_openmm(self.mock_openmm_system)

            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)
    def test_correct_map_used_for_ALA(self):
        self.make_system('ALA')

        adder = CMAPAdder(self.system.top_string)
        adder.add_to_openmm(self.mock_openmm_system)

        self.mock_cmap.addTorsion.assert_called_once_with(2, ANY, ANY, ANY, ANY, ANY, ANY, ANY, ANY)
Example #5
0
    def test_correct_torsions_should_be_added_to_force(self):
        adder = CMAPAdder(self.system.top_string)
        adder.add_to_openmm(self.mock_openmm_system)

        # 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 #6
0
    def test_correct_map_used_for_ALA(self):
        self.make_system("ALA")

        adder = CMAPAdder(self.system.top_string)
        adder.add_to_openmm(self.mock_openmm_system)

        self.mock_cmap.addTorsion.assert_called_once_with(
            2, ANY, ANY, ANY, ANY, ANY, ANY, ANY, ANY)
Example #7
0
    def test_correct_torsions_should_be_added_to_force(self):
        adder = CMAPAdder(self.system.top_string)
        adder.add_to_openmm(self.mock_openmm_system)

        # map should be #2 for alanine
        # all atom indices are zero-based in openmm
        expected_calls = [
            mock.call(2, 10, 12, 14, 20, 12, 14, 20, 22),
            mock.call(2, 43, 45, 47, 53, 45, 47, 53, 55),
        ]
        self.mock_cmap.addTorsion.assert_has_calls(expected_calls)
    def test_correct_torsions_should_be_added_to_force(self):
        adder = CMAPAdder(self.system.top_string)
        adder.add_to_openmm(self.mock_openmm_system)

        # map should be #2 for alanine
        # all atom indices are zero-based in openmm
        expected_calls = [
            mock.call(2, 10, 12, 14, 20, 12, 14, 20, 22),
            mock.call(2, 43, 45, 47, 53, 45, 47, 53, 55)
        ]
        self.mock_cmap.addTorsion.assert_has_calls(expected_calls)
    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)

            adder = CMAPAdder(self.system.top_string)
            adder.add_to_openmm(self.mock_openmm_system)

            self.mock_cmap.addTorsion.assert_called_once_with(3, ANY, ANY, ANY, ANY, ANY, ANY, ANY, ANY)
Example #10
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)

            adder = CMAPAdder(self.system.top_string)
            adder.add_to_openmm(self.mock_openmm_system)

            self.mock_cmap.addTorsion.assert_called_once_with(
                3, ANY, ANY, ANY, ANY, ANY, ANY, ANY, ANY)
Example #11
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)

            adder = CMAPAdder(self.system.top_string)
            adder.add_to_openmm(self.mock_openmm_system)

            self.mock_cmap.addTorsion.assert_called_once_with(
                3, ANY, ANY, ANY, ANY, ANY, ANY, ANY, ANY
            )
Example #12
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)

            adder = CMAPAdder(self.system.top_string)
            adder.add_to_openmm(self.mock_openmm_system)

            self.mock_cmap.addTorsion.assert_called_once_with(
                3, ANY, ANY, ANY, ANY, ANY, ANY, ANY, ANY)
Example #13
0
    def test_force_should_be_added_to_system(self):
        adder = CMAPAdder(self.system.top_string)
        adder.add_to_openmm(self.mock_openmm_system)

        self.mock_openmm_system.addForce.assert_called_once_with(
            self.mock_cmap)
Example #14
0
    def test_force_should_be_added_to_system(self):
        adder = CMAPAdder(self.system.top_string)
        adder.add_to_openmm(self.mock_openmm_system)

        self.mock_openmm_system.addForce.assert_called_once_with(self.mock_cmap)