
     i[d                     2   d Z ddlmZ ddlZddlZddlZddlZddlm	Z	 ddl
mZ ddlmZ dd	lmZmZ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mZmZm Z m!Z!m"Z"m#Z# ddl$m%Z%  G d de"          Z& G d d          Z' G d d          Z( G d de          Z)dS )a4  
ITP topology parser
===================

Reads a GROMACS ITP_ or TOP_ file to build the system. The topology will
contain atom IDs, segids, residue IDs, residue names, atom names, atom types,
charges, chargegroups, masses, moltypes, and molnums.
Any masses that are in the file will be read; any missing values will be guessed.
Bonds, angles, dihedrals and impropers are also read from the file.

If an ITP file is passed without a ``[ molecules ]`` directive, passing 
``infer_system=True`` (the default option) will create a Universe with 
1 molecule of each defined ``moleculetype``. 
If a ``[ molecules ]`` section is present, ``infer_system`` is ignored.

If files are included with the `#include` directive, they will also be read.
If they are not in the working directory, ITPParser will look for them in the
``include_dir`` directory. By default, this is set to
``include_dir="/usr/local/gromacs/share/gromacs/top/"``.
Variables can be defined with the `#define` directive in files, or by passing
in :ref:`keyword arguments <itp-define-kwargs>`.

Examples
--------

.. code-block:: python

    import MDAnalysis as mda
    from MDAnalysis.tests.datafiles import ITP_tip5p

    #  override charge of HW2 atom (defined in file as HW2_CHARGE)
    u = mda.Universe(ITP_tip5p, HW2_CHARGE=2, infer_system=True)

.. note::

    AMBER also uses topology files with the .top extension. To use ITPParser
    to read GROMACS top files, pass ``topology_format='ITP'``.

    ::

        import MDAnalysis as mda
        u = mda.Universe('topol.top', topology_format='ITP')


.. _itp-define-kwargs:

Preprocessor variables
----------------------

ITP files are often defined with lines that depend on 
whether a keyword flag is given. For example, this modified TIP5P water file:

.. code-block:: none

    [ moleculetype ]
    ; molname       nrexcl
    SOL             2

    #ifndef HW1_CHARGE
        #define HW1_CHARGE 0.241
    #endif

    #define HW2_CHARGE 0.241

    [ atoms ]
    ; id    at type res nr  residu name     at name         cg nr   charge
    1       opls_118     1       SOL              OW             1       0
    2       opls_119     1       SOL             HW1             1       HW1_CHARGE
    3       opls_119     1       SOL             HW2             1       HW2_CHARGE
    4       opls_120     1       SOL             LP1             1      -0.241
    5       opls_120     1       SOL             LP2             1      -0.241
    #ifdef EXTRA_ATOMS  ; added for keyword tests
    6       opls_120     1       SOL             LP3             1      -0.241
    7       opls_120     1       SOL             LP4             1       0.241
    #endif


Define these preprocessor variables by passing keyword arguments. Any arguments that you 
pass in *override* any variables defined in the file. For example, the universe below 
will have charges of 3 for the HW1 and HW2 atoms::

    import MDAnalysis as mda
    from MDAnalysis.tests.datafiles import ITP_tip5p

    u = mda.Universe(ITP_tip5p, EXTRA_ATOMS=True, HW1_CHARGE=3, HW2_CHARGE=3)

These keyword variables are **case-sensitive**. Note that if you set keywords to
``False`` or ``None``, they will be treated as if they are not defined in #ifdef conditions.

For example, the universe below will only have 5 atoms. ::

    u = mda.Universe(ITP_tip5p, EXTRA_ATOMS=False)


.. _ITP: http://manual.gromacs.org/current/reference-manual/topologies/topology-file-formats.html#molecule-itp-file

.. _TOP: http://manual.gromacs.org/current/reference-manual/file-formats.html#top

Classes
-------

.. autoclass:: ITPParser
   :members:
   :inherited-members:

    )defaultdictN   )openany)SYMB2Z)DefaultGuesser   )TopologyReaderBasechange_squashreduce_singular)Atomids	Atomnames	AtomtypesMassesMoltypesMolnumsChargesResidsResnumsResnamesSegidsBondsAngles	Dihedrals	ImpropersAtomAttrElements)Topologyc                       e Zd ZdZdZdZdS )ChargegroupszThe charge group for each AtomchargegroupschargegroupN)__name__
