
     i                         d Z ddlZddlmZ ddlmZmZmZm	Z	m
Z
mZmZmZmZmZmZ ddlmZ ddlmZmZmZ  G d	 d
e          ZdS )a4  
PQR topology parser
===================

Read atoms with charges from a PQR_ file (as written by PDB2PQR_). No
connectivity is deduced.

Note
----
The file format is described in :mod:`MDAnalysis.coordinates.PQR`.


Classes
-------

.. autoclass:: PQRParser
   :members:
   :inherited-members:


.. _PQR:     https://apbs-pdb2pqr.readthedocs.io/en/latest/formats/pqr.html
.. _APBS:    https://apbs.readthedocs.io/en/latest/
.. _PDB2PQR: https://apbs-pdb2pqr.readthedocs.io/en/latest/pdb2pqr/index.html
.. _PDB:     http://www.wwpdb.org/documentation/file-format

    N   )openany)Atomids	Atomnames	AtomtypesChargesICodesRadiiRecordTypesResidsResnumsResnamesSegids)Topology   )TopologyReaderBase	squash_bychange_squashc                   2    e Zd ZdZdZed             Zd ZdS )	PQRParsera  Parse atom information from PQR file *filename*.

    Creates a MDAnalysis Topology with the following attributes
     - Atomids
     - Atomnames
     - Charges
     - Radii
     - RecordTypes (ATOM/HETATM)
     - Resids
     - Resnames
     - Segids

     .. note::

        Atomtypes will be read from the input file if they are present
        (e.g. GROMACS PQR files). Otherwise, they will be guessed on Universe
        creation. By default, masses will also be guessed on Universe creation.
        This may change in release 3.0.
        See :ref:`Guessers` for more information.


    .. versionchanged:: 0.9.0
       Read chainID from a PQR file and use it as segid (before we always used
       'SYSTEM' as the new segid).
    .. versionchanged:: 0.16.1
       Now reads insertion codes and splits into new residues around these
    .. versionchanged:: 0.18.0
       Added parsing of Record types
       Can now read PQR files from Gromacs, these provide atom type as last column
       but don't have segids
    .. versionchanged:: 2.8.0
        Removed type and mass guessing (attributes guessing takes place now
        through universe.guess_TopologyAttrs() API).

    PQRc                     |                                  }t          |          dk    r+	 t          |d                    d}n# t          $ r d}Y nw xY wd}|S )a0  Guess which variant of PQR format this line is

        Parameters
        ----------
        line : str
          entire line of PQR file starting with ATOM/HETATM

        Returns
        -------
        flavour : str
          ORIGINAL / GROMACS / NO_CHAINID

        .. versionadded:: 0.18.0
           ORIGINALGROMACS
NO_CHAINID)splitlenfloat
ValueError)linefieldsflavours      g/srv/www/vhosts/g4struct/public_html/venv/lib/python3.11/site-packages/MDAnalysis/topology/PQRParser.pyguess_flavourzPQRParser.guess_flavourm   st      v;;"%fRj!!! %  $ $ $#$
 #Gs   A AAc                 	   g }g }g }g }g }g }g }g }	g }
g }d}t          | j                  5 }|D ]}|                    d          s|                                }||                     |          }|dk    r|\  }}}}}}}}}}}nA|dk    r&|\  }}}}}}}}}}}d}|                    |           n|dk    r|\
  }}}}}}}}}}d}	 t          |          }d}n/# t          $ r" t          |dd                   }|d         }Y nw xY w|                    |           |                    |           |                    |           |                    |           |                    |           |                    |           |	                    |           |
                    |           |                    |           	 ddd           n# 1 swxY w Y   t          |          }g }|r%|} |                    t          | d	                     |                    t          t          j        |t          j        
                               |                    t          t          j        |t          
                               |                    t!          t          j        |	t          j        
                               |                    t%          t          j        |t          
                               |                    t'          t          j        |
t          j        
                               t          j        |t          j        
          }t          j        |t          
          }t          j        |t          
          }t          j        |t          
          }t)          ||||f||||f          \  }!\  }}}}t          |          }"|                    t+          |                     |                    t-          |                                                     |                    t1          |                     |                    t3          |                     t5          |          dd         \  }#}t          |          }$|                    t7          |                     t9          ||"|$||!|#          }%|%S )zParse atom information from PQR file *filename*.

        Returns
        -------
        A MDAnalysis Topology object
        N)ATOMHETATMr   r   SYSTEMr    r   F)dtyper   )attrsatom_resindexresidue_segindex)r   filename
startswithr   r&   appendintr!   r   r   r   nparrayint32r   objectr   float32r   r
   r   r   r   copyr   r	   r   r   r   )&selfkwargsrecord_typesserialsnamesresnameschainIDsresidsicodeschargesradiielementsr$   fr"   r#   
recordNameserialnameresNamechainIDresSeqxyzchargeradiuselementresidicoden_atomsr-   	atomtypesresidx
n_residuessegidx
n_segmentstops&                                         r%   parsezPQRParser.parse   s?    T]## G	)q F) F)'9:: ?"0066Gj(( "	)) "&GOOG,,,,,, "&GKKE EE " ' ' 'ss,,E"2JEEE' ##J///v&&&T"""(((e$$$e$$$v&&&V$$$((((MF)G	) G	) G	) G	) G	) G	) G	) G	) G	) G	) G	) G	) G	) G	) G	)R g,, 	6 ILL9e44555WRXgRX>>>??@@@YrxV<<<==>>>WRXgRZ@@@AABBB[,f!E!E!EFFGGGU28E<<<==>>>&111&///8HF3338HF3337DXvx0Xvx08
 8
4468
 [[
VF^^$$$WV[[]]++,,,Xh''(((VF^^$$$$X..rr2]]
VH%%&&& #
 
 
 
s7   BG	CG)DGDCGGGN)__name__
__module____qualname____doc__formatstaticmethodr&   r\        r%   r   r   F   sS        " "H F  \6H H H H Hrd   r   )r`   numpyr4   lib.utilr   core.topologyattrsr   r   r   r   r	   r
   r   r   r   r   r   core.topologyr   baser   r   r   r   rc   rd   r%   <module>rj      s"  0 4                                    % $ $ $ $ $ > > > > > > > > > >K K K K K" K K K K Krd   