
     iQ                         d Z ddlmZmZ ddlmZ ddlZddlZddl	m
Z
 ddlZ ej        d          Z G d d	e          Z G d
 de          ZddZdS )a8  
Base guesser classes --- :mod:`MDAnalysis.guesser.base`
================================================================

Derive context-specific guesser classes from the base class in this module.

Classes
-------

.. autoclass:: GuesserBase
   :members:
   :inherited-members:

.. autofunction:: get_guesser

   )	_GUESSERS_TOPOLOGY_ATTRS)_Connection    N)DictzMDAnalysis.guesser.basec                       e Zd ZdZd ZdS )_GuesserMetaa  Internal: guesser classes registration

    When classes which inherit from GuesserBase are *defined*
    this metaclass makes it known to MDAnalysis.  'context'
    attribute  are read:
     - `context` defines the context of the guesser class for example:
       forcefield specific context  as MartiniGuesser
       and file specific context as PDBGuesser.

    Eg::

      class FooGuesser(GuesserBase):
          format = 'foo'

    .. versionadded:: 2.8.0
    c                     t                               t           |||           | t          |d                                         <   d S )Ncontext)type__init__r   upper)clsnamebases	classdicts       a/srv/www/vhosts/g4struct/public_html/venv/lib/python3.11/site-packages/MDAnalysis/guesser/base.pyr   z_GuesserMeta.__init__C   s;    dD%33325	)I&,,..///    N)__name__
__module____qualname____doc__r    r   r   r	   r	   1   s-         "6 6 6 6 6r   r	   c                   H    e Zd ZU dZdZi Zeed<   ddZd Z	d Z
d Zdd
ZdS )GuesserBaseaA  Base class for context-specific guessers to inherit from

    Parameters
    ----------
    universe : Universe, optional
        Supply a Universe to the Guesser. This then becomes the source of atom
        attributes to be used in guessing processes. (this is relevant to how
        the universe's guess_TopologyAttrs API works.
        See :meth:`~MDAnalysis.core.universe.Universe.guess_TopologyAttrs`).
    **kwargs : dict, optional
        To pass additional data to the guesser that can be used with
              different methods.


    .. versionadded:: 2.8.0

    base_guesser_methodsNc                 "    || _         || _        d S N)	_universe_kwargs)selfuniversekwargss      r   r   zGuesserBase.__init___   s    !r   c                 :    | j                             |           d S r   )r!   update)r"   r$   s     r   update_kwargszGuesserBase.update_kwargsc   s    F#####r   c                 V    t          j        | j                  } | j        dddi|}|S )zReturn a copy of this Guesserr#   Nr   )copydeepcopyr!   	__class__)r"   r$   news      r   r)   zGuesserBase.copyf   s4    t|,,dn55d5f55
r   c                 @    |                                 | j        v rdS dS )zcheck if the passed atrribute can be guessed by the guesser class

        Parameters
        ----------
        guess: str
            Attribute to be guessed then added to the Universe

        Returns
        -------
        bool
        TF)lowerr   )r"   attr_to_guesss     r   is_guessablezGuesserBase.is_guessablel   s(       D$9994ur   Fc                    	 t           |         }n # t          $ r t          | d          w xY w|j        }	 | j        |         }n4# t          $ r' t	          t          |           j         d|           w xY wt          |t                    r
 |            S t          | j
        j        |          r||szt          j        t          | j
        j        |d                    }|                    |          }d|v r ||          ||<   |S t                               d| d| d           dS t          j         |                      S )	a  map the attribute to be guessed with the apporpiate guessing method

        Parameters
        ----------
        attr_to_guess: str
            an atrribute to be guessed then to be added to the universe
        force_guess: bool
            To indicate wether to only partialy guess the empty values of the
            attribute or to overwrite all existing values by guessed one

        Returns
        -------
        NDArray of guessed values

        z2 is not a recognized MDAnalysis topology attributez cannot guess this attribute: NT)indices_to_guesszThere is no empty z2 values. Guesser did not guess any new values for z
 attribute)r   KeyErrorattrnamer   
ValueErrorr   r   
issubclassr   hasattrr    atomsnparraygetattrare_values_missingloggerinfo)r"   r/   force_guesstop_attrguesser_methodattr_valuesempty_valuess          r   
guess_attrzGuesserBase.guess_attr}   s    	&}5HH 	 	 	  % % %  	 !)	!2=ANN 	 	 	::& . .+. .  	 h,, 	$!>### 4>'77 	. 	.(,mTBB K $66{CCL|## -;N%1- - -L) #" N N N4AN N N   t8NN,,---s    -A 1A7r   )F)r   r   r   r   r   r   r   __annotations__r   r'   r)   r0   rD   r   r   r   r   r   I   s          $ Gd   $ $ $    "?. ?. ?. ?. ?. ?.r   r   )	metaclassc                 j   t          | t                    r|| _         | j        di | | S 	 t	          | t                    r	 | |fi |S n# t
          $ r Y nw xY w	 t          |                                          |fi |}n0# t          $ r# t          d	                    |                     w xY w|S )a  get an appropiate guesser to the Universe and pass
       the Universe to the guesser

    Parameters
    ----------
    u: Universe
        to be passed to the guesser
    context: str or Guesser
    **kwargs : dict, optional
        Extra arguments are passed to the guesser.

    Returns
    -------
    Guesser class

    Raises
    ------
    * :exc:`KeyError` upon failing to return a guesser class

    .. versionadded:: 2.8.0

    zUnidentified guesser type {0}r   )

isinstancer   r    r'   r6   	TypeErrorr   r   r3   format)r   ur$   guessers       r   get_guesserrM      s    . ';'' '''''g{++ 	(71'''''	(   HGMMOO,Q99&99 H H H6==gFFGGGHNs   A 
AA%B -B0r   )r    r   r   core.topologyattrsr   numpyr9   loggingtypingr   r)   	getLoggerr=   r   r	   r   rM   r   r   r   <module>rT      s   .   * ) ) ) ) ) ) ) , , , , , ,            		4	5	56 6 6 6 64 6 6 60s. s. s. s. s.L s. s. s. s.l% % % % % %r   