__module____qualname____doc__attrnamesingular     g/srv/www/vhosts/g4struct/public_html/venv/lib/python3.11/site-packages/MDAnalysis/topology/ITPParser.pyr   r      s        ((HHHHr)   r   c                   d    e Zd ZdZd Zed             Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd ZdS )GmxTopIteratora  
    Iterate over the lines of a TOP/ITP file and its included files

    The iterator strips comments, deals with #ifdef and #ifndef conditions,
    and substitutes defined variables.

    Defined variables passed into ``__init__`` *override* anything defined in the file.
    c                 b    || _         t          di || _        || _        |g| _        || _        d S )Nr(   )_original_definesdictdefinesinclude_dir
file_stackstarting_file)selfpathr1   r0   s       r*   __init__zGmxTopIterator.__init__   s:    !(g&&!r)   c                     | j         d         S )N)r2   r4   s    r*   current_filezGmxTopIterator.current_file   s    r""r)   c              #   L   K   |                      | j                  D ]}|V  d S N)iter_from_filer3   r4   lines     r*   __iter__zGmxTopIterator.__iter__   s;      ''(:;; 	 	DJJJJ	 	r)   c              #   0  K   |                      |          }t          |          5 }| j                            |           |                     |          D ]}|                    d          rA|                    d d          d         dd         }|                     |          D ]}|V  Y|                    d          r|                     |           |                    d          r| 	                    ||           |                    d          r| 
                    |           |                    d          r|r|                     |          }|V  | j                                         d d d            d S # 1 swxY w Y   d S )Nz#includer   r8   z#define#if#else#)	find_pathr   r2   appendclean_file_lines
startswithsplitr=   definedo_ifskip_until_endifsubstitute_definedpop)r4   r5   
found_pathinfiler?   incs         r*   r=   zGmxTopIterator.iter_from_file   s     ^^D))
Z   	"FO""6***--f55  ??:.. **T1--a026C $ 3 3C 8 8 # #"



