ó
ŠöIc           @   sN  d  d l  Z  d  d l m Z d  d l m Z d Z d d d     YZ e d k rJd  d l Z d  d l	 Te
   Z e j d	 e j d
  Z e j e d  Z e j d e j d
  Z e j e d  Z e  j d  j d  Z e  j d d  Z x e D] Z e j e e  qũ We   Z e j e e  e j GHe j GHe j e  n  d S(   iĸĸĸĸN(   t   SVDSuperimposer(   t   PDBExceptions   Superimpose two structures.t   Superimposerc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s_   
    Rotate/translate one set of atoms on top of another,
    thereby minimizing the RMSD.
    c         C   s   d  |  _ d  |  _ d  S(   N(   t   Nonet   rotrant   rms(   t   self(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Superimposer.pyt   __init__   s    	c         C   sę   t  |  t  |  k s' t d   n  t  |  } t j | d f  } t j | d f  } xE t d t  |   D]. } | | j   | | <| | j   | | <qs Wt   } | j | |  | j   | j	   |  _
 | j   |  _ d S(   s  
        Put (translate/rotate) the atoms in fixed on the atoms in 
        moving, in such a way that the RMSD is minimized.

        @param fixed: list of (fixed) atoms
        @param moving: list of (moving) atoms 
        @type fixed,moving: [L{Atom}, L{Atom},...]
        s*   Fixed and moving atom lists differ in sizei   i    N(   t   lenR   t   numpyt   zerost   ranget	   get_coordR    t   sett   runt   get_rmsR   t
   get_rotranR   (   R   t   fixedt   movingt   lt   fixed_coordt   moving_coordt   it   sup(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Superimposer.pyt	   set_atoms   s    		
c         C   sp   |  j  d k r t d   n  |  j  \ } } | j d  } | j d  } x | D] } | j | |  qR Wd S(   s3   
        Rotate/translate a list of atoms.
        s)   No transformation has been calculated yett   fN(   R   R   R   t   astypet	   transform(   R   t	   atom_listt   rott   trant   atom(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/PDB/Superimposer.pyt   apply-   s    (   t   __name__t
   __module__t   __doc__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/Superimposer.pyR      s   		t   __main__(   t   *t   FIXEDi   t   At   MOVINGi   R   g      ð?g       @g      @(    (   g      ð?g       @g      @(    R	   t   Bio.SVDSuperimposerR    t   Bio.PDB.PDBExceptionsR   R#   R   R!   t   syst   Bio.PDBt	   PDBParsert   pt   get_structuret   argvt   s1t	   Selectiont   unfold_entitiesR   t   s2R   t   identityR   R   t   arrayR   R   R   R   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/Superimposer.pyt   <module>   s*   -
		