Example #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
Example #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
Example #3
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)
Example #4
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)
Example #5
0
    def __contains__(self, res):
        """True if the given residue is in any of the mapped fragments.

        @type res: L{Residue}
        """
        return (res in self.fd)

    def __getitem__(self, res):
        """
        @type res: L{Residue}

        @return: fragment classification
        @rtype: L{Fragment}
        """
        return self.fd[res]


if __name__ == "__main__":

    import sys

    p = PDBParser()
    s = p.get_structure("X", sys.argv[1])
    m = s[0]
    fm = FragmentMapper(m, 10, 5, "levitt_data")

    for r in Selection.unfold_entities(m, "R"):
        print("%s:" % r)
        if r in fm:
            print(fm[r])
Example #6
0
            raise PDBException("No transformation has been calculated yet")
        rot, tran=self.rotran
        rot=rot.astype('f')
        tran=tran.astype('f')
        for atom in atom_list:
            atom.transform(rot, tran)


if __name__=="__main__":
    import sys

    from SAP.Bio.PDB import PDBParser, Selection

    p=PDBParser()
    s1=p.get_structure("FIXED", sys.argv[1])
    fixed=Selection.unfold_entities(s1, "A")

    s2=p.get_structure("MOVING", sys.argv[1])
    moving=Selection.unfold_entities(s2, "A")

    rot=numpy.identity(3).astype('f')
    tran=numpy.array((1.0, 2.0, 3.0), 'f')

    for atom in moving:
        atom.transform(rot, tran)

    sup=Superimposer()

    sup.set_atoms(fixed, moving)

    print(sup.rotran)
Example #7
0
    def __contains__(self, res):
        """True if the given residue is in any of the mapped fragments.

        @type res: L{Residue}
        """
        return (res in self.fd)

    def __getitem__(self, res):
        """
        @type res: L{Residue}

        @return: fragment classification
        @rtype: L{Fragment}
        """
        return self.fd[res]


if __name__=="__main__":

    import sys

    p = PDBParser()
    s = p.get_structure("X", sys.argv[1])
    m = s[0]
    fm = FragmentMapper(m, 10, 5, "levitt_data")

    for r in Selection.unfold_entities(m, "R"):
        print("%s:" % r)
        if r in fm:
            print(fm[r])
Example #8
0
            raise PDBException("No transformation has been calculated yet")
        rot, tran = self.rotran
        rot = rot.astype('f')
        tran = tran.astype('f')
        for atom in atom_list:
            atom.transform(rot, tran)


if __name__ == "__main__":
    import sys

    from SAP.Bio.PDB import PDBParser, Selection

    p = PDBParser()
    s1 = p.get_structure("FIXED", sys.argv[1])
    fixed = Selection.unfold_entities(s1, "A")

    s2 = p.get_structure("MOVING", sys.argv[1])
    moving = Selection.unfold_entities(s2, "A")

    rot = numpy.identity(3).astype('f')
    tran = numpy.array((1.0, 2.0, 3.0), 'f')

    for atom in moving:
        atom.transform(rot, tran)

    sup = Superimposer()

    sup.set_atoms(fixed, moving)

    print(sup.rotran)