ó
ê9êHc           @   s  d  d l  Td Z d d d „  ƒ  YZ e d k rd  d l Z d  d l Z d  d l  Te j j j	 e j
 d d ƒ Z e j
 d	 Z e j
 d
 Z e ƒ  Z e j d e ƒ Z e ƒ  Z e j d e ƒ Z e d Z e d Z e e e e ƒ Z x& e j ƒ  D] \ Z Z e Ge GHqó Wn  d S(   iÿÿÿÿ(   t   *sT   
Map the residues of two structures to each other based on 
a FASTA alignment file.
t   StructureAlignmentc           B   s8   e  Z d  Z d d d „ Z d „  Z d „  Z d „  Z RS(   s]   
    This class aligns two structures based on a FASTA alignment of their
    sequences.
    i    i   c         C   s¡  | j  ƒ  } | j | ƒ } | j | ƒ } t j | d ƒ }	 t j | d ƒ }
 d } d } i  } i  } g  } xt d | ƒ D]} | j | ƒ } | | } | | } | d k rï x( |	 | } | d } t | ƒ r´ Pq´ q´ W|  j | | ƒ n d } | d k r?x( |
 | } | d } t | ƒ rPqqW|  j | | ƒ n d } | rX| | | <n  | rk| | | <n  | j	 | | f ƒ q| W| |  _
 | |  _ | |  _ d S(   sÔ   
        fasta_align --- A Bio.Fasta.FastaAlign object 
        m1, m2 --- two models
        si, sj --- the sequences in the Bio.Fasta.FastaAlign object that
                correspond to the structures
        t   Ri    t   -i   N(   t   get_alignment_lengtht   get_seq_by_numt	   Selectiont   unfold_entitiest   ranget
   get_columnt   is_aat   _test_equivalencet   Nonet   appendt   map12t   map21t   duos(   t   selft   fasta_alignt   m1t   m2t   sit   sjt   lt   s1t   s2t   rl1t   rl2t   p1t   p2R   R   R   t   it   columnt   aa1t   aa2t   r1t   r2(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureAlignment.pyt   __init__   sL    





		c         C   s,   | j  ƒ  } t | } | | k s( t ‚ d S(   s,   Test if aa in sequence fits aa in structure.N(   t   get_resnamet   to_one_letter_codet   AssertionError(   R   R"   R    t   resname(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureAlignment.pyR   N   s    
c         C   s   |  j  |  j f S(   s‰   
        Return two dictionaries that map a residue in one structure to 
        the equivealent residue in the other structure.
        (   R   R   (   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureAlignment.pyt   get_mapsT   s    c         c   s3   x, t  d t |  j ƒ ƒ D] } |  j | Vq Wd S(   s2   
        Iterator over all residue pairs.
        i    N(   R   t   lenR   (   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureAlignment.pyt   get_iterator[   s    (   t   __name__t
   __module__t   __doc__R$   R   R)   R+   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureAlignment.pyR      s
   ;		t   __main__Ni   t   PROTEINi   i   t   1t   2i    (    (   t   Bio.PDBR.   R   R,   t   syst   Bio.Fasta.FastaAlignt   Biot   Fastat
   FastaAlignt
   parse_filet   argvt   fat	   pdb_file1t	   pdb_file2t	   PDBParsert   pt   get_structureR   R   R   R   t   alR+   R"   R#   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/StructureAlignment.pyt   <module>   s$   
U
		

