Exemplo n.º 1
0
 def generate_peak_list(self,
                        pdb_code,
                        peak_pdb_hier,
                        model_id,
                        set_chain=False,
                        renumber=False):
     #this function takes a list of peaks from a peak search as a pdb
     #and outputs a list of dictionaries with info and coordinates
     #if chainid is False, original chainids are preserved
     pput = Util()
     peak_list = []
     pdb = peak_pdb_hier
     for model in pdb.models():
         for chain in model.chains():
             ori_chain = chain.id.strip()
             if set_chain:
                 out_chain = set_chain
             else:
                 out_chain = ori_chain
             for resgroups in chain.residue_groups():
                 for atomgroups in resgroups.atom_groups():
                     for atom in atomgroups.atoms():
                         awl = atom.fetch_labels()
                         resname = awl.resname.strip()
                         name = awl.name.strip()
                         altloc = awl.altloc.strip()
                         ori_resid = resgroups.resseq.strip()
                         if renumber:
                             out_resid = str(len(peak_list) + 1)
                         else:
                             out_resid = ori_resid
                         coord = atom.xyz
                         resat = resname + "_" + ori_chain + ori_resid + "_" + name
                         db_id = pput.gen_db_id(pdb_code, out_chain,
                                                out_resid)
                         unat, unal, unrg = pput.gen_unids(awl,
                                                           model=model_id)
                         pdict = self.gen_pdict()
                         pdict["db_id"] = db_id
                         pdict["model"] = model_id
                         pdict["resid"] = out_resid
                         pdict["chainid"] = out_chain
                         pdict["coord"] = coord
                         pdict["unat"] = unat
                         pdict["unal"] = unal
                         pdict["unrg"] = unrg
                         pdict["ori_chain"] = ori_chain
                         pdict["ori_resid"] = ori_resid
                         pdict["resat"] = resat
                         peak_list.append(pdict)
     return peak_list
Exemplo n.º 2
0
    def __init__(self, pdb_code, unid, symmetry, orig_pdb_hier, strip_pdb_hier,
                 peak_pdb_hier, struct_data, chainid, resid, coord, bound):
        #instantiate utility classes
        self.pput = Util()
        self.ppctx = CctbxHelpers()
        #bind some util functions here
        self.write_atom = self.pput.write_atom

        #attach references to structure data for use in this class
        self.pdb_code = struct_data.pdb_code
        self.orig_symmetry = struct_data.orig_symmetry
        self.orig_pdb_hier = struct_data.orig_pdb_hier
        self.orig_xrs = struct_data.orig_xrs
        self.strip_pdb_hier = strip_pdb_hier
        self.peak_pdb_hier = struct_data.peak_pdb_hier
        self.struct_data = struct_data

        self.chainid = chainid  #single letter string
        self.resid = int(resid)
        self.coord = coord  #tuple of floats
        self.bound = bound
        self.grid_last = int(self.bound * 4 + 1)
        self.unid = unid

        #copy pdb,hier,xrs in standard settings
        self.so4_pdb = copy.deepcopy(self.struct_data.std_so4_pdb)
        self.symmetry = self.so4_pdb.crystal_symmetry()
        self.so4_hier = copy.deepcopy(self.struct_data.std_so4_hier)
        self.so4_xrs = copy.deepcopy(self.struct_data.std_so4_xrs)
        self.wat_pdb = copy.deepcopy(self.struct_data.std_wat_pdb)
        self.wat_hier = copy.deepcopy(self.struct_data.std_wat_hier)
        self.wat_xrs = copy.deepcopy(self.struct_data.std_wat_xrs)

        #make local maps
        self.local_map_fofc, self.peak_volume_fofc = self.make_local_map(
            self.struct_data.fofc_map_data)
        self.local_map_2fofc, self.peak_volume_2fofc = self.make_local_map(
            self.struct_data.twofofc_map_data)
        self.shaped_map_fofc = self.make_shaped_map(self.local_map_fofc)
        self.shaped_map_2fofc = self.make_shaped_map(self.local_map_2fofc)
        self.inv_map_fofc = self.make_round_map(self.local_map_fofc, 2.0, True)
        self.inv_map_2fofc = self.make_round_map(self.local_map_2fofc, 2.0,
                                                 True)

        #set peak heights of initial peak
        self.peak_fofc = self.density_at_point(self.struct_data.fofc_map_data,
                                               self.orig_xrs, self.coord)
        self.peak_2fofc = self.density_at_point(
            self.struct_data.twofofc_map_data, self.orig_xrs, self.coord)