#__Y// 
KK%%%%__U++ JJtV,,,,__W-- ))&1111__S))  22488DJJJO!!!'	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s   EFFFc                     	 |                     d d          \  }}}n)# t          $ r |                                 \  }}d}Y nw xY w|| j        vr|| j        |<   d S d S )Nr   T)rI   
ValueErrorr.   r0   )r4   r?   _variablevalues        r*   rJ   zGmxTopIterator.define   s    	!%D!!4!4Ax 	 	 	**,,KAxEEE	
 4111%*DL""" 21s    #AAc                     |                                 }| j                                        D ].\  }}||v r%t          |          ||                    |          <   /d                    |          }|S )N )rI   r0   itemsstrindexjoin)r4   r?   rI   kvs        r*   rM   z!GmxTopIterator.substitute_defined   sh    

L&&(( 	/ 	/DAqEzz(+Aekk!nn%xxr)   c              #   v   K   |D ]3}|                     d          d                                         }|V  4d S )N;r   )rI   stripr4   rP   r?   s      r*   rG   zGmxTopIterator.clean_file_lines   sJ       	 	D::c??1%++--DJJJJ	 	r)   c                     |                                 \  }}|dk    r5| j                            |          dv r|                     |           d S d S |dk    r3| j                            |          dvr|                     |           d S d S d S )Nz#ifdef)FNz#ifndef)rI   r0   getskip_until_else)r4   r?   rP   ifdefrU   s        r*   rK   zGmxTopIterator.do_if   s    **,,xH|))]::$$V,,,,, ;:i|))>>$$V,,,,,  >>r)   c                 0   |                      |          D ]Z}|                    d          r|                     |           -|                    d          s|                    d          r dS [t          d                    | j                            )z#Skip lines until #if condition endsrB   #endifrC   Missing #endif in {}NrG   rH   rL   IOErrorformatr:   rb   s      r*   re   zGmxTopIterator.skip_until_else   s    ))&11 	L 	LDu%% %%f----** doog.F.F  0778IJJKKKr)   c                    |                      |          D ]E}|                    d          r|                     |           -|                    d          r dS Ft          d                    | j                            )zSkip lines until #endifrB   rh   ri   Nrj   rb   s      r*   rL   zGmxTopIterator.skip_until_endif  s    ))&11 	L 	LDu%% %%f----**  0778IJJKKKr)   c                 H   	 | j         j        }n# t          $ r
 | j         }Y nw xY w	 t          j                            |j                  }n# t          $ r Y nw xY wt          j                            |          }t          j                            ||          }t          j                            |          r|S t          j                            | j	        |          }t          j                            |          r|S t          d                    |                    )NzCould not find {})r:   nameAttributeErrorosr5   abspathdirnamer\   existsr1   rk   rl   )r4   r5   r:   current_dirdir_pathinclude_paths         r*   rE   zGmxTopIterator.find_path  s   	-,1LL 	- 	- 	-,LLL	-	7??49--DD 	 	 	D	gool337<<T227>>(## 	Ow||D$4d;;7>>,'' 	 )0066777s    ##$A 
AAN)r"   r#   r$   r%   r6   propertyr:   r@   r=   rJ   rM   rG   rK   re   rL   rE   r(   r)   r*   r,   r,      s         " " " # # X#  " " ".	+ 	+ 	+    
- - -L L LL L L8 8 8 8 8r)   r,   c                       e Zd ZdZd Zed             Zed             Zd Zd Z	d Z
d Zd	 Zd
 Zd Z	 ddZddZd ZdS )Moleculez&Store moleculetype-specific attributesc                    || _         g | _        g | _        g | _        g | _        g | _        g | _        g | _        g | _        t          t                    | _        t          t                    | _        t          t                    | _        t          t                    | _        | j        | j        | j        | j        | j        | j        d| _        d| _        d S )N)atomsbondsangles	dihedralsconstraintssettlesF)ro   idstypesresidsresnamesnamesr    chargesmassesr   listr}   r~   r   	impropersparse_atomsparse_bondsparse_anglesparse_dihedralsparse_constraintsparse_settlesparsersresolved_residue_attrs)r4   ro   s     r*   r6   zMolecule.__init__'  s    	

 &&
!$''$T**$T** %%'-1)
 
 ',###r)   c                 f    | j         | j        | j        | j        | j        | j        | j        | j        gS r<   )r   r   r   r   r   r    r   r   r9   s    r*   
atom_orderzMolecule.atom_orderB  s7     HJKMJLK	
 		
r)   c                 6    | j         | j        | j        | j        gS r<   )r}   r~   r   r   r9   s    r*   paramszMolecule.paramsO  s    
DKHHr)   c                     |                                 }| j        D ]P}	 |                    |                    d                     ,# t          $ r |                    d           Y Mw xY wd S )Nr    )rI   r   rF   rN   
IndexError)r4   r?   valueslsts       r*   r   zMolecule.parse_atomsS  s|    ? 	 	C

6::a==))))   

2	 	s   (AA*)A*c                 B    |                      || j        dd           d S )Nr   )
r   r                     	   
   n_functfunct_values	add_paramr}   r>   s     r*   r   zMolecule.parse_bonds[  s5    J8	 	 	
 	
 	
 	
 	
r)   c                 B    |                      || j        dd           d S )Nr   )r   r   r   r   r   r   r   r   r   )r   r~   r>   s     r*   r   zMolecule.parse_anglesc  s5    K2	 	 	
 	
 	
 	
 	
r)   c                     |                      || j        dd          }|s |                      || j        dd           d S d S )Nr   )r   r   r   r   r   r      r   )r   r   )r   r   r   )r4   r?   dihs      r*   r   zMolecule.parse_dihedralsk  sl    nnN0	  
 
  	NNdnaf      	 	r)   c                 B    |                      || j        dd           d S )Nr   )r   r   r   r   r>   s     r*   r   zMolecule.parse_constraintsw  s$    tTZHHHHHr)   c                 (   |                                 \  }}}}	 |                     |g          d         }| j        ||dz   f                             d           | j        ||dz   f                             d           d S # t          $ r Y d S w xY w)Nr   r   r   r   )rI   	index_idsr}   rF   rS   )r4   r?   oxygenfunctdohdhhbases          r*   r   zMolecule.parse_settlesz  s     #'**,,sC	;>>6(++A.D JdQh'(//	:::JdQh'(//	:::::	  	 	 	DD	s   B 
BBc                    t          j        | j        t           j                  }t          j        | j        t
                    }t          |f||f          \  | _        \  | _        }t          |          | _        | j	        gt          | j                  z  | _        t          j        dgt          | j                  z            | _        d| _        dS )z:Figure out residue borders and assign moltypes and molnumsdtyper   TN)nparrayr   int32r   objectr
   residxr   ro   lenmoltypesmolnumsr   )r4   r   r   s      r*   resolve_residue_attrszMolecule.resolve_residue_attrs  s    $+RX6668DM888/<I)0
 0
,,dk8 Xc$+&6&66xc$+&6&6 677&*###r)   r   c           	         | j         s|                                  t          t          j        | j                  |z             }t          t          j        | j                  |z             }t          t          j        | j                  |z             }	t          t          j        | j        t                    |z             }
	 t          j        | j
        t                    }n:# t          $ r- t          j        dt          | j
                  dz             }Y nw xY wt          ||z             }|
| j        || j        | j        || j        | j        g}g }| j        D ]Z}i }|                                D ],\  }}||t+          t          j        |          |z             <   -|                    |           [|||	| j        |fS )a  
        Get attributes ready for adding onto a larger topology.

        Shifts atom indices, residue indices, molnums, and chargegroup numbers.

        Returns
        -------
        atom_attrs: list of lists
            attributes in the [ atoms ] section

        new_params: list of dicts
            Bonds, angles, dihedrals, impropers as dicts of shape {indices: parameters}

        molnums: list
        moltypes: list
        residx: list
        r   r   )r   r   r   r   r   r   r   r   r   intr    rS   aranger   r   r   r   r   r   r   rY   tuplerF   r   )r4   atomidresidmolnumcgnrn_resn_atomsr   r   r   r   cgr    r   
new_paramspnewindicesr   s                      r*   shift_indiceszMolecule.shift_indices  s   ( * 	)&&(((bht{++e344bht{++e344rx--67728DHC00069::	:$+3777BB 	: 	: 	:1c$"344q899BBB	:BI JMJLK	

 
 	# 	#AC#$7799 A A:@E"(7++g56677c"""":wvEEs    C) )4D D r   Nc                     |g }|                                 }t          ||                   }||v rL	 |                     |d|                   }||                             |           n# t          $ r Y nw xY wdS dS )zMAdd defined GROMACS directive lines, only if the funct is in ``funct_values``NTF)rI   r   r   rF   rS   )r4   r?   	containerr   r   r   r   r   s           r*   r   zMolecule.add_param  s    LF7O$$L  nnVHWH%566#%%e,,,,   45s   8A, ,
