示例#1
0
    def test_guess_bonds_withlist(self):
        bondlist = (
            (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 2), (1, 3),
            (1, 4), (2, 3), (2, 4), (2, 8), (3, 4), (4, 5), (4, 6),
            (6, 7), (6, 8), (6, 9), (7, 8))
        user_vdw = {'56': 1.5, '2': 1.5, '22': 1.5, '6': 1.5, '23': 1.5, '3': 1.5}

        assert_equal(guess_bonds(list(self.u.atoms[:10]),
                                 self.u.atoms.positions[:10],
                                 vdwradii=user_vdw),
                     bondlist)
示例#2
0
    def test_guess_bonds_withag(self):
        # here's one I prepared earlier
        bondlist = (
            (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 2), (1, 3),
            (1, 4), (2, 3), (2, 4), (2, 8), (3, 4), (4, 5), (4, 6),
            (6, 7), (6, 8), (6, 9), (7, 8))
        user_vdw = {'56': 1.5, '2': 1.5, '22': 1.5, '6': 1.5, '23': 1.5, '3': 1.5}

        assert_equal(guess_bonds(self.u.atoms[:10],
                                 self.u.atoms.positions[:10],
                                 vdwradii=user_vdw),
                     bondlist)
示例#3
0
    def test_guess_bonds_withlist(self):
        bondlist = ((0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 2), (1, 3),
                    (1, 4), (2, 3), (2, 4), (2, 8), (3, 4), (4, 5), (4, 6),
                    (6, 7), (6, 8), (6, 9), (7, 8))
        user_vdw = {
            '56': 1.5,
            '2': 1.5,
            '22': 1.5,
            '6': 1.5,
            '23': 1.5,
            '3': 1.5
        }

        assert_equal(
            guess_bonds(list(self.u.atoms[:10]),
                        self.u.atoms.positions[:10],
                        vdwradii=user_vdw), bondlist)
示例#4
0
    def test_guess_bonds_withag(self):
        # here's one I prepared earlier
        bondlist = ((0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 2), (1, 3),
                    (1, 4), (2, 3), (2, 4), (2, 8), (3, 4), (4, 5), (4, 6),
                    (6, 7), (6, 8), (6, 9), (7, 8))
        user_vdw = {
            '56': 1.5,
            '2': 1.5,
            '22': 1.5,
            '6': 1.5,
            '23': 1.5,
            '3': 1.5
        }

        assert_equal(
            guess_bonds(self.u.atoms[:10],
                        self.u.atoms.positions[:10],
                        vdwradii=user_vdw), bondlist)
示例#5
0
    def _parsebonds(self, primitive_pdb_reader):
        if self.guess_bonds_mode:
            guessed_bonds = guess_bonds(self.structure["_atoms"],
                                        np.array(primitive_pdb_reader.ts))
            self.structure["_guessed_bonds"] = guessed_bonds

        # Mapping between the atom array indicies a.number and atom ids
        # (serial) in the original PDB file

        mapping = dict((a.serial, a.number) for a in self.structure["_atoms"])

        bonds = set()
        with openany(self.filename, "r") as fname:
            lines = ((num, line[6:].split()) for num, line in enumerate(fname)
                     if line[:6] == "CONECT")
            for num, bond in lines:
                atom, atoms = int(bond[0]), map(int, bond[1:])
                for a in atoms:
                    bond = tuple([mapping[atom], mapping[a]])
                    bonds.add(bond)

        self.structure["_bonds"] = tuple(bonds)
示例#6
0
    def _parsebonds(self, primitive_pdb_reader):
        if self.guess_bonds_mode:
            guessed_bonds = guess_bonds(self.structure["_atoms"],
                                        np.array(primitive_pdb_reader.ts))
            self.structure["_guessed_bonds"] = guessed_bonds

        # Mapping between the atom array indicies a.number and atom ids
        # (serial) in the original PDB file

        mapping = dict((a.serial, a.number) for a in self.structure["_atoms"])

        bonds = set()
        with openany(self.filename, "r") as fname:
            lines = ((num, line[6:].split()) for num, line in enumerate(fname)
                     if line[:6] == "CONECT")
            for num, bond in lines:
                atom, atoms = int(bond[0]), map(int, bond[1:])
                for a in atoms:
                    bond = tuple([mapping[atom], mapping[a]])
                    bonds.add(bond)

        self.structure["_bonds"] = tuple(bonds)