B
    b
(              %   @   s  d Z ddddddddd	d
dddddddddddddddddddddd d!d"d#d$d%g%ZG d&d' d'eZG d(d deZed)ddZed*dd+Zed,dd-Zed.dd/d0d1gZed2dd d3d4gZ	ed5d	d6d7d8gZ
ed9d
d:Zed;ddZed<dd=d>d?d@gZedAddBZedCddDZedEddFZedGddHdIgZedJddKZedLddMZedNddOZedPddQZedRddSZedTddUZedVddWZedXddYZG dZd deZG d[d deZed\dd]d^d_d`gZedaddbdcdddedfgZedgddhdidjdkdlgZedmddndodpgZed\dd]dqdrdsdtdudvdwgZ edad dbdxdydzd{d|d}d~dg	Z!edgddhdddddddgZ"eddddddddddgZ#edmdSdndddddddgZ$dddddddhZ%e%dhB Z&ddhZ'dddddddddddddddddHdhZ(ddddddddhZ)e(e)B Z*dBS )zq
This module contains basic information and functionality related to individual
residues in typical biopolymers.
AminoAcidResidue
RNAResidue
DNAResidueALAARGASNASPCYSGLUGLNGLYHISHYPILELEULYSMETPHEPROSERTHRTRPTYRVALDADTDGDCAUGCSOLVENT_NAMESEXTRA_POINT_NAMESCATION_NAMESANION_NAMESALLION_NAMESc               @   sN   e Zd ZdZe Ze Ze Zg Zdd Z	e
dd Zdd Ze
dd	 Zd
S )BiomolecularResiduez9 Base class for different classes of biopolymer residues c             O   s   t dd S )Nz&BiomolecularResidue must be subclassed)NotImplementedError)selfargskwargs r+   -lib/python3.7/site-packages/parmed/residue.pyZ__init_   s    zBiomolecularResidue.__init_c             C   s   t dd S )Nz&BiomolecularResidue must be subclassed)r'   )clskeyr+   r+   r,   get   s    zBiomolecularResidue.getc             C   s   | j S )N)name)r(   r+   r+   r,   __str__   s    zBiomolecularResidue.__str__c             C   s@   t |tr|| jkS y| | W n tk
r6   dS X dS dS )a  
        Determines if a particular BiomolecularResidue or residue name is
        present in this classification of biomolecular residues

        Parameters
        ----------
        thing : str or :class:`BiomolecularResidue`

        Returns
        -------
        contains : bool
            If the residue or residue name *is* of this type, True. Otherwise,
            False.
        FTN)
isinstancer&   all_residuesr/   KeyError)r-   thingr+   r+   r,   has   s    

zBiomolecularResidue.hasN)__name__
__module____qualname____doc__dict_all_residues_by_name_all_residues_by_abbr_all_residues_by_symbolr3   Z_BiomolecularResidue__init_classmethodr/   r1   r6   r+   r+   r+   r,   r&      s   r&   c               @   sF   e Zd ZdZe Ze Ze Zg Zd
ddZ	dd Z
eddd	ZdS )r   a  
    An individual amino acid residue.

    Parameters
    ----------
    name : str
        The name of the residue
    abbr : str
        The 3-letter abbreviation of the amino acid residue
    symbol : str
        The 1-letter symbol of the amino acid
    aliases : list of str, optional
        A list of other abbreviations that *also* refer to this residue

    Raises
    ------
    ValueError
        If any aliases have the same abbreviation as *other*
    Nc             C   s   || _ || _|| _| t| j| < | t| j| < |d k	rP| t| j| < t| j	|  |d k	rx<|D ]4}| }|t| jkrt
d| | t| j|< qnW d S )Nz%s is already an abbreviation)r0   abbrsymboltyper<   upperr=   r>   r3   append
ValueError)r(   r0   r@   rA   aliasesaliasr+   r+   r,   __init__S   s    
zAminoAcidResidue.__init__c             C   s   d| j | j| jf S )Nz <Amino Acid Residue %s: %s [%s]>)r0   r@   rA   )r(   r+   r+   r,   __repr__c   s    
zAminoAcidResidue.__repr__Fc             C   sx   t |dkr|s| j|  S t |dkr8| j|  S t |dkrj|d  dkrj| j|dd   S | j|  S )a  
        Gets the amino acid corresponding to either the residue name, 3-letter
        abbreviation or 1-letter symbol. It is case-insensitive.

        Parameters
        ----------
        key : str
            1-letter symbol, 3-letter abbreviation, or residue name
        abbronly : bool
            If True, only look for the 3-letter abbreviation (not the 1-letter
            symbol)

        Returns
        -------
        residue : :class:`AminoAcidResidue`
            The residue corresponding to the given key

        Raises
        ------
        KeyError if ``key`` is not a symbol, abbreviation, or case-insensitive
        name of an amino acid residue, or any of its abbreviations.
                     CNN)lenr>   rC   r=   r<   )r-   r.   Zabbronlyr+   r+   r,   r/   g   s    zAminoAcidResidue.get)N)F)r7   r8   r9   r:   r;   r<   r=   r>   r3   rH   rI   r?   r/   r+   r+   r+   r,   r   :   s   
ZAlanineZArginineRZ
AsparagineNZ	AspartateDZASHZAS4ZCysteineZCYMZCYXZ	GlutamateEZGLHZGL4Z	GlutamineQZGlycineZ	HistidineHZHIPZHIEZHIDZHydroxyprolineNZ
IsoleucineIZLeucineLZLysineKZLYNZ
MethionineMZPhenylalanineFZProlinePZSerineSZ	ThreonineTZ
TryptophanWZTyrosineYZValineVc               @   sD   e Zd ZdZe Ze Ze Zg Zd	ddZ	dd Z
edd ZdS )
r   a   An individual DNA residue

    Parameters
    ----------
    name : str
        The name of the residue
    abbr : str
        The abbreviation of the nucleic acid residue
    aliases : list of str, optional
        A list of other abbreviations that *also* refer to this residue
    Nc             C   s   || _ || _| t| j| < | t| j| < t| j|  |d k	rx<|D ]4}| }|t| jkrttd| | t| j|< qNW d S )Nz%s is already an abbreviation)	r0   r@   rB   r<   rC   r=   r3   rD   rE   )r(   r0   r@   rF   rG   r+   r+   r,   rH      s    
zDNAResidue.__init__c             C   s   d| j | jf S )Nz<DNA Residue %s: %s>)r0   r@   )r(   r+   r+   r,   rI      s    zDNAResidue.__repr__c             C   sT   y0|d dkr$| j |dd   S | j |  S  tk
rN   | j|  S X dS )a  
        Gets the nucleic acid corresponding to either the residue name or
        abbreviation. It is case-insensitive.

        Parameters
        ----------
        key : str
            abbreviation or residue name

        Returns
        -------
        residue : :class:`DNAResidue`
            The residue corresponding to the given key

        Raises
        ------
        KeyError if ``key`` is not a recognized residue name or abbreviation for
        an DNA residue.
        35N)r=   rC   r4   r<   )r-   r.   r+   r+   r,   r/      s    zDNAResidue.get)N)r7   r8   r9   r:   r;   r<   r=   r>   r3   rH   rI   r?   r/   r+   r+   r+   r,   r      s   
c               @   s:   e Zd ZdZe Ze Ze Zg Zdd Z	e
dd ZdS )r   a   An individual RNA residue

    Parameters
    ----------
    name : str
        The name of the residue
    abbr : str
        The abbreviation of the nucleic acid residue
    aliases : list of str, optional
        A list of other abbreviations that *also* refer to this residue
    c             C   s   d| j | jf S )Nz<RNA Residue %s: %s>)r0   r@   )r(   r+   r+   r,   rI      s    zRNAResidue.__repr__c             C   sT   y0|d dkr$| j |dd   S | j |  S  tk
rN   | j|  S X dS )a  
        Gets the nucleic acid corresponding to either the residue name or
        abbreviation. It is case-insensitive.

        Parameters
        ----------
        key : str
            abbreviation or residue name

        Returns
        -------
        residue : :class:`RNAResidue`
            The residue corresponding to the given key

        Raises
        ------
        KeyError if ``key`` is not a recognized residue name or abbreviation for
        an RNA residue.
        ra   rb   N)r=   rC   r4   r<   )r-   r.   r+   r+   r,   r/      s    zRNAResidue.getN)r7   r8   r9   r:   r;   r<   r=   r>   r3   rI   r?   r/   r+   r+   r+   r,   r      s   ZGuanineZGUAZDG5ZDG3ZDGNZCytosineZCYTZDC5ZDC3ZDCNZDCPZAdenineZADEZDA5ZDA3ZDANZDAPZThymineZTHYZDT5ZDT3ZG5ZG3ZGNZRGZRG3ZRG5ZRGNZCPZC5ZC3rN   ZRCZRC5ZRC3ZRCNZAPZA5ZA3ZANZRAZRA3ZRA5ZUracilZURAZU3ZU5ZUNZRUZRU3ZRU5ZRUNZT3ZT5ZTNZRTZRT3ZRT5ZRTNZWATZHOHZTIP3ZTIP4ZTIP5ZSPCEZSPCZSOLZEPZLPzNa+zLi+zMg+zRb+ZMGzCs+ZPOTZSODZMG2ZCALZRUBZLITZZN2ZCD2ZNAzK+zNA+zCl-zBr-zF-zI-ZCLAZCLZBRzCL-)+r:   __all__objectr&   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r   r]   ZWATER_NAMESr!   r"   r#   r$   r%   r+   r+   r+   r,   <module>   sf   
,N=0

