§
    Å ´iÿ  ã                   ó¤   — d Z g d¢ZddlZddlZddlmZmZm	Z	 ddl
mZmZ ddlmZ ddlmZ ddlZddlZ ej        d¦  «        Zdd„Zdd„Zd„ ZdS )a—  
Distance analysis --- :mod:`MDAnalysis.analysis.distances`
==========================================================

This module provides functions to rapidly compute distances between
atoms or groups of atoms.

:func:`dist` and :func:`between` can take atom groups that do not even
have to be from the same :class:`~MDAnalysis.core.universe.Universe`.

See Also
--------
:mod:`MDAnalysis.lib.distances`
)Údistance_arrayÚself_distance_arrayÚcontact_matrixÚdistÚbetweené    N)Úcapped_distancer   r   )Úcontact_matrix_no_pbcÚcontact_matrix_pbc)ÚAtomNeighborSearch)Ú
calc_bondszMDAnalysis.analysis.distancesç      .@Únumpyc                 óÀ  — |dk    rlt          j        t          | ¦  «        t          | ¦  «        fdt          ¬¦  «        }t	          | | ||d¬¦  «        }t          j        |¦  «        \  }}d|||f<   |S |dk    ret          j                             t          | ¦  «        t          | ¦  «        fd¬¦  «        }|t          | |||¦  «         nt          | ||¦  «         |S dS )	a  Calculates a matrix of contacts.

    There is a fast, high-memory-usage version for small systems
    (*returntype* = 'numpy'), and a slower, low-memory-usage version for
    larger systems (*returntype* = 'sparse').

    If *box* dimensions are passed then periodic boundary conditions
    are applied.

    Parameters
    ---------
    coord : array
       Array of coordinates of shape ``(N, 3)`` and dtype float32.
    cutoff : float, optional, default 15
       Particles within `cutoff` are considered to form a contact.
    returntype : string, optional, default "numpy"
       Select how the contact matrix is returned.
       * ``"numpy"``: return as an ``(N. N)`` :class:`numpy.ndarray`
       * ``"sparse"``: return as a :class:`scipy.sparse.lil_matrix`
    box : array-like or ``None``, optional, default ``None``
       Simulation cell dimensions in the form of
       :attr:`MDAnalysis.trajectory.timestep.Timestep.dimensions` when
       periodic boundary conditions should be taken into account for
       the calculation of contacts.

    Returns
    -------
    array or sparse matrix
       The contact matrix is returned in a format determined by the `returntype`
       keyword.

    See Also
    --------
    :mod:`MDAnalysis.analysis.contacts` for native contact analysis


    .. versionchanged:: 0.11.0
       Keyword *suppress_progmet* and *progress_meter_freq* were removed.
    r   F)Údtype)Ú
max_cutoffÚboxÚreturn_distancesTÚsparseÚboolN)ÚnpÚfullÚlenr   r   Ú	transposeÚscipyr   Ú
lil_matrixr
   r	   )	ÚcoordÚcutoffÚ
returntyper   ÚadjÚpairsÚidxÚidyÚsparse_contactss	            úg/srv/www/vhosts/g4struct/public_html/venv/lib/python3.11/site-packages/MDAnalysis/analysis/distances.pyr   r   G   sü   € ðR WÒÐÝŒg•s˜5‘z”z¥3 u¡:¤:Ð.°½TÐBÑBÔBˆÝØ5 V°Àuð
ñ 
ô 
ˆõ ”< Ñ&Ô&‰ˆˆSØˆˆCˆH‰àˆ
Ø	xÒ	Ð	õ  œ,×1Ò1Ý‰ZŒZ˜U™œÐ$¨Fð 2ñ 
ô 
ˆð ˆ?å˜u o°s¸FÑCÔCÐCÐCõ " %¨¸&ÑAÔAÐAØÐð 
 Ð	ó    c                 ó†  — | j         j        |j         j        k    rt          d¦  «        ‚	 |\  }}n(# t          t          f$ r t	          |¦  «        x}}Y nw xY wt          j        | j        ¦  «        |z   }t          j        |j        ¦  «        |z   }t          | j	        |j	        |¦  «        }t          j        |||g¦  «        S )a¬  Return distance between atoms in two atom groups.

    The distance is calculated atom-wise. The residue ids are also
    returned because a typical use case is to look at CA distances
    before and after an alignment. Using the `offset` keyword one can
    also add a constant offset to the resids which facilitates
    comparison with PDB numbering.

    Arguments
    ---------
    A, B : AtomGroup
       :class:`~MDAnalysis.core.groups.AtomGroup` with the
       same number of atoms
    offset : integer or tuple, optional, default 0
       An integer `offset` is added to *resids_A* and *resids_B* (see
       below) in order to produce PDB numbers.

       If `offset` is :class:`tuple` then ``offset[0]`` is added to
       *resids_A* and ``offset[1]`` to *resids_B*. Note that one can
       actually supply numpy arrays of the same length as the atom
       group so that an individual offset is added to each resid.

    Returns
    -------
    resids_A : array
        residue ids of the `A` group (possibly changed with `offset`)
    resids_B : array
       residue ids of the `B` group (possibly changed with `offset`)
    distances : array
       distances between the atoms
    z7AtomGroups A and B do not have the same number of atoms)
