o
    RÅ€g  ã                   @   s,   d Z ddlmZ dd„ Zdd„ Zdd„ Zd	S )
a  NOEtools: For predicting NOE coordinates from assignment data.

The input and output are modelled on nmrview peaklists.
This modules is suitable for directly generating an nmrview
peaklist with predicted crosspeaks directly from the
input assignment peaklist.
é   )Úxpktoolsc                 C   sä   d}t | jƒ}||d  d }||d  d }||d  d }	t|ƒ|  |¡v rpt|ƒ|  |¡v rp|  |¡t|ƒ }
|  |¡t|ƒ }|
d }|
D ]}t|
|	ƒ}t||ƒ}|d  ¡ | }qIt ||d |¡}t ||d |¡}|S )aS  Predict the i->j NOE position based on self peak (diagonal) assignments.

    Parameters
    ----------
    peaklist : xprtools.Peaklist
        List of peaks from which to derive predictions
    originNuc : str
        Name of originating nucleus.
    originResNum : int
        Index of originating residue.
    detectedNuc : str
        Name of detected nucleus.

    toResNum : int
        Index of detected residue.

    Returns
    -------
    returnLine : str
        The .xpk file entry for the predicted crosspeak.

    Examples
    --------
    Using predictNOE(peaklist,"N15","H1",10,12)
    where peaklist is of the type xpktools.peaklist
    would generate a .xpk file entry for a crosspeak
    that originated on N15 of residue 10 and ended up
    as magnetization detected on the H1 nucleus of
    residue 12


    Notes
    =====
    The initial peaklist is assumed to be diagonal (self peaks only)
    and currently there is no checking done to insure that this
    assumption holds true.  Check your peaklist for errors and
    off diagonal peaks before attempting to use predictNOE.

    Ú z.Lr   z.Pé    )Ú	_data_mapÚ
datalabelsÚstrÚresidue_dictÚ_col_aveÚsplitr   Úreplace_entry)ÚpeaklistÚ	originNucÚdetectedNucÚoriginResNumÚtoResNumÚ
returnLineÚdatamapÚoriginAssColÚoriginPPMColÚdetectedPPMColÚdetectedListÚ
originListÚlineÚaveDetectedPPMÚaveOriginPPMÚ	originAss© r   úD/var/www/html/myenv/lib/python3.10/site-packages/Bio/NMR/NOEtools.pyÚ
predictNOE   s"   (


r   c                 C   s   |   ¡ }dd„ t|ƒD ƒ}|S )Nc                 S   s   i | ]\}}||“qS r   r   )Ú.0ÚiÚlabelr   r   r   Ú
<dictcomp>Z   s    z_data_map.<locals>.<dictcomp>)r
   Ú	enumerate)Ú	labellineÚ	labelListr   r   r   r   r   T   s   r   c                 C   s.   d}| D ]}|t | ¡ | ƒ7 }q|t| ƒ S )Ng        )Úfloatr
   Úlen)ÚelementsÚcolÚtotalÚelementr   r   r   r	   _   s   r	   N)Ú__doc__r   r   r   r   r	   r   r   r   r   Ú<module>   s
   D