Пример #1
0
    def _parseatoms(self, pdb):
        atoms = []

        # translate Bio.PDB atom objects to MDAnalysis Atom.
        for iatom, atom in enumerate(pdb.get_atoms()):
            residue = atom.parent
            chain_id = residue.parent.id

            atomname = atom.name
            atomtype = guess_atom_type(atomname)
            resname = residue.resname
            resid = int(residue.id[1])
            # no empty segids (or Universe throws IndexError)
            segid = residue.get_segid().strip() or chain_id or "SYSTEM"
            mass = guess_atom_mass(atomname)
            charge = guess_atom_charge(atomname)
            bfactor = atom.bfactor
            # occupancy = atom.occupancy

            atoms.append(
                Atom(iatom,
                     atomname,
                     atomtype,
                     resname,
                     resid,
                     segid,
                     mass,
                     charge,
                     bfactor=bfactor))

        return atoms
Пример #2
0
    def _parseatoms(self, pdb):
        atoms = []

        # translate list of atoms to MDAnalysis Atom.
        for iatom, atom in enumerate(pdb._atoms):
            # ATOM
            if len(atom.__dict__) == 10:
                atomname = atom.name
                atomtype = atom.element or guess_atom_type(atomname)
                resname = atom.resName
                resid = int(atom.resSeq)
                chain = atom.chainID.strip()
                # no empty segids (or Universe throws IndexError)
                segid = atom.segID.strip() or chain or "SYSTEM"
                mass = guess_atom_mass(atomname)
                charge = guess_atom_charge(atomname)
                bfactor = atom.tempFactor
                # occupancy = atom.occupancy
                altLoc = atom.altLoc

                atoms.append(Atom(iatom, atomname, atomtype, resname, resid,
                                  segid, mass, charge,
                                  bfactor=bfactor, serial=atom.serial,
                                  altLoc=altLoc))
            # TER atoms
            #elif len(atom.__dict__) == 5:
            #    pass
            #    #atoms.append(None)
        self.structure["_atoms"] = atoms
Пример #3
0
    def parse(self):
        """Parse CRD file *filename* and return the dict `structure`.

        Only reads the list of atoms.

        :Returns: MDAnalysis internal *structure* dict

        .. SeeAlso:: The *structure* dict is defined in
                     `MDAnalysis.topology`
        """
        extformat = FORTRANReader(
            '2I10,2X,A8,2X,A8,3F20.10,2X,A8,2X,A8,F20.10')
        stdformat = FORTRANReader('2I5,1X,A4,1X,A4,3F10.5,1X,A4,1X,A4,F10.5')

        atoms = []
        atom_serial = 0
        with openany(self.filename) as crd:
            for linenum, line in enumerate(crd):
                # reading header
                if line.split()[0] == '*':
                    continue
                elif line.split()[-1] == 'EXT' and bool(int(
                        line.split()[0])) is True:
                    r = extformat
                    continue
                elif line.split()[0] == line.split(
                )[-1] and line.split()[0] != '*':
                    r = stdformat
                    continue
                # anything else should be an atom
                try:
                    serial, TotRes, resName, name, x, y, z, chainID, resSeq, tempFactor = r.read(
                        line)
                except:
                    raise ValueError("Check CRD format at line {}: {}".format(
                        linenum, line.rstrip()))

                atomtype = guess_atom_type(name)
                mass = guess_atom_mass(name)
                charge = guess_atom_charge(name)
                atoms.append(
                    Atom(atom_serial, name, atomtype, resName, TotRes, chainID,
                         mass, charge))
                atom_serial += 1

        structure = {}
        structure["_atoms"] = atoms

        return structure
Пример #4
0
    def parse(self):
        """Parse CRD file *filename* and return the dict `structure`.

        Only reads the list of atoms.

        :Returns: MDAnalysis internal *structure* dict

        .. SeeAlso:: The *structure* dict is defined in
                     `MDAnalysis.topology`
        """
        extformat = FORTRANReader('2I10,2X,A8,2X,A8,3F20.10,2X,A8,2X,A8,F20.10')
        stdformat = FORTRANReader('2I5,1X,A4,1X,A4,3F10.5,1X,A4,1X,A4,F10.5')

        atoms = []
        atom_serial = 0
        with openany(self.filename) as crd:
            for linenum, line in enumerate(crd):
                # reading header
                if line.split()[0] == '*':
                    continue
                elif line.split()[-1] == 'EXT' and bool(int(line.split()[0])) is True:
                    r = extformat
                    continue
                elif line.split()[0] == line.split()[-1] and line.split()[0] != '*':
                    r = stdformat
                    continue
                # anything else should be an atom
                try:
                    serial, TotRes, resName, name, x, y, z, chainID, resSeq, tempFactor = r.read(line)
                except:
                    raise ValueError("Check CRD format at line {}: {}".format(
                        linenum, line.rstrip()))

                atomtype = guess_atom_type(name)
                mass = guess_atom_mass(name)
                charge = guess_atom_charge(name)
                atoms.append(Atom(atom_serial, name, atomtype, resName, TotRes, chainID, mass, charge))
                atom_serial += 1

        structure = {}
        structure["_atoms"] = atoms

        return structure
Пример #5
0
    def _parseatoms(self, pdb):
        atoms = []

        # translate Bio.PDB atom objects to MDAnalysis Atom.
        for iatom, atom in enumerate(pdb.get_atoms()):
            residue = atom.parent
            chain_id = residue.parent.id

            atomname = atom.name
            atomtype = guess_atom_type(atomname)
            resname = residue.resname
            resid = int(residue.id[1])
            # no empty segids (or Universe throws IndexError)
            segid = residue.get_segid().strip() or chain_id or "SYSTEM"
            mass = guess_atom_mass(atomname)
            charge = guess_atom_charge(atomname)
            bfactor = atom.bfactor
            # occupancy = atom.occupancy

            atoms.append(Atom(iatom, atomname, atomtype, resname, resid, segid,
                              mass, charge, bfactor=bfactor))

        return atoms
Пример #6
0
    def _parseatoms(self, pdb):
        atoms = []

        # translate list of atoms to MDAnalysis Atom.
        for iatom, atom in enumerate(pdb._atoms):
            # ATOM
            if len(atom.__dict__) == 10:
                atomname = atom.name
                atomtype = atom.element or guess_atom_type(atomname)
                resname = atom.resName
                resid = int(atom.resSeq)
                chain = atom.chainID.strip()
                # no empty segids (or Universe throws IndexError)
                segid = atom.segID.strip() or chain or "SYSTEM"
                mass = guess_atom_mass(atomname)
                charge = guess_atom_charge(atomname)
                bfactor = atom.tempFactor
                # occupancy = atom.occupancy
                altLoc = atom.altLoc

                atoms.append(
                    Atom(iatom,
                         atomname,
                         atomtype,
                         resname,
                         resid,
                         segid,
                         mass,
                         charge,
                         bfactor=bfactor,
                         serial=atom.serial,
                         altLoc=altLoc))
            # TER atoms
            #elif len(atom.__dict__) == 5:
            #    pass
            #    #atoms.append(None)
        self.structure["_atoms"] = atoms