B
    ê×æb¬  ã               @   s,   d dl mZ d dlZdZG dd„ deƒZdS )é    )Úprint_functionNz!Marcin Kowiel, Dariusz Brzezinskic               @   s    e Zd ZdZdd„ Zdd„ Zdd„ Zedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZdd„ Zdd„ Zdd„ ZdS )ÚAtom)Úchain_idÚres_idÚres_nameÚ	atom_nameÚalt_locÚatom_xyzÚi_seqc             C   s>   |  ¡ | _|| _|  ¡ | _|  ¡ | _|  ¡ | _|| _|| _dS )ah  
        Represents an atom from a pdb file, for which restraints (e.g., bond length or angle) will be created.
        :param chain_id: chain id
        :param res_id: residual id
        :param res_name: residual name
        :param atom_name: atom name
        :param alt_loc: alternate location
        :param atom_xyz: xyz coordinates of the atom
        N)Ústripr   r   r   r   r   r	   r
   )Úselfr   r   r   r   r   r	   r
   © r   ú0lib/python3.7/site-packages/restraintlib/atom.pyÚ__init__   s    




zAtom.__init__c             C   s    d  | j| j| j| j| j| j¡S )z4
        String representation of the atom.
        z:chain: {} res: {} monomer: {} atom: {} alt loc: {} xyz: {})Úformatr   r   r   r   r   r	   )r   r   r   r   Ú__str__!   s    zAtom.__str__c             C   sH   | j |j koF| j|jkoF| j|jkoF| j|jkoF| j|jkoF| j|jkS )N)r   r   r   r   r   r	   )r   Úotherr   r   r   Ú__eq__(   s    zAtom.__eq__c             C   s0   || ||  | | ||  || ||  fS )Nr   )ÚclsÚx1Zy1Zz1Zx2Úy2Zz2r   r   r   Úcross32   s    zAtom.cross3c          	   C   s,   |   |d |d |d |d |d |d ¡S )Nr   é   é   )r   )r   ÚaÚbr   r   r   Úcross6   s    z
Atom.crossc             C   s.   |d |d  |d |d  |d |d  fS )Nr   r   r   r   )r   r   r   r   r   r   Úsub:   s    zAtom.subc             C   s0   |d |d  |d |d   |d |d   S )Nr   r   r   r   )r   r   r   r   r   r   Údot>   s    zAtom.dotc             C   s   t  |  ||¡¡S )N)ÚmathÚsqrtr   )r   r   r   r   r   ÚlenghtB   s    zAtom.lenghtc             C   s"   ||d  ||d  ||d  fS )Nr   r   r   r   )r   ZscaÚvecr   r   r   Úmul_scaF   s    zAtom.mul_scac             C   s   |   |¡}|  d| |¡S )Ng      ð?)r!   r#   )r   r"   Z
vec_lenghtr   r   r   Ú	normalizeJ   s    
zAtom.normalizec             C   s   |   |  ||¡|¡S )N)r   r   )r   r   r   Úcr   r   r   ÚdetO   s    zAtom.detc             C   sZ   | j d |j d  }| j d |j d  }| j d |j d  }t || ||  ||  ¡S )Nr   r   r   )r	   r   r    )r   ZatomZdxZdyZdzr   r   r   ÚdistS   s    z	Atom.distc             C   sX   |   | j|j¡}|   |j|j¡}|  ||¡}|  |¡|  |¡ }t || ¡}t |¡S )N)r   r	   r   r!   r   ZacosÚdegrees)r   Úatom2Úatom3r   r   r%   ÚdÚangler   r   r   r,   Y   s    z
Atom.anglec             C   s„   |   |j| j¡}|   |j|j¡}|   |j|j¡}|  ||¡}|  |¡|  ||¡ }|  ||¡}	|  |	|¡}
t ||
¡}t |¡}|S )zÆ
        Return torsion of self -> atom2, atom2 -> atom3, atom3 -> atom4 vectors.
        :param atom2:
        :param atom3:
        :param atom4:
        :return: torsion angle in degrees
        )r   r	   r   r!   r   r   Zatan2r(   )r   r)   r*   Zatom4Zvector1Zvector2Zvector3r   Úyr   ÚxÚtorsionr   r   r   r/   a   s    
zAtom.torsionN)Ú__name__Ú
__module__Ú__qualname__Ú	__slots__r   r   r   Úclassmethodr   r   r   r   r!   r#   r$   r&   r'   r,   r/   r   r   r   r   r   	   s   
r   )Z
__future__r   r   Ú
__author__Úobjectr   r   r   r   r   Ú<module>   s   