Пример #1
0
def test_process_rb_torsions():
    """Test that the GROMACS driver reports Ryckaert-Bellemans torsions"""

    import foyer
    import mbuild as mb

    oplsaa = foyer.Forcefield(name="oplsaa")

    ethanol = Molecule.from_smiles("CCO")
    ethanol.generate_conformers(n_conformers=1)
    ethanol.generate_unique_atom_names()

    # Run this OFFMol through MoSDeF infrastructure and OPLS-AA
    from openff.interchange.components.mbuild import offmol_to_compound

    my_compound = offmol_to_compound(ethanol)
    my_compound.box = mb.Box(lengths=[4, 4, 4])

    oplsaa = foyer.Forcefield(name="oplsaa")
    struct = oplsaa.apply(my_compound)

    struct.save("eth.top", overwrite=True)
    struct.save("eth.gro", overwrite=True)

    # Get single-point energies using GROMACS
    oplsaa_energies = _run_gmx_energy(top_file="eth.top",
                                      gro_file="eth.gro",
                                      mdp_file=_get_mdp_file("default"))

    assert oplsaa_energies.energies["Torsion"].m != 0.0
Пример #2
0
    def test_mbuild_conversion_element_names(self):
        """Test that the generated Compound has particle names that can be
        interpreted as elements"""
        offmol = Molecule.from_smiles(
            "CSC(CO[P]([O-])([O-])=O)c1cc(Br)c(F)c(Cl)n1",
            allow_undefined_stereo=True,
        )
        comp = offmol_to_compound(offmol)

        known_elements = {"C", "H", "O", "N", "Cl", "Br", "F", "S", "P"}

        for particle in comp.particles():
            assert particle.name in known_elements
Пример #3
0
    def test_basic_mol_to_compound(self):
        """Test basic behavior of conversion to mBuild Compound"""
        offmol = Molecule.from_smiles("CCO")
        offmol.generate_conformers(n_conformers=1)

        comp = offmol_to_compound(offmol)

        assert comp.n_particles == offmol.n_atoms
        assert comp.n_bonds == offmol.n_bonds

        np.testing.assert_equal(
            offmol.conformers[0].value_in_unit(simtk_unit.nanometer),
            comp.xyz,
        )
Пример #4
0
    def test_mbuild_conversion_generate_conformers(self):
        """Test that a single conformer is automatically generated"""
        offmol = Molecule.from_smiles("CCO")

        comp = offmol_to_compound(offmol)

        assert comp.n_particles == offmol.n_atoms
        assert comp.n_bonds == offmol.n_bonds

        offmol.generate_conformers(n_conformers=1)
        expected_conf = offmol.conformers[0]

        np.testing.assert_equal(
            expected_conf.value_in_unit(simtk_unit.nanometer),
            comp.xyz,
        )
Пример #5
0
    def test_mbuild_conversion_first_conformer_used(self):
        """Test that only the first conformer in an OFFMol is used"""
        offmol = Molecule.from_smiles("C1=CC=C(C=C1)C2=CC=C(C=C2)C3=CC=CC=C3")
        offmol.generate_conformers(n_conformers=3,
                                   rms_cutoff=0.0 * simtk_unit.angstrom)

        comp = offmol_to_compound(offmol)

        np.testing.assert_equal(
            offmol.conformers[0].value_in_unit(simtk_unit.nanometer),
            comp.xyz,
        )

        with np.testing.assert_raises(AssertionError):
            np.testing.assert_equal(
                offmol.conformers[1].value_in_unit(simtk_unit.nanometer),
                comp.xyz,
            )

        with np.testing.assert_raises(AssertionError):
            np.testing.assert_equal(
                offmol.conformers[2].value_in_unit(simtk_unit.nanometer),
                comp.xyz,
            )