示例#1
0
    def ReadFromPdb(self, fname):
        self._Residues = dict()
        self._Atoms = dict()

        with open(fname, "r") as file:
            for line in file.readlines():
                data_type = line[0:6].strip()
                if data_type not in ['ATOM', 'HETATM']:
                    continue
                atom = Atom()
                atom.DataType = line[0:6].strip()
                atom.Name = line[12:16].strip()
                atom.AltLoc = line[16].strip()
                atom.ResName = line[17:20].strip()
                atom.ChainId = line[21].strip()
                atom.ResSeq = int(line[22:26])
                atom.ResCode = line[26].strip()
                atom.Coordinate = np.array(list(map(float, [line[30:38], line[38:46], line[46:54]])))
                atom.Occup = 0.0  # float(line[54:60])
                atom.Tempfac = 0.0  # float(line[60:66])
                atom.Element = atom.Name[0]  # line[76:78].strip()
                num = int(line[6:11])

                if atom.ResSeq not in self._Residues:
                    self._Residues[atom.ResSeq] = dict()

                self._Residues[atom.ResSeq][atom.Name] = atom
                self._Atoms[num] = atom