示例#1
0
    def read_geom_angle(self, bond_map):
        """Read bond information form the geom_angle section.
        """
        for t in self.cif.tables:
            if "geom_angle_atom_site_label_1" in t.columns:
                table = t
                break
        else:
            warning("read_atoms: no geom_angle section found")
            return

        for row in range(len(table.rows)):
            name1 = table.get_value("geom_angle_atom_site_label_1", row)
            atom1 = self.atom_site_name_map[name1]
            name2 = table.get_value("geom_angle_atom_site_label_2", row)
            atom2 = self.atom_site_name_map[name2]
            name3 = table.get_value("geom_angle_atom_site_label_3", row)
            atom3 = self.atom_site_name_map[name3]

            if id(atom1) < id(atom2):
                bnd = (atom1, atom2)
            else:
                bnd = (atom2, atom1)
            bond_map[bnd] = {}

            if id(atom2) < id(atom3):
                bnd = (atom2, atom3)
            else:
                bnd = (atom3, atom2)
            bond_map[bnd] = {}
示例#2
0
    def read_geom_angle(self, bond_map):
        """Read bond information form the geom_angle section.
        """
        for t in self.cif.tables:
            if "geom_angle_atom_site_label_1" in t.columns:
                table = t
                break
        else:
            warning("read_atoms: no geom_angle section found")
            return

        for row in range(len(table.rows)):
            name1 = table.get_value("geom_angle_atom_site_label_1", row)
            atom1 = self.atom_site_name_map[name1]
            name2 = table.get_value("geom_angle_atom_site_label_2", row)
            atom2 = self.atom_site_name_map[name2]
            name3 = table.get_value("geom_angle_atom_site_label_3", row)
            atom3 = self.atom_site_name_map[name3]

            if id(atom1) < id(atom2):
                bnd = (atom1, atom2)
            else:
                bnd = (atom2, atom1)
            bond_map[bnd] = {}

            if id(atom2) < id(atom3):
                bnd = (atom2, atom3)
            else:
                bnd = (atom3, atom2)
            bond_map[bnd] = {}
示例#3
0
 def read_start(self, filobj):
     ## parse the CIF file
     cif_file = CIF.CIFFile()
     cif_file.load_file(filobj)
     if len(cif_file.data_blocks) != 1:
         warning("read_start: only single-structure CIF files supported")
         self.halt = True
         return
     self.cif = cif_file.data_blocks[0]
     self.get_cell_parameters()
     self.atom_site_name_map = {}
示例#4
0
 def read_start(self, filobj):
     ## parse the CIF file
     cif_file = CIF.CIFFile()
     cif_file.load_file(filobj)
     if len(cif_file.data_blocks) != 1:
         warning("read_start: only single-structure CIF files supported")
         self.halt = True
         return
     self.cif = cif_file.data_blocks[0]
     self.get_cell_parameters()
     self.atom_site_name_map = {}
示例#5
0
    def read_atoms(self):
        """Read atom information form the atom_site section.
        """
        for t in self.cif.tables:
            if "atom_site_label" in t.columns:
                table = t
                break
        else:
            warning("read_atoms: no atom_site section found")
            self.halt = True
            return

        for i in range(len(table.rows)):
            atm_map = {
                "res_name": self.cif.name,
                "fragment_id": "1",
                "chain_id": " ",
            }
            add_string(atm_map, "name", table, "atom_site_label", i)
            add_string(atm_map, "element", table, "atom_site_type_symbol", i)
            add_number(atm_map, "fractx", table, "atom_site_fract_x", i)
            add_number(atm_map, "fracty", table, "atom_site_fract_y", i)
            add_number(atm_map, "fractz", table, "atom_site_fract_z", i)
            add_number(atm_map, "temp_factor", table,
                       "atom_site_U_iso_or_equiv", i)
            add_number(atm_map, "occupancy", table, "atom_site_occupancy", i)
            try:
                fx = atm_map["fractx"]
                fy = atm_map["fracty"]
                fz = atm_map["fractz"]
            except KeyError:
                warning("read_atoms: missing coordinates")
            else:
                fc = [fx, fy, fz]
                xyz = [0.0, 0.0, 0.0]
                for i in range(3):
                    sum = 0.0
                    for j in range(3):
                        sum += self.xform[i][j] * fc[j]
                    xyz[i] = sum
                atm_map["x"] = xyz[0]
                atm_map["y"] = xyz[1]
                atm_map["z"] = xyz[2]
            atm = self.load_atom(atm_map)
            self.atom_site_name_map[atm_map["name"]] = atm
        #print "%d atoms" % len(self.atom_site_name_map)

        ## load the bonds
        bond_map = {}
        self.read_geom_bond(bond_map)
        self.read_geom_angle(bond_map)
        self.load_bonds(bond_map)
