
     il                         d Z ddlmZ ddlmZ ddlmZ ddlmc m	c m
Z ddlmc m	c mZ ddlZ ej        d          ZddlZ G d	 d
ej                  ZdS )a  
TPR file format --- :mod:`MDAnalysis.coordinates.TPR`
======================================================

Class for reading positions and velocities from GROMACS TPR files.


Reading TPR files
-----------------
MDAnalysis can read positions and velocities from GROMACS TPR files,
and can also do so using different versions of the topology and
coordinate file for a given system.


For example, both of these are supported modes for reading
in positions and velocities from GROMACS TPR files::

   >>> u = mda.Universe(TPR2020, TPR2024_4)
   >>> u = mda.Universe(TPR2020)


Classes
-------

.. autoclass:: TPRReader
   :members:
   :inherited-members:

   )base   )util)Timestep    NzMDAnalysis.coordinates.TPRc                   *    e Zd ZdZdZdddZeZd ZdS )	TPRReaderzoClass supporting read in of positions and velocities from GROMACS TPR files.

    .. versionadded:: 2.10.0
    TPRnmznm/ps)lengthvelocityc                 t   t          j        | j        d          5 }|                                }d d d            n# 1 swxY w Y   t	          j        |          }	 t	          j        |          }nH# t          t          f$ r4 | j         d}t          
                    |           t          |          w xY w | j        |j        fi | j        x| _        }|j        | _        |j        t$          j        k    r|j        dk    rt+          |                                          |                                z
  }|d|j        z  k    r+d}t          
                    |           t          |          t          j                            |          }|j        }|j        rt	          j        ||j                   |dk    r5|j        dk     rt	          j        ||           t	          j        ||           t	          j        ||j        d	|j         
          }	|j!        rBtE          j#        t	          j$        ||j                  tD          j%                  | j        _&        |j'        rPtE          j#        t	          j$        ||j                  tD          j%                  | j        _(        d	| j        _)        d S d S )Nrb)modez5: Invalid tpr coordinate file or cannot be recognized      zHTPR files produced with beta versions of gromacs 2020 are not supported.r   E   T)tpr_resid_from_one	precision)dtype)*r   openanyfilenameread	tpr_utilsTPXUnpackerread_tpxheaderEOFError
ValueErrorloggercriticalIOError	_Timestepnatoms
_ts_kwargstsn_atomsfverStpxv_AddSizeFieldfgenlen
get_bufferget_positionsizeOfTprBodyTPXUnpacker2020from_unpackerngtcbBoxextract_box_infondo_realdo_mtopr   bXnpasarrayndo_rvecfloat32_posbV
velocitieshas_velocities)
selfinfiletprfdatathmsgr%   actual_body_size
state_ngtctpr_tops
             d/srv/www/vhosts/g4struct/public_html/venv/lib/python3.11/site-packages/MDAnalysis/coordinates/TPR.py_read_first_framezTPRReader._read_first_frameQ   s    \$-d333 	!v;;==D	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!$T**	)$//BB*% 	 	 	]YYYCOOC   #,,	
 &t~biCC4?CCC"y 7a)))bgmm"4??#4#4558I8I8K8KK1r'7#777)  $$$cll",::4@@DW
7 	6&tRW555>>w||"4444j   #"'dbl
 
 
 5 	:"4332:  DGL 5 	*!#"4332:" " "DG &*DG"""		* 	*s   =AAA2 2AB7N)	__name__
__module____qualname____doc__formatunitsr   r"   rI        rH   r	   r	   C   sF          F11EI5* 5* 5* 5* 5*rQ   r	   )rM    r   libr   timestepr   MDAnalysis.topology.tpr.utilstopologytprutilsr   MDAnalysis.topology.tpr.settingsettingr(   logging	getLoggerr   numpyr7   SingleFrameReaderBaser	   rP   rQ   rH   <module>r_      s   0 <                   1 1 1 1 1 1 1 1 1 1 1 1 + + + + + + + + + + + + 		7	8	8    C* C* C* C* C** C* C* C* C* C*rQ   