A98A9c                 P    t          t          | j        j        |                    S )z;
        Get indices of atom ids (list of strings)
        )r   mapr   r[   )r4   r   s     r*   r   zMolecule.index_ids  s      S00111r)   )r   r   r   r   r   r   )r   N)r"   r#   r$   r%   r6   rx   r   r   r   r   r   r   r   r   r   r   r   r   r(   r)   r*   rz   rz   $  s       00, , ,6 

 

 X

 I I XI  
 
 

 
 

 
 
I I I; ; ;&+ + + EF4F 4F 4F 4Fl    2 2 2 2 2r)   rz   c                   @    e Zd ZdZdZ	 	 ddZd Zd Zd Zd	 Z	d
 Z
dS )	ITPParsera`  Read topology information from a GROMACS ITP_ or TOP_ file.

    Creates a Topology with the following Attributes:
    - ids
    - names
    - types
    - masses
    - charges
    - chargegroups
    - resids
    - resnames
    - segids
    - moltypes
    - molnums
    - bonds
    - angles
    - dihedrals
    - impropers

    .. _ITP: http://manual.gromacs.org/current/reference-manual/topologies/topology-file-formats.html#molecule-itp-file
    .. _TOP: http://manual.gromacs.org/current/reference-manual/file-formats.html#top

    .. note::

        By default, atomtypes and masses will be guessed on Universe creation
        if they are not read from the input file.
        This may change in release 3.0.
        See :ref:`Guessers` for more information.

    .. versionchanged:: 2.2.0
      no longer adds angles for water molecules with SETTLE constraint
    .. versionchanged:: 2.8.0
      Removed mass guessing (attributes guessing takes place now
      through universe.guess_TopologyAttrs() API).
      Added guessed elements if all elements are valid to preserve partial
      mass guessing behavior

    ITP%/usr/local/gromacs/share/gromacs/top/Tc           	          i  _         i  _        g  _        d _         j         _        g  _        t           j                  5 }t          |||           _
         j
        D ]}d|v rd|v r|                    d          d                             d          d                                         }|dk    r j         _        c|dk    r j         _        v|dk    r j         _         j        r+ j        j                            | j                   _         j         _        ȉ                     |           	 ddd           n# 1 swxY w Y    j        s|rd	  j        D              _                                          t'          j         j                   _        t'          j         j        t.          
           _        t'          j         j        t.          
           _        t3           j                  s, j        dk    } fd j        |         D              j        |<   t3           j                  s, j        dk    } fd j        |         D              j        |<   g } j        t6          t&          j        f j        t:          t.          f j        t>          t.          f j         tB          t&          j        f j        tD          t&          j#        ffD ]G\  }	}
}t3          |	          r2|$                     |
t'          j        |	|
                               Ht3           j                  s j        dk    }tJ          j&         j        |<   |$                    tK          t'          j         j        t&          j'        
          d                     tQ          d          )                     j                   _*        t3          d  j*        D                       r]|$                    tW          t'          j         j*        t.          
          d                     tY          j-        dt\                     ntY          j-        d           t'          j         j/        t&          j        
          }t'          j         j0        t.          
          }t'          j         j1        t&          j        
          }|$                    te          |                     |$                    tg          |4                                                     |$                    tk          |                     |$                    tm          t'          j         j7        t.          
                               |$                    tq          |                     ts           j                  }ts           j/                  }ts           j                  }|$                    tu          t'          j         j        t.          
                               |dz
  }tw          |||| j<        |          } j=        t|          df j?        t          df jA        t          df jC        t          dffD ]f\  }}
}|r,t          t          |G                                           \  }}ng g }}d |D             } |
||          }|H                    |           g|S )a  Parse ITP file into Topology

        Parameters
        ----------
        include_dir: str, optional
            A directory in which to look for other files included
            from the original file, if the files are not first found
            in the current directory.
            Default: "/usr/local/gromacs/share/gromacs/top/"

        infer_system: bool, optional (default True)
            If a ``[ molecules ]`` directive is not found within the the
            topology file, create a Topology with one of every
            ``[ moleculetype ]`` defined. If a ``[ molecules ]`` directive is
            found, this keyword is ignored.

        Returns
        -------
        MDAnalysis *Topology* object
        N[]r   r   	atomtypesmoleculetype	moleculesc                     g | ]	}|j         
S r(   )ro   ).0xs     r*   
<listcomp>z#ITPParser.parse.<locals>.<listcomp>O  s    $E$E$EQV$E$E$Er)   r   r   c                     g | ]?}|j                                         v r j                             |          d          nd@S )charger   r   keysrd   r   r   r4   s     r*   r   z#ITPParser.parse.<locals>.<listcomp>Y  sa     # # #  DN//1111 N&&q))(33	# # #r)   c                     g | ]?}|j                                         v r j                             |          d          nd@S )massr   r   r   s     r*   r   z#ITPParser.parse.<locals>.<listcomp>d  sa     " " "  DN//1111 N&&q))&11	" " "r)   F)guessedc              3   L   K   | ]}|                                 t          v V   d S r<   )
capitalizer   )r   es     r*   	<genexpr>z"ITPParser.parse.<locals>.<genexpr>  s/      ??Aq||~~'??????r)   Ta  The elements attribute has been populated by guessing elements from atom types. This behaviour has been temporarily added to the ITPParser as we transition to the new guessing API. This behavior will be removed in release 3.0. Please see issue #4698 for more information. zElement information is missing, elements attribute will not be populated. If needed these can be guessed using universe.guess_TopologyAttrs(to_guess=['elements']).)attrsatom_resindexresidue_segindexr}   r~   r   r   c                 ,    g | ]}t          |          S r(   )r   )r   ts     r*   r   z#ITPParser.parse.<locals>.<listcomp>  s     777A_Q''777r)   )r   )Ir   r   
_moleculescurrent_mol_passparsersystem_moleculesr   filenamer,   linesrI   ra   parse_atomtypesparse_moleculetypeparse_moleculesr   rd   build_systemr   r   r   r   r   r   allr   r   r   r   r   r   r    r   r   float32rF   r   missing_value_labelfloat64r   guess_typeselementsr   warningswarnDeprecationWarningr   r   r   r   r   copyr   r   r   r   r   r   r   r   r}   r   r~   r   r   r   r   r   zipr   rY   add_TopologyAttr)r4   r1   infer_systemkwargsitpfiler?   sectionemptyr   valsAttrr   r   r   r   r   
n_residues
n_segmentssegidxtopdctr&   r   r   tattrs   `                        r*   parsezITPParser.parse  s   6 j " T]## 	&w'fEEDJ
 & &$;;3$;;"jjooa066s;;A>DDFFG+--&*&: N22&*&= K//&*&:) 1&*&6&>&B&B#TZ' '
 '+j KK%%%%-&	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&4 $ 	F 	F$E$ET_$E$E$ED!Xdj))