示例#6
0
    def read_atoms(self):
        """Read atom information form the atom_site section.
        """
        for t in self.cif.tables:
            if "atom_site_label" in t.columns:
                table = t
                break
        else:
            warning("read_atoms: no atom_site section found")
            self.halt = True
            return

        for i in range(len(table.rows)):
            atm_map = {
                "res_name": self.cif.name,
                "fragment_id": "1",
                "chain_id": " ",
            }
            add_string(atm_map, "name", table, "atom_site_label", i)
            add_string(atm_map, "element", table, "atom_site_type_symbol", i)
            add_number(atm_map, "fractx", table, "atom_site_fract_x", i)
            add_number(atm_map, "fracty", table, "atom_site_fract_y", i)
            add_number(atm_map, "fractz", table, "atom_site_fract_z", i)
            add_number(atm_map, "temp_factor",
                                        table, "atom_site_U_iso_or_equiv", i)
            add_number(atm_map, "occupancy", table, "atom_site_occupancy", i)
            try:
                fx = atm_map["fractx"] 
                fy = atm_map["fracty"] 
                fz = atm_map["fractz"] 
            except KeyError:
                warning("read_atoms: missing coordinates")
            else:
                fc = [ fx, fy, fz ]
                xyz = [ 0.0, 0.0, 0.0 ]
                for i in range(3):
                    sum = 0.0
                    for j in range(3):
                        sum += self.xform[i][j] * fc[j]
                    xyz[i] = sum
                atm_map["x"] = xyz[0]
                atm_map["y"] = xyz[1]
                atm_map["z"] = xyz[2]
            atm = self.load_atom(atm_map)
            self.atom_site_name_map[atm_map["name"]] = atm
        #print "%d atoms" % len(self.atom_site_name_map)

        ## load the bonds
        bond_map = {}
        self.read_geom_bond(bond_map)
        self.read_geom_angle(bond_map)
        self.load_bonds(bond_map)
示例#7
0
    def read_geom_bond(self, bond_map):
        """Read bond information form the geom_bond section.
        """
        for t in self.cif.tables:
            if "geom_bond_atom_site_label_1" in t.columns:
                table = t
                break
        else:
            warning("read_atoms: no geom_bond section found")
            return

        for row in range(len(table.rows)):
            name1 = table.get_value("geom_bond_atom_site_label_1", row)
            try:
                atom1 = self.atom_site_name_map[name1]
            except KeyError:
                warning("read_atoms: bond references non-existent atom '%s'" %
                        name1)
                continue
            name2 = table.get_value("geom_bond_atom_site_label_2", row)
            try:
                atom2 = self.atom_site_name_map[name2]
            except KeyError:
                warning("read_atoms: bond references non-existent atom '%s'" %
                        name2)
                continue

            if id(atom1) < id(atom2):
                bnd = (atom1, atom2)
            else:
                bnd = (atom2, atom1)
            bond_map[bnd] = {}
示例#8
0
    def read_geom_bond(self, bond_map):
        """Read bond information form the geom_bond section.
        """
        for t in self.cif.tables:
            if "geom_bond_atom_site_label_1" in t.columns:
                table = t
                break
        else:
            warning("read_atoms: no geom_bond section found")
            return

        for row in range(len(table.rows)):
            name1 = table.get_value("geom_bond_atom_site_label_1", row)
            try:
                atom1 = self.atom_site_name_map[name1]
            except KeyError:
                warning("read_atoms: bond references non-existent atom '%s'"
                        % name1)
                continue
            name2 = table.get_value("geom_bond_atom_site_label_2", row)
            try:
                atom2 = self.atom_site_name_map[name2]
            except KeyError:
                warning("read_atoms: bond references non-existent atom '%s'"
                        % name2)
                continue

            if id(atom1) < id(atom2):
                bnd = (atom1, atom2)
            else:
                bnd = (atom2, atom1)
            bond_map[bnd] = {}