Esempio n. 1
0
 def __init__(self, fasta_align, m1, m2, si=0, sj=1):
     """
     fasta_align --- Alignment object
     m1, m2 --- two models
     si, sj --- the sequences in the Alignment object that
             correspond to the structures
     """
     l=fasta_align.get_alignment_length()
     # Get the residues in the models
     rl1=Selection.unfold_entities(m1, 'R')
     rl2=Selection.unfold_entities(m2, 'R')
     # Residue positions
     p1=0
     p2=0
     # Map equivalent residues to each other
     map12={}
     map21={}
     # List of residue pairs (None if -)
     duos=[]
     for i in range(0, l):
         column=fasta_align.get_column(i)
         aa1=column[si]
         aa2=column[sj]
         if aa1!="-":
             # Position in seq1 is not -
             while True:
                 # Loop until an aa is found
                 r1=rl1[p1]
                 p1=p1+1
                 if is_aa(r1):
                     break
             self._test_equivalence(r1, aa1)
         else:
             r1=None
         if aa2!="-":
             # Position in seq2 is not -
             while True:
                 # Loop until an aa is found
                 r2=rl2[p2]
                 p2=p2+1
                 if is_aa(r2):
                     break
             self._test_equivalence(r2, aa2)
         else:
             r2=None
         if r1:
             # Map residue in seq1 to its equivalent in seq2
             map12[r1]=r2
         if r2:
             # Map residue in seq2 to its equivalent in seq1
             map21[r2]=r1
         # Append aligned pair (r is None if gap)
         duos.append((r1, r2))
     self.map12=map12
     self.map21=map21
     self.duos=duos
Esempio n. 2
0
 def __init__(self, fasta_align, m1, m2, si=0, sj=1):
     """
     fasta_align --- Alignment object
     m1, m2 --- two models
     si, sj --- the sequences in the Alignment object that
             correspond to the structures
     """
     l = fasta_align.get_alignment_length()
     # Get the residues in the models
     rl1 = Selection.unfold_entities(m1, 'R')
     rl2 = Selection.unfold_entities(m2, 'R')
     # Residue positions
     p1 = 0
     p2 = 0
     # Map equivalent residues to each other
     map12 = {}
     map21 = {}
     # List of residue pairs (None if -)
     duos = []
     for i in range(0, l):
         column = fasta_align.get_column(i)
         aa1 = column[si]
         aa2 = column[sj]
         if aa1 != "-":
             # Position in seq1 is not -
             while True:
                 # Loop until an aa is found
                 r1 = rl1[p1]
                 p1 = p1 + 1
                 if is_aa(r1):
                     break
             self._test_equivalence(r1, aa1)
         else:
             r1 = None
         if aa2 != "-":
             # Position in seq2 is not -
             while True:
                 # Loop until an aa is found
                 r2 = rl2[p2]
                 p2 = p2 + 1
                 if is_aa(r2):
                     break
             self._test_equivalence(r2, aa2)
         else:
             r2 = None
         if r1:
             # Map residue in seq1 to its equivalent in seq2
             map12[r1] = r2
         if r2:
             # Map residue in seq2 to its equivalent in seq1
             map21[r2] = r1
         # Append aligned pair (r is None if gap)
         duos.append((r1, r2))
     self.map12 = map12
     self.map21 = map21
     self.duos = duos
Esempio n. 3
0
    def __init__(self, model, radius=12.0, offset=0):
        """
        A residue's exposure is defined as the number of CA atoms around
        that residues CA atom. A dictionary is returned that uses a L{Residue}
        object as key, and the residue exposure as corresponding value.

        @param model: the model that contains the residues
        @type model: L{Model}

        @param radius: radius of the sphere (centred at the CA atom)
        @type radius: float

        @param offset: number of flanking residues that are ignored in the calculation            of the number of neighbors
        @type offset: int

        """
        assert(offset>=0)
        ppb=CaPPBuilder()
        ppl=ppb.build_peptides(model)
        fs_map={}
        fs_list=[]
        fs_keys=[]
        for pp1 in ppl:
            for i in range(0, len(pp1)):
                fs=0
                r1=pp1[i]
                if not is_aa(r1) or not r1.has_id('CA'):
                    continue
                ca1=r1['CA']
                for pp2 in ppl:
                    for j in range(0, len(pp2)):
                        if pp1 is pp2 and abs(i-j)<=offset:
                            continue
                        r2=pp2[j]
                        if not is_aa(r2) or not r2.has_id('CA'):
                            continue
                        ca2=r2['CA']
                        d=(ca2-ca1)
                        if d<radius:
                            fs+=1
                res_id=r1.get_id()
                chain_id=r1.get_parent().get_id()
                # Fill the 3 data structures
                fs_map[(chain_id, res_id)]=fs
                fs_list.append((r1, fs))
                fs_keys.append((chain_id, res_id))
                # Add to xtra
                r1.xtra['EXP_CN']=fs
        AbstractPropertyMap.__init__(self, fs_map, fs_keys, fs_list)
Esempio n. 4
0
def annotate(m, ss_seq):
    """Apply seconardary structure information to residues in model."""
    c = m.get_list()[0]
    all = c.get_list()
    residues = []
    # Now remove HOH etc.
    for res in all:
        if is_aa(res):
            residues.append(res)
    L = len(residues)
    if not (L == len(ss_seq)):
        raise ValueError("Length mismatch %i %i" % (L, len(ss_seq)))
    for i in range(0, L):
        residues[i].xtra["SS_PSEA"] = ss_seq[i]