ÚatomsÚn_atomsÚ
ValueErrorÚ	TypeErrorÚintr   ÚarrayÚresidsr   Ú	positions)	ÚAÚBÚoffsetr   Úoff_AÚoff_BÚ
residues_AÚ
residues_BÚds	            r$   r   r   ‰   sÉ   € ðB 	„w„˜!œ'œ/Ò)Ð)ÝØEñ
ô 
ð 	
ð$Ø‰ˆˆuˆuøÝ•zÐ"ð $ð $ð $Ý˜F™œÐ#ˆð$øøøå”˜!œ(Ñ#Ô# eÑ+€JÝ”˜!œ(Ñ#Ô# eÑ+€Jå1”; ¤¨SÑ1Ô1€AÝŒ8Z ¨QÐ/Ñ0Ô0Ð0s   «1 ±"AÁAc                 ó¢   — t          | ¦  «        }|                     ||¦  «        }|                     ||¦  «        }|                     |¦  «        S )a’  Return sub group of `group` that is within `distance` of both `A` and `B`

    This function is not aware of periodic boundary conditions.

    Can be used to find bridging waters or molecules in an interface.

    Similar to "*group* and (AROUND *A* *distance* and AROUND *B* *distance*)".

    Parameters
    ----------
    group : AtomGroup
        Find members of `group` that are between `A` and `B`
    A : AtomGroup
    B : AtomGroup
        `A` and `B` are the groups of atoms between which atoms in
        `group` are searched for.  The function works is more
        efficient if `group` is bigger than either `A` or `B`.
    distance : float
        maximum distance for an atom to be counted as in the vicinity of
        `A` or `B`

    Returns
    -------
    AtomGroup
        :class:`~MDAnalysis.core.groups.AtomGroup` of atoms that
        fulfill the criterion


    .. versionadded: 0.7.5

    )r   ÚsearchÚintersection)Úgroupr/   r0   ÚdistanceÚns_groupÚresAÚresBs          r$   r   r   ¹   sL   € õ@ " %Ñ(Ô(€HØ?Š?˜1˜hÑ'Ô'€DØ?Š?˜1˜hÑ'Ô'€DØ×Ò˜TÑ"Ô"Ð"r%   )r   r   N)r   N)Ú__doc__Ú__all__r   r   Úscipy.sparser   ÚMDAnalysis.lib.distancesr   r   r   ÚMDAnalysis.lib.c_distancesr	   r
   ÚMDAnalysis.lib.NeighborSearchr   r   ÚwarningsÚloggingÚ	getLoggerÚloggerr   r   r   © r%   r$   ú<module>rJ      s$  ðð4ð ðð ð €ð Ð Ð Ð Ø Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð
ð ð ð ð ð ð ð ð =Ð <Ð <Ð <Ð <Ð <Ø /Ð /Ð /Ð /Ð /Ð /ð €€€Ø €€€à	ˆÔ	Ð:Ñ	;Ô	;€ð?ð ?ð ?ð ?ðD-1ð -1ð -1ð -1ð`##ð ##ð ##ð ##ð ##r%   