o
    Rŀg                     @   s6   d Z G dd dZG dd deZG dd deZdS )z=Class that maps (chain_id, residue_id) to a residue property.c                   @   sH   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dS )AbstractPropertyMapz4Define base class, map holder of residue properties.c                 C   s   || _ || _|| _dS zInitialize the class.N)property_dictproperty_keysproperty_listselfr   r   r    r   O/var/www/html/myenv/lib/python3.10/site-packages/Bio/PDB/AbstractPropertyMap.py__init__   s   
zAbstractPropertyMap.__init__c                 C   s   |S )z#Return entity identifier (PRIVATE).r   )r   	entity_idr   r   r	   _translate_id   s   z!AbstractPropertyMap._translate_idc                 C   s   |  |}|| jv S )a|  Check if the mapping has a property for this residue.

        :param chain_id: chain id
        :type chain_id: char

        :param res_id: residue id
        :type res_id: char

        Examples
        --------
        This is an incomplete but illustrative example::

            if (chain_id, res_id) in apmap:
                res, prop = apmap[(chain_id, res_id)]

        r   r   )r   idtranslated_idr   r   r	   __contains__   s   

z AbstractPropertyMap.__contains__c                 C   s   |  |}| j| S )a  Return property for a residue.

        :param chain_id: chain id
        :type chain_id: char

        :param res_id: residue id
        :type res_id: int or (char, int, char)

        :return: some residue property
        :rtype: anything (can be a tuple)
        r   )r   keyr   r   r   r	   __getitem__,   s   

zAbstractPropertyMap.__getitem__c                 C   s
   t | jS )zReturn number of residues for which the property is available.

        :return: number of residues
        :rtype: int
        )lenr   r   r   r   r	   __len__;   s   
zAbstractPropertyMap.__len__c                 C   s   | j S )zReturn the list of residues.

        :return: list of residues for which the property was calculated
        :rtype: [(chain_id, res_id), (chain_id, res_id),...]
        )r   r   r   r   r	   keysC   s   zAbstractPropertyMap.keysc                 c   s&    t t| jD ]}| j| V  qdS )a  Iterate over the (entity, property) list.

        Handy alternative to the dictionary-like access.

        :return: iterator

        Examples
        --------
        >>> entity_property_list = [
        ...     ('entity_1', 'property_1'),
        ...     ('entity_2', 'property_2')
        ... ]
        >>> map = AbstractPropertyMap({}, [], entity_property_list)
        >>> for (res, property) in iter(map):
        ...     print(res, property)
        entity_1 property_1
        entity_2 property_2

        N)ranger   r   )r   ir   r   r	   __iter__K   s   zAbstractPropertyMap.__iter__N)__name__
__module____qualname____doc__r
   r   r   r   r   r   r   r   r   r   r	   r      s    r   c                   @       e Zd ZdZdd Zdd ZdS )AbstractResiduePropertyMapz(Define class for residue properties map.c                 C      t | ||| dS r   r   r
   r   r   r   r	   r
   f      z#AbstractResiduePropertyMap.__init__c                 C   s$   |\}}t |tr|d|dff}|S )z.Return entity identifier on residue (PRIVATE). )
isinstanceint)r   ent_idchain_idres_idr   r   r	   r   j   s   
z(AbstractResiduePropertyMap._translate_idNr   r   r   r   r
   r   r   r   r   r	   r   c       r   c                   @   r   )AbstractAtomPropertyMapz%Define class for atom properties map.c                 C   r    r   r!   r   r   r   r	   r
   u   r"   z AbstractAtomPropertyMap.__init__c                 C   sH   t |dkr|\}}}}n|\}}}d}t|tr"|d|df||f}|S )z,Return entity identifier on atoms (PRIVATE).   Nr#   )r   r$   r%   )r   r&   r'   r(   	atom_nameicoder   r   r	   r   y   s   

z%AbstractAtomPropertyMap._translate_idNr)   r   r   r   r	   r+   r   r*   r+   N)r   r   r   r+   r   r   r   r	   <module>   s   X