Esempio n. 5
0
def annotate(m, ss_seq):
    """Apply seconardary structure information to residues in model."""
    c=m.get_list()[0]
    all=c.get_list()
    residues=[]
    # Now remove HOH etc.
    for res in all:
        if is_aa(res):
            residues.append(res)
    L=len(residues)
    if not (L==len(ss_seq)):
        raise ValueError("Length mismatch %i %i" % (L, len(ss_seq)))
    for i in range(0, L):
        residues[i].xtra["SS_PSEA"]=ss_seq[i]
Esempio n. 6
0
 def __init__(self, model, pdb_file):
     depth_dict={}
     depth_list=[]
     depth_keys=[]
     # get_residue
     residue_list=Selection.unfold_entities(model, 'R')
     # make surface from PDB file
     surface=get_surface(pdb_file)
     # calculate rdepth for each residue
     for residue in residue_list:
         if not is_aa(residue):
             continue
         rd=residue_depth(residue, surface)
         ca_rd=ca_depth(residue, surface)
         # Get the key
         res_id=residue.get_id()
         chain_id=residue.get_parent().get_id()
         depth_dict[(chain_id, res_id)]=(rd, ca_rd)
         depth_list.append((residue, (rd, ca_rd)))
         depth_keys.append((chain_id, res_id))
         # Update xtra information
         residue.xtra['EXP_RD']=rd
         residue.xtra['EXP_RD_CA']=ca_rd
     AbstractPropertyMap.__init__(self, depth_dict, depth_keys, depth_list)
Esempio n. 7
0
 def __init__(self, model, pdb_file):
     depth_dict = {}
     depth_list = []
     depth_keys = []
     # get_residue
     residue_list = Selection.unfold_entities(model, 'R')
     # make surface from PDB file
     surface = get_surface(pdb_file)
     # calculate rdepth for each residue
     for residue in residue_list:
         if not is_aa(residue):
             continue
         rd = residue_depth(residue, surface)
         ca_rd = ca_depth(residue, surface)
         # Get the key
         res_id = residue.get_id()
         chain_id = residue.get_parent().get_id()
         depth_dict[(chain_id, res_id)] = (rd, ca_rd)
         depth_list.append((residue, (rd, ca_rd)))
         depth_keys.append((chain_id, res_id))
         # Update xtra information
         residue.xtra['EXP_RD'] = rd
         residue.xtra['EXP_RD_CA'] = ca_rd
     AbstractPropertyMap.__init__(self, depth_dict, depth_keys, depth_list)
Esempio n. 8
0
    def __init__(self, model, radius, offset, hse_up_key, hse_down_key,
            angle_key=None):
        """
        @param model: model
        @type model: L{Model}

        @param radius: HSE radius
        @type radius: float

        @param offset: number of flanking residues that are ignored in the calculation
        of the number of neighbors
        @type offset: int

        @param hse_up_key: key used to store HSEup in the entity.xtra attribute
        @type hse_up_key: string

        @param hse_down_key: key used to store HSEdown in the entity.xtra attribute
        @type hse_down_key: string

        @param angle_key: key used to store the angle between CA-CB and CA-pCB in
            the entity.xtra attribute
        @type angle_key: string
        """
        assert(offset>=0)
        # For PyMOL visualization
        self.ca_cb_list=[]
        ppb=CaPPBuilder()
        ppl=ppb.build_peptides(model)
        hse_map={}
        hse_list=[]
        hse_keys=[]
        for pp1 in ppl:
            for i in range(0, len(pp1)):
                if i==0:
                    r1=None
                else:
                    r1=pp1[i-1]
                r2=pp1[i]
                if i==len(pp1)-1:
                    r3=None
                else:
                    r3=pp1[i+1]
                # This method is provided by the subclasses to calculate HSE
                result=self._get_cb(r1, r2, r3)
                if result is None:
                    # Missing atoms, or i==0, or i==len(pp1)-1
                    continue
                pcb, angle=result
                hse_u=0
                hse_d=0
                ca2=r2['CA'].get_vector()
                for pp2 in ppl:
                    for j in range(0, len(pp2)):
                        if pp1 is pp2 and abs(i-j)<=offset:
                            # neighboring residues in the chain are ignored
                            continue
                        ro=pp2[j]
                        if not is_aa(ro) or not ro.has_id('CA'):
                            continue
                        cao=ro['CA'].get_vector()
                        d=(cao-ca2)
                        if d.norm()<radius:
                            if d.angle(pcb)<(pi/2):
                                hse_u+=1
                            else:
                                hse_d+=1
                res_id=r2.get_id()
                chain_id=r2.get_parent().get_id()
                # Fill the 3 data structures
                hse_map[(chain_id, res_id)]=(hse_u, hse_d, angle)
                hse_list.append((r2, (hse_u, hse_d, angle)))
                hse_keys.append((chain_id, res_id))
                # Add to xtra
                r2.xtra[hse_up_key]=hse_u
                r2.xtra[hse_down_key]=hse_d
                if angle_key:
                    r2.xtra[angle_key]=angle
        AbstractPropertyMap.__init__(self, hse_map, hse_keys, hse_list)