Esempio n. 1
0
    def run(self):
        xrs = self.pdb_hierarchy.extract_xray_structure(
            crystal_symmetry=self.crystal_symmetry)
        xrs.scattering_type_registry(table=self.params.scattering_table)
        soin = maptbx.shift_origin_if_needed(
            map_data=self.map_data,
            sites_cart=xrs.sites_cart(),
            crystal_symmetry=self.crystal_symmetry)
        map_data = soin.map_data
        xrs.set_sites_cart(soin.sites_cart)
        self.five_cc_result = mmtbx.maps.correlation.five_cc(
            map=map_data,
            xray_structure=xrs,
            d_min=self.params.resolution,
            compute_cc_mask=self.params.compute_cc_mask,
            compute_cc_volume=self.params.compute_cc_volume,
            compute_cc_peaks=self.params.compute_cc_peaks)
        # Atom radius
        self.atom_radius = mtriage.get_atom_radius(
            xray_structure=xrs,
            d_min=self.params.resolution,
            map_data=map_data,
            crystal_symmetry=self.crystal_symmetry,
            radius=self.params.atom_radius)
        # Model-map FSC
        if (self.params.compute_fsc):
            mtriage_params = mtriage.master_params().extract()
            mtriage_params.scattering_table = self.params.scattering_table
            mtriage_params.compute_d_model = False
            mtriage_params.compute_d99 = False
            mtriage_params.radius_smooth = self.atom_radius
            self.fsc = mtriage.mtriage(
                map_data=self.map_data,
                pdb_hierarchy=self.pdb_hierarchy,
                crystal_symmetry=self.crystal_symmetry,
                params=mtriage_params).run().get_results().fsc_curve_model.fsc
        #
        cc_calculator = mmtbx.maps.correlation.from_map_and_xray_structure_or_fmodel(
            xray_structure=xrs,
            map_data=map_data,
            d_min=self.params.resolution)

        #
        def get_common_data(atoms, atom_radius):
            sel = atoms.extract_i_seq()
            return group_args(b_iso_mean=flex.mean(atoms.extract_b()),
                              occ_mean=flex.mean(atoms.extract_occ()),
                              n_atoms=atoms.size(),
                              cc=cc_calculator.cc(selection=sel,
                                                  atom_radius=atom_radius),
                              xyz_mean=atoms.extract_xyz().mean())

        # CC per chain
        if (self.params.compute_cc_per_chain):
            for chain in self.pdb_hierarchy.chains():
                cd = get_common_data(atoms=chain.atoms(),
                                     atom_radius=self.atom_radius)
                self.cc_per_chain.append(
                    group_args(chain_id=chain.id,
                               b_iso_mean=cd.b_iso_mean,
                               occ_mean=cd.occ_mean,
                               n_atoms=cd.n_atoms,
                               cc=cd.cc))
        # CC per residue
        if (self.params.compute_cc_per_residue):
            for rg in self.pdb_hierarchy.residue_groups():
                for conformer in rg.conformers():
                    for residue in conformer.residues():
                        cd = get_common_data(atoms=residue.atoms(),
                                             atom_radius=self.atom_radius)
                        self.cc_per_residue.append(
                            group_args(
                                chain_id=rg.parent().id,
                                resname=residue.resname,
                                resseq=residue.resseq,
                                icode=residue.icode,
                                b_iso_mean=cd.b_iso_mean,
                                occ_mean=cd.occ_mean,
                                n_atoms=cd.n_atoms,
                                cc=cd.cc,
                                xyz_mean=cd.xyz_mean,
                                residue=residue))  # for compatibility with GUI
Esempio n. 2
0
 def run(self):
   xrs = self.pdb_hierarchy.extract_xray_structure(
     crystal_symmetry=self.crystal_symmetry)
   xrs.scattering_type_registry(table = self.params.scattering_table)
   soin = maptbx.shift_origin_if_needed(
     map_data         = self.map_data,
     sites_cart       = xrs.sites_cart(),
     crystal_symmetry = self.crystal_symmetry)
   map_data = soin.map_data
   xrs.set_sites_cart(soin.sites_cart)
   self.five_cc = mmtbx.maps.correlation.five_cc(
     map               = map_data,
     xray_structure    = xrs,
     keep_map_calc     = self.params.keep_map_calc,
     d_min             = self.params.resolution,
     compute_cc_mask   = self.params.compute.cc_mask,
     compute_cc_volume = self.params.compute.cc_volume,
     compute_cc_peaks  = self.params.compute.cc_peaks,
     compute_cc_box    = self.params.compute.cc_box,
     compute_cc_image  = self.params.compute.cc_image)
   # Atom radius
   self.atom_radius = mtriage.get_atom_radius(
     xray_structure = xrs,
     resolution     = self.params.resolution,
     radius         = self.params.atom_radius)
   #
   cc_calculator = mmtbx.maps.correlation.from_map_and_xray_structure_or_fmodel(
     xray_structure = xrs,
     map_data       = map_data,
     d_min          = self.params.resolution)
   #
   def get_common_data(atoms, atom_radius):
     sel = atoms.extract_i_seq()
     cc = cc_calculator.cc(selection = sel, atom_radius = atom_radius)
     return group_args(
       b_iso_mean = flex.mean(atoms.extract_b()),
       occ_mean   = flex.mean(atoms.extract_occ()),
       n_atoms    = atoms.size(),
       cc         = cc,
       xyz_mean   = atoms.extract_xyz().mean())
   # CC per chain
   if(self.params.compute.cc_per_chain):
     for chain in self.pdb_hierarchy.chains():
       cd = get_common_data(atoms=chain.atoms(), atom_radius=self.atom_radius)
       self.cc_per_chain.append(group_args(
         chain_id   = chain.id,
         b_iso_mean = cd.b_iso_mean,
         occ_mean   = cd.occ_mean,
         n_atoms    = cd.n_atoms,
         cc         = cd.cc))
   # CC per residue
   if(self.params.compute.cc_per_residue):
     for rg in self.pdb_hierarchy.residue_groups():
       for conformer in rg.conformers():
         for residue in conformer.residues():
           cd = get_common_data(
             atoms       = residue.atoms(),
             atom_radius = self.atom_radius)
           self.cc_per_residue.append(group_args(
             chain_id   = rg.parent().id,
             resname    = residue.resname,
             resseq     = residue.resseq,
             icode      = residue.icode,
             b_iso_mean = cd.b_iso_mean,
             occ_mean   = cd.occ_mean,
             n_atoms    = cd.n_atoms,
             cc         = cd.cc,
             xyz_mean   = cd.xyz_mean))
   # Side chain
   sel_mc_str = "protein and (name C or name N or name CA or name O or name CB)"
   asc = self.pdb_hierarchy.atom_selection_cache()
   sel_mc = asc.selection(sel_mc_str)
   sel_sc = ~sel_mc
   if(sel_mc.count(True)>0):
     self.cc_main_chain = get_common_data(
       atoms       = self.pdb_hierarchy.select(sel_mc).atoms(),
       atom_radius = self.atom_radius)
   if(sel_sc.count(True)>0):
     self.cc_side_chain = get_common_data(
       atoms       = self.pdb_hierarchy.select(sel_sc).atoms(),
       atom_radius = self.atom_radius)