Пример #1
0
        def test_read_write(self, tmpdir):
                """Read a topology, write it out, and read in the output again.
                Writing the topology out should make no change to the topology.
                """
                path = self.processed
                with tmpdir.as_cwd():
                        filename1 = 'processed_1.top'
                        filename2 = 'processed_2.top'

                        top1 = TOP(path)
                        top1.write(filename1)

                        # make life harder, write out again
                        top2 = TOP(filename1)
                        top2.write(filename2)

                        top2 = TOP(filename2)

                        attrs1 = [section for section in top1.found_sections if "types" in section]
                        attrs2 = [section for section in top1.found_sections if "types" in section]

                        assert attrs1 == attrs2

                        #attrs1 = ['atomtypes', 'pairtypes', 'bondtypes', 'constrainttypes', 'angletypes', 'dihedraltypes', 'dihedraltypes', 'cmaptypes']
                        #attrs1 = ['atomtypes',]

                        for attr in attrs1:
                                attr1 = getattr(top1, attr)
                                attr2 = getattr(top2, attr)
                                assert attr1 == attr2, helper(attr, attr1, attr2)
Пример #2
0
 def test_read(self, tmpdir):
     path = self.processed
     try:
         top1 = TOP(path)
     except Exception as err:
         raise AssertionError("Failed to read {0}. Raised:\n{1}".format(
             path, str(err)))
     attrs1 = [
         section for section in top1.found_sections if "types" in section
     ]
     assert attrs1
Пример #3
0
    def test_equal(self):
        """
                        Load the same topology twice and check if __eq__ comparisions work
                """
        path = self.processed

        top1 = TOP(path)
        top2 = TOP(path)

        attrs1 = [
            section for section in top1.found_sections if "types" in section
        ]
        attrs2 = [
            section for section in top1.found_sections if "types" in section
        ]

        assert attrs1 == attrs2, "sections are not equal"

        for attr in attrs1:
            assert getattr(top1, attr) == getattr(top2, attr), \
                    "{0} not identical".format(attr)
Пример #4
0
    def test_read_write(self, tmpdir):
        """Read a topology, write it out, and read in the output again.
                Writing the topology out should make no change to the topology.
                """
        path = self.processed
        with tmpdir.as_cwd():
            filename1 = 'processed_1.top'
            filename2 = 'processed_2.top'

            top1 = TOP(path)
            top1.write(filename1)

            # make life harder, write out again
            top2 = TOP(filename1)
            top2.write(filename2)

            top2 = TOP(filename2)

            attrs1 = [
                section for section in top1.found_sections
                if "types" in section
            ]
            attrs2 = [
                section for section in top1.found_sections
                if "types" in section
            ]

            assert attrs1 == attrs2

            #attrs1 = ['atomtypes', 'pairtypes', 'bondtypes', 'constrainttypes', 'angletypes', 'dihedraltypes', 'dihedraltypes', 'cmaptypes']
            #attrs1 = ['atomtypes',]

            for attr in attrs1:
                attr1 = getattr(top1, attr)
                attr2 = getattr(top2, attr)
                assert attr1 == attr2, helper(attr, attr1, attr2)
Пример #5
0
            key = "{0}-{1}-{2}-{3}-{4}".format(a1, a2, a3, a4,
                                               im.gromacs['func'])
            if (key in impropers):
                for i, imt in enumerate(impropers[key]):
                    new_impropers[key] = imt
                break
    print(new_impropers)
    return new_impropers.values()


parser = argparse.ArgumentParser()
parser.add_argument("input")
parser.add_argument("output")
args = parser.parse_args()

top = TOP(args.input)
molname = top.molecules[0].name
mol = top.dict_molname_mol[molname]

#
# ATOMTYPES
#
atomtypes = {a.atomtype for a in mol.atoms}
top.atomtypes = [at for at in top.atomtypes if at.atype in atomtypes]

#
# BONDTYPES
#
bondtypes = {
    tuple(sorted((b.atom1.atomtype, b.atom2.atomtype)))
    for b in mol.bonds
Пример #6
0
 def test_basic(self):
     path = self.processed
     top = TOP(path)
     assert top.dict_molname_mol.keys() == self.molecules
Пример #7
0
                        if((iswitch/16)%2==1): a4="X";
                        key = "{0}-{1}-{2}-{3}-{4}".format(a1, a2, a3, a4, im.gromacs['func'])
                        if (key in impropers):
                                for i, imt in enumerate(impropers[key]):
                                        new_impropers[key] = imt
                                break
        print new_impropers
        return new_impropers.values()


parser = argparse.ArgumentParser()
parser.add_argument("input")
parser.add_argument("output")
args = parser.parse_args()

top = TOP(args.input)
molname = top.molecules[0].name
mol = top.dict_molname_mol[molname]

#
# ATOMTYPES
#
atomtypes = {a.atomtype for a in mol.atoms}
top.atomtypes = [at for at in top.atomtypes if at.atype in atomtypes]

#
# BONDTYPES
#
bondtypes = {tuple(sorted((b.atom1.atomtype, b.atom2.atomtype))) for b in mol.bonds}
bondtypes_dictionary = {tuple(sorted((bt.atype1, bt.atype2))): bt for bt in top.bondtypes}
top.bondtypes = [bondtypes_dictionary[bt] for bt in bondtypes]