示例#1
0
def getLigandNbrs(resids: List[Residue],
                  struct: Structure) -> List[ResidueDict]:
    """KDTree search the neighbors of a given list of residues(which constitue a ligand) 
    and return unique having tagged them with a ban identifier proteins within 5 angstrom of these residues. """
    ns = NeighborSearch(list(struct.get_atoms()))
    nbrs = []

    for r in resids:
        # a ligand consists of residues
        resatoms = r.child_list[0]
        #  each residue has an atom plucked at random
        for nbrresidues in ns.search(resatoms.get_coord(), 5, level='R'):
            # we grab all residues in radius around that atom and extend the list of neighbors with those
            nbrs.extend([nbrresidues])

    # Filter out the residues that constitute the ligand itself
    filtered = []
    for neighbor in nbrs:
        present = 0
        for constit in resids:
            if ResidueDict(constit) == ResidueDict(neighbor):
                present = 1
        if present == 0:
            filtered.append(ResidueDict(neighbor))

    return [*map(lambda x: addBanClass(x), set(filtered))]
    def merge_structure(self, new_st: Structure, mod_id: str, ch_id: str,
                        brk_list: Union[Sequence[Atom],
                                        Sequence[Sequence[Atom]]],
                        offset: int) -> Union[str, List[str]]:
        spimp = Superimposer()
        fixed_ats = [
            atm for atm in self.st[mod_id][ch_id].get_atoms() if atm.id == 'CA'
        ]
        moving_ats = []
        for atm in fixed_ats:
            moving_ats.append(new_st[0][' '][atm.get_parent().id[1] - offset +
                                             1]['CA'])
        spimp.set_atoms(fixed_ats, moving_ats)
        spimp.apply(new_st.get_atoms())

        list_res = self.st[mod_id][ch_id].get_list()
        fixed_gaps = []
        for i in range(0,
                       len(self.sequence_data.data[ch_id]['pdb'][mod_id]) - 1):
            gap_start = self.sequence_data.data[ch_id]['pdb'][mod_id][
                i].features[0].location.end
            gap_end = self.sequence_data.data[ch_id]['pdb'][mod_id][
                i + 1].features[0].location.start

            if [
                    self.st[mod_id][ch_id][gap_start],
                    self.st[mod_id][ch_id][gap_end]
            ] not in brk_list:
                continue

            pos = 0
            while pos < len(list_res) and self.st[mod_id][ch_id].child_list[
                    pos].id[1] != gap_start:
                pos += 1
            self.remove_residue(self.st[mod_id][ch_id][gap_start],
                                update_int=False)
            self.remove_residue(self.st[mod_id][ch_id][gap_end],
                                update_int=False)
            for nres in range(gap_start, gap_end + 1):
                res = new_st[0][' '][nres - offset + 1].copy()
                res.id = (' ', nres, ' ')
                self.st[mod_id][ch_id].insert(pos, res)
                pos += 1
                print("Adding " + mu.residue_id(res))
            fixed_gaps.append('{}{}-{}{}/{}'.format(ch_id, gap_start, ch_id,
                                                    gap_end, mod_id + 1))
            print()
        return fixed_gaps
示例#3
0
def getLigandNbrs(resids: List[Residue], struct:Structure):
    ns   = NeighborSearch(list( struct.get_atoms() ))
    nbrs = []
    for r in resids:
        # a ligand consists of residues
        resatom = r.child_list[0]
        #  each residue has an atom plucked at random
        for nbr in ns.search(resatom.get_coord(), 5,level='R'):
            # we grab all residues in radius around that atom and extend the list with those
            nbrs.extend([* nbr])
    filtered = [] 
    for neighor in nbrs:
        present = 0
        for constit in resids:
            if ResidueId( constit ) == ResidueId( neighor ):
                present = 1
        if present == 0:
            filtered.append(ResidueId(neighor))
    return [ * map(lambda x: addBanClass(x) ,  set(filtered) ) ]
示例#4
0
文件: Residue.py 项目: rtviii/ribxz
def getResidueNeighbors(struct:Structure, resid: ResidueFullIdDict, radius:float, level:str = 'R', all_levels=False)-> List[Residue] or List[Chain] or List[Chain or Residue]:

    """
    struct: opened cif structure
    resid: A dictionary containing the residue's identifiers (see associated class)
    radiue: radius of neighborhood to check
    level: Atom, Residue, Chain : one of A/R/C
    """

    if level.upper() not in ['A', 'R', 'C']:
        print('Level has to be one of A R C')
        raise Error

    parentStrand      :Chain         = struct[resid.model][resid.strand_id]
    residuesOfInterest:List[Residue] = list(filter(lambda x : x.get_full_id()[3][1] == resid.residue_id, parentStrand.child_list))

    ligandAtoms = residuesOfInterest[0].get_atoms()

    coords      = list( map(lambda atom: atom.get_coord(), ligandAtoms) )
    ns          = NeighborSearch(list( struct.get_atoms() ))

    yield ns.search(coords[0],radius,level.upper())