コード例 #1
0
    def test_atomtyping(self, only_run=None):
        resource_dir = resource_filename('foyer', '../opls_validation')
        top_files = glob.glob(os.path.join(resource_dir, '*.top'))

        # Please update this file if you implement atom typing for a test case.
        implemented_tests_path = os.path.join(os.path.dirname(__file__),
                                              'implemented_opls_tests.txt')
        correctly_implemented = [
            line.strip() for line in open(implemented_tests_path)
        ]

        for top in top_files:
            top_name = os.path.split(top)[-1]
            system, known_opls_types, mol_name = load_top_opls(top, only_run)

            if only_run and only_run != mol_name:
                continue
            elif mol_name not in correctly_implemented:
                continue

            print("Typing {} ({})...".format(mol_name, top_name))
            prepare_atoms(system)
            find_atomtypes(list(system.atoms),
                           forcefield='OPLS-AA',
                           debug=False)

            generated_opls_types = list()

            for i, atom in enumerate(system.atoms):
                message = (
                    'Found multiple or no OPLS types for atom {} in {} ({}): {}\n'
                    'Should be atomtype: {}'.format(i, mol_name, top_name,
                                                    atom.atomtype[0],
                                                    known_opls_types[i]))
                assert isinstance(atom.atomtype[0], string_types), message
                generated_opls_types.append(atom.atomtype[0])
            both = zip(generated_opls_types, known_opls_types)
            message = "Found inconsistent OPLS types in {} ({}): {}".format(
                mol_name, top_name,
                list(
                    zip(range(len(generated_opls_types)), generated_opls_types,
                        known_opls_types)))

            assert all([a == b for a, b in both]), message
            print("Passed.\n")
コード例 #2
0
ファイル: test_opls.py プロジェクト: summeraz/foyer
    def test_atomtyping(self, only_run=None):
        resource_dir = resource_filename('foyer', '../opls_validation')
        top_files = glob.glob(os.path.join(resource_dir, '*.top'))

        # Please update this file if you implement atom typing for a test case.
        implemented_tests_path = os.path.join(os.path.dirname(__file__), 'implemented_opls_tests.txt')
        correctly_implemented = [line.strip() for line in open(implemented_tests_path)]

        for top in top_files:
            top_name = os.path.split(top)[-1]
            system, known_opls_types, mol_name = load_top_opls(top, only_run)

            if only_run and only_run != mol_name:
                continue
            elif mol_name not in correctly_implemented:
                continue

            print("Typing {} ({})...".format(mol_name, top_name))
            prepare_atoms(system)
            find_atomtypes(list(system.atoms), forcefield='OPLS-AA', debug=False)

            generated_opls_types = list()

            for i, atom in enumerate(system.atoms):
                message = ('Found multiple or no OPLS types for atom {} in {} ({}): {}\n'
                           'Should be atomtype: {}'.format(
                    i, mol_name, top_name, atom.atomtype[0], known_opls_types[i]))
                assert isinstance(atom.atomtype[0], string_types), message
                generated_opls_types.append(atom.atomtype[0])
            both = zip(generated_opls_types, known_opls_types)
            message = "Found inconsistent OPLS types in {} ({}): {}".format(
                mol_name, top_name, list(zip(range(len(generated_opls_types)),
                                        generated_opls_types,
                                        known_opls_types)))

            assert all([a == b for a, b in both]), message
            print("Passed.\n")
コード例 #3
0
ファイル: rules.py プロジェクト: Jonestj1/foyer
def uff_C_3(atom):
    """ """
    return True


@Element('H')
@NeighborCount(1)
@NeighborsExactly('C', 1)
@Whitelist('H_')
def uff_H_(atom):
    """ """
    return True


if __name__ == "__main__":

    from foyer.atomtyper import find_atomtypes
    from foyer.forcefield import prepare_atoms

    from mbuild.examples.methane.methane import Methane

    m = Methane()
    # m = Ethane()

    traj = m.to_trajectory()
    prepare_atoms(traj.top)
    find_atomtypes(traj.top._atoms, forcefield='UFF')

    for atom in traj.top._atoms:
        print("Atom name={}, opls_type={}".format(atom.name, atom.atomtype))
コード例 #4
0
ファイル: rules.py プロジェクト: summeraz/foyer
def uff_C_3(atom):
    """ """
    return True


@Element("H")
@NeighborCount(1)
@NeighborsExactly("C", 1)
@Whitelist("H_")
def uff_H_(atom):
    """ """
    return True


if __name__ == "__main__":

    from foyer.atomtyper import find_atomtypes
    from foyer.forcefield import prepare_atoms

    from mbuild.examples.methane.methane import Methane

    m = Methane()
    # m = Ethane()

    traj = m.to_trajectory()
    prepare_atoms(traj.top)
    find_atomtypes(traj.top._atoms, forcefield="UFF")

    for atom in traj.top._atoms:
        print("Atom name={}, opls_type={}".format(atom.name, atom.atomtype))