o
    RÅ€g—  ã                   @   s6   d Z ddlZddlmZ ddlmZ G dd„ dƒZdS )zSuperimpose two structures.é    N)ÚPDBException)ÚSVDSuperimposerc                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚSuperimposerzERotate/translate one set of atoms on top of another to minimize RMSD.c                 C   s   d| _ d| _dS )zInitialize the class.N)ÚrotranÚrms)Úself© r   úH/var/www/html/myenv/lib/python3.10/site-packages/Bio/PDB/Superimposer.pyÚ__init__   s   
zSuperimposer.__init__c                 C   sœ   t |ƒt |ƒkstdƒ‚t |ƒ}t |df¡}t |df¡}t|ƒD ]}||  ¡ ||< ||  ¡ ||< q"tƒ }| ||¡ | ¡  | 	¡ | _
| ¡ | _dS )aP  Prepare translation/rotation to minimize RMSD between atoms.

        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},...]
        z*Fixed and moving atom lists differ in sizeé   N)Úlenr   ÚnpÚzerosÚrangeÚ	get_coordr   ÚsetÚrunÚget_rmsr   Ú
get_rotranr   )r   ÚfixedÚmovingÚlengthÚfixed_coordÚmoving_coordÚiÚsupr   r   r	   Ú	set_atoms   s   

zSuperimposer.set_atomsc                 C   sJ   | j du r	tdƒ‚| j \}}| d¡}| d¡}|D ]}| ||¡ qdS )z!Rotate/translate a list of atoms.Nz)No transformation has been calculated yetÚf)r   r   ÚastypeÚ	transform)r   Ú	atom_listÚrotÚtranÚatomr   r   r	   Úapply0   s   



ÿzSuperimposer.applyN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   r$   r   r   r   r	   r      s
    r   )r(   Únumpyr   ÚBio.PDB.PDBExceptionsr   ÚBio.SVDSuperimposerr   r   r   r   r   r	   Ú<module>   s
   