
     i                     ~    d Z ddlZddlmZmZ ddlmZmZ ddl	m
Z
 ddlmZmZmZmZmZmZmZ  G d	 d
e          ZdS )a  
CRD topology parser
===================

Read a list of atoms from a CHARMM CARD coordinate file (CRD_)
to build a basic topology.  Reads atom ids (ATOMNO), atom names (TYPES),
resids (RESID), residue numbers (RESNO), residue names (RESNames), segment ids
(SEGID) and tempfactor (Weighting).

Residues are detected through a change is either resid or resname
while segments are detected according to changes in segid.

.. note::

        By default, atomtypes and masses will be guessed on Universe creation.
        This may change in release 3.0.
        See :ref:`Guessers` for more information.

.. _CRD: https://www.charmmtutorial.org/index.php/CHARMM:The_Basics


Classes
-------

.. autoclass:: CRDParser
   :members:
   :inherited-members:

    N   )openanyFORTRANReader   )TopologyReaderBasechange_squash)Topology)Atomids	AtomnamesResidsResnamesResnumsSegidsTempfactorsc                       e Zd ZdZdZd ZdS )	CRDParseraH  Parse a CHARMM CARD coordinate file for topology information.

    Reads the following Attributes:
     - Atomids
     - Atomnames
     - Tempfactors
     - Resids
     - Resnames
     - Resnums
     - Segids


    .. note::

        By default, atomtypes and masses will be guessed on Universe creation.
        This may change in release 3.0.
        See :ref:`Guessers` for more information.

    .. versionchanged:: 2.8.0
       Type and mass are not longer guessed here. Until 3.0 these will still be
       set by default through through universe.guess_TopologyAttrs() API.
    CRDc                    t          d          }t          d          }g }g }g }g }g }g }	g }
t          | j                  5 }t          |          D ]\  }}|                                d         dk    r%|                                d         dk    r*t          |                                d                   r|}m|                                d         |                                d         k    r!|                                d         dk    r|}	 |                    |          \
  }}}}}}}}}}n;# t          $ r. d|dz    d	|                                 }t          |          d
w xY w|
                    |           |
                    |           |
                    |           |
                    |           |
                    |           |	
                    |           |

                    |           	 d
d
d
           n# 1 swxY w Y   t          j        |t          j                  }t          j        |t                    }t          j        |t          j                  }t          j        |t          j                  }t          j        |t                    }t          j        |	t          j                  }	t          j        |
t                    }
t!          ||f|||	|
f          \  }\  }}}}t!          |f|f          \  }\  } t#          t%          |          t%          |          t%          |           t'          |          t)          |          t+          |          t-          |          t/          |          t1          |          t3          |           g||          }!|!S )zCreate the Topology object

        Returns
        -------
        MDAnalysis Topology object

        Todo
        ----
        Could use the resnum and temp factor better
        z+2I10,2X,A8,2X,A8,3F20.10,2X,A8,2X,A8,F20.10z(2I5,1X,A4,1X,A4,3F10.5,1X,A4,1X,A4,F10.5r   *EXTzCheck CRD format at line r   z: N)dtype)attrsatom_resindexresidue_segindex)r   r   filename	enumeratesplitintread	Exceptionrstrip
ValueErrorappendnparrayint32objectfloat32r   r	   lenr
   r   r   r   r   r   r   )"selfkwargs	extformat	stdformatatomids	atomnamestempfactorsresidsresnamesresnumssegidscrdlinenumlinerserialresnumresNamenamexyzsegidresid
tempFactorerrmsgatom_residx
res_residsres_resnamesres_resnums
res_segids
res_segidx
seg_segidstops"                                     g/srv/www/vhosts/g4struct/public_html/venv/lib/python3.11/site-packages/MDAnalysis/topology/CRDParser.pyparsezCRDParser.parse_   s    "9
 
	 ""LMM		T]## )	%s!*3 (% (%::<<?c))ZZ\\"%..3tzz||A3G3G.!AJJLLOtzz||B'777

Q3..!A7 t"
  7 7 7+GaK + +;;==+ +  %V,,$67 v&&&  &&&"":...e$$$(((v&&&e$$$$Q(%)	% )	% )	% )	% )	% )	% )	% )	% )	% )	% )	% )	% )	% )	% )	%X (7"(333HYf555	h{"*===&1118HF333(7"(333&/// "VXw$G  	IHj,Z
 %2:-*$O$O!
MZLL
OO
OO  )$$K((z""&&$$z"" &'
 
 
" 
s,   CH D76H78E//BHHHN)__name__
__module____qualname____doc__formatrN        rM   r   r   E   s9         . Fd d d d drU   r   )rR   numpyr%   lib.utilr   r   baser   r   core.topologyr	   core.topologyattrsr
   r   r   r   r   r   r   r   rT   rU   rM   <module>r[      s   0 :     - - - - - - - - 3 3 3 3 3 3 3 3 $ $ $ $ $ $                 ~ ~ ~ ~ ~" ~ ~ ~ ~ ~rU   