Exemplo n.º 3
0
 def __init__(self, master_dictionary, train=False, verbose=False):
     self.verbose = verbose
     self.ppio = DataIO(phenix_python=False)
     self.pput = Util()
     self.ppfilt = Filters(verbose=verbose)
     self.ppstat = StatFunc()
     mdict = master_dictionary
     if train == False:
         self.kdedict = mdict['kde']
         self.populations = self.kdedict['populations']
         self.features = self.kdedict['features']
     else:
         self.populations = ['HOH', 'SO4', 'OTH', 'ML1']
         self.features = ['score', 'cscore']
     self.flat_prior = np.ones(len(self.populations),
                               dtype=np.float32) / len(self.populations)
     #expected value of MLE of alpha coefficients of dirichlet distribution
     #trained against probabilities from +1 smoothed counts from entire PDB
     self.dir_prior = np.array(
         [0.8516044, 0.04814615, 0.05036076, 0.04988869])
Exemplo n.º 4
0
 def basic_features(self, features, peak_object):
     #add data on rotations,peak heights, volumes, local environment, etc.
     pput = Util()
     features['resid'] = peak_object.resid
     features['chainid'] = peak_object.chainid
     features['coord'] = peak_object.coord
     features['vol_fofc'] = peak_object.peak_volume_fofc
     features['vol_2fofc'] = peak_object.peak_volume_2fofc
     features['fofc_sig_in'] = peak_object.peak_fofc
     features['2fofc_sig_in'] = peak_object.peak_2fofc
     features['fofc_sig_out'] = peak_object.density_at_point(
         peak_object.local_map_fofc, features['wat_fofc_ref_xrs'],
         features['wat_fofc_coord_out'])
     features['2fofc_sig_out'] = peak_object.density_at_point(
         peak_object.local_map_2fofc, features['wat_fofc_ref_xrs'],
         features['wat_fofc_coord_out'])
     #rescale density level to account for lack of variance in solvent region
     features['2fofc_sigo_scaled'] = pput.scale_density(
         features['2fofc_sig_out'], features['solc'])
     features['fofc_sigo_scaled'] = pput.scale_density(
         features['fofc_sig_out'], features['solc'])
     new_coord = features['wat_fofc_coord_out']
     features['dmove'] = np.linalg.norm(
         np.subtract(new_coord, (5.0, 5.0, 5.0)))
Exemplo n.º 5
0
 def get_contacts(self, s_atom, cpairs, cutoff=6.0):
     pput = Util()
     s_resname = s_atom.resname.strip()
     s_chain = str(s_atom.chain().id).strip()
     s_model_id = s_atom.model_id.strip()
     s_element = s_atom.element.strip()
     s_name = s_atom.name.strip()
     s_altloc = s_atom.altloc.strip()
     s_resid = s_atom.resseq.strip()
     s_coord = s_atom.xyz
     s_unat, s_unal, s_unrg = pput.gen_unids(s_atom)
     s_resat = s_resname + "_" + s_chain + s_resid + "_" + s_name
     contacts = []
     for cpair in cpairs:
         distance = cpair[1]
         #contact_atom
         c_atom = cpair[0]
         c_sym = int(cpair[2])
         resname = c_atom.resname.strip()
         chain = str(c_atom.chain().id).strip()
         model_id = c_atom.model_id.strip()
         element = c_atom.element.strip()
         name = c_atom.name.strip()
         altloc = c_atom.altloc.strip()
         resid = c_atom.resseq.strip()
         coord = c_atom.xyz
         unat, unal, unrg = pput.gen_unids(c_atom)
         resat = resname + "_" + chain + resid + "_" + name
         if s_model_id == "":
             s_model_id = 5
         if model_id == "":
             model_id = 5
         special = False
         ctype = "unknown"
         if s_unat == unat:
             ctype = "self"
             if distance < 1.8:
                 special = True
         elif int(model_id) == int(s_model_id):
             ctype = "intra"
         else:
             ctype = "inter"
         #everything goes into a dictionary (some converted to int)
         contact = {
             "name": name,
             "chain": chain,
             "element": element,
             "distance": distance,
             "coord": coord,
             "resname": resname,
             "altloc": altloc,
             "resid": int(resid),
             "model": int(model_id),
             "special": special,
             "unat": unat,
             "unal": unal,
             "unrg": unrg,
             "s_name": s_name,
             "s_chain": s_chain,
             "s_element": s_element,
             "s_coord": s_coord,
             "s_resname": s_resname,
             "s_altloc": s_altloc,
             "s_resid": int(s_resid),
             "s_model": int(s_model_id),
             "ctype": ctype,
             "s_unat": s_unat,
             "s_unal": s_unal,
             "s_unrg": s_unrg,
             "s_resat": s_resat,
             "resat": resat,
             "sym": c_sym
         }
         contacts.append(contact)
     contacts.sort(key=lambda x: x['distance'])
     return contacts, s_unal
Exemplo n.º 6
0
 def __init__(self):
     self.pput = Util()