xF;;;ht{&9994<   		LB&E# # # # E*# # #DL 4; 		K2%E" " " " E*" " "DK  Xw)ZF+ZF+bh7\7BJ/"
 	@ 	@D$ 4yy @TT"(4u"="="=>>???4; 	<K2%E!'!;DK28DKrz:::EJJJ	
 	
 	
 't,,88DD??????? 	LL$-v>>>MMM   M@ #    M*   $+RX6668DM888(4<rx888VF^^$$$WV[[]]++,,,Xh''(((Xbht}FCCCDDEEEWW%%&&&dh--%%
.//
VBHT%:&IIIJJKKK1+#
 
 
 Z([&(+^Y4^Y4	$
 	( 	(Cx  (!$d399;;&7&7!8!#R77777ED...E  ''''
s   C<EEEc                     d S r<   r(   r>   s     r*   r   zITPParser._pass  s    r)   c                    g d}|                                 }t          |d                   dk    r%|d                                         r|dd         }nt          |d                   dk    r4|d                                         rdd|d         |d         |d         f}nt          |d                   dk    ry|d                                         r_|d         d	                                         r |d         d|d         |d         |d         f}nd|d         |d         |d         |d         f}t          t	          ||                    | j        |d	         <   d S )
N)type_bondedatomic_numberr   r   p_typer   r   r   r   r   r   r   r   )rI   r   isalphar/   r
  r   )r4   r?   r   fieldsr   s        r*   r   zITPParser.parse_atomtypes  sL   KKKvay>>Q6!9#4#4#6#6AaC[FF^^q  VAY%6%6%8%8 VAYq	6!9<FF^^q  VAY%6%6%8%8 ay|##%% HBq	6!9fQiGVAYq	6!9fQiG$(T6):):$;$;vay!!!r)   c                     |                                 d         }t          |          x| _        | j        |<   | j                            | j                   d S )Nr   )rI   rz   r   r   r   rF   )r4   r?   ro   s      r*   r   zITPParser.parse_moleculetype  sL    zz||A2:4..@4>$/t/00000r)   c                     |                                 \  }}| j                            |gt          |          z             d S r<   )rI   r   extendr   )r4   r?   ro   n_mols       r*   r   zITPParser.parse_molecules  s=    jjlle$$dVc%jj%899999r)   c           	         g | _         g | _        g | _        g | _        g | _        g | _        g | _        g | _        g | _        g | _	        g | _
        | j         | j        | j        | j        | j        | j        | j        | j        g| _        t          t                    | _        t          t                    | _        t          t                    | _        t          t                    | _        | j        | j        | j        | j        g| _        t'          | j                  D ]N\  }}| j        |         }| j         r| j         d         nd}| j        r| j        d         nd}| j        r| j        d         nd}t-          | j                  }t-          | j                   }|                    ||||||          }	|	\  }
}}}}t1          | j        |
          D ]\  }}|                    |           | j                            |           | j	                            |           | j
                            |           t1          | j        |          D ]\  }}|                    |           Pd S )Nr8   r   )r   r   r   r   r   r   )r   r   r   r   r   r    r   r   r   r   r   r   r   r   r}   r~   r   r   r   	enumerater   r   r   r   r
  r#  update)r4   imoltypemolr   r   r   r   r   shiftedr   r   r   r   r   system_attrmol_attrsystem_param	mol_params                      r*   r   zITPParser.build_system  sd   

 HJKMJLK	
 !&&
!$''$T**$T**z4;O#D$9:: 	/ 	/JAw.)C%)X4TXb\\1F'+{9DKOOE,0,=D4$R((1D$$E$(mmG'' (  G =D9J6),T_j)I)I - -%X""8,,,,M  ***L(((Kv&&&+.t{F+C+C / /'i##I..../5	/ 	/r)   N)r   T)r"   r#   r$   r%   rl   r  r   r   r   r   r   r(   r)   r*   r   r     s        % %N F <p p p pd  < < <1 1 1
: : ::/ :/ :/ :/ :/r)   r   )*r%   collectionsr   rq   loggingnumpyr   r  lib.utilr   guesser.tablesr   guesser.default_guesserr   r   r	   r
   r   core.topologyattrsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   core.topologyr   r   r,   rz   r   r(   r)   r*   <module>r8     s>  0i iT $ # # # # # 				             # # # # # # 4 4 4 4 4 4 D D D D D D D D D D                                     & % $ $ $ $ $    8   w8 w8 w8 w8 w8 w8 w8 w8t@2 @2 @2 @2 @2 @2 @2 @2Fp/ p/ p/ p/ p/" p/ p/ p/ p/ p/r)   