
     i                      \    d dl Z d dlmZ d Zd Zd Zd Zd Zd Zd	 Z	d
 Z
d Zd Zd ZdS )    N)	constantsc                 n   ||         }||         }||         }| j         | j                 }	| j        | j                 }
| j        | j                 }| j        | j                 }| j        | j                 }| j        | j                 }| j        | j                 }|                    ||
|	|||||||
  
         dS )a  Add the atomic data to the DataTransferInterface.
    :param data_api the data api from where to get the data
    :param data_setters the class to push the data to
    :param atom_nams the list of atom names for the group
    :param element_names the list of element names for this group
    :param atom_charges the list formal atomic charges for this group
    :param group_atom_ind the index of this atom in the groupN)	alt_loc_listatom_counteratom_id_listx_coord_listy_coord_listz_coord_listoccupancy_listb_factor_listset_atom_info)data_apidata_setters
atom_nameselement_namesatom_chargesgroup_atom_ind	atom_nameelementchargealternative_location_idserial_numberxyz	occupancytemperature_factors                   b/srv/www/vhosts/g4struct/public_html/venv/lib/python3.11/site-packages/mmtf/utils/decoder_utils.pyadd_atom_datar      s     >*IN+G.)F&3H4IJ)(*?@Mh34Ah34Ah34A'(=>I!/0EFy-9P !Q	3EwPVX X X X X    c                     t          t          |                    D ]4}|                     ||dz           ||dz  dz            ||                    5dS )zAdd the bonds for this group.
    :param data_setters the class to push the data to
    :param bond_indices the indices of the atoms in the group that
    are bonded (in pairs)
    :param bond_orders the orders of the bonds      N)rangelenset_group_bond)r   bond_indicesbond_orders
bond_indexs       r   add_group_bondsr*      sk     C,,-- u u
##LA$>|JWXLYZN?[\ghr\sttttu ur    c                    | j         |         }t          | j        |         d                   }| j        |         }|                    | j        |         d         | j        |         || j        |         d         || j        | j        |         d         | j        |         | j        |         	  	         t          |          D ]Y}t          | || j        |         d         | j        |         d         | j        |         d         |           | xj        dz  c_        Zt          || j        |         d         | j        |         d	                    |S )
zAdd the data for a whole group.
    :param data_api the data api from where to get the data
    :param data_setters the class to push the data to
    :param group_index the index for this groupatomNameList	groupNamechemCompTypesingleLetterCodeelementListformalChargeListr#   bondAtomListbondOrderList)group_type_listr%   
group_listins_code_listset_group_infogroup_id_list	num_bondssequence_index_listsec_struct_listr$   r   r   r*   )r   r   group_indexgroup_type_ind
atom_countinsertion_coder   s          r   	add_groupr@   $   si   
 -k:NX(8HIIJ+K8N 3N CK P ( 6{ C^ ( 3N CN S *H,> ( 3N CDV W ( <[ I ( 8 EG G G  
++ " "h).9.I).9-H).9:LM$		& 	& 	&
 	!L'7G'7HJ J J r    c                 ,   | j         |         }| j        |         }| j        |         }|                    |||           | j        |z   }| j        }t          ||          D ]#}t          | ||           | xj        dz  c_        $| xj        dz  c_        dS )zAdd the data for a whole chain.
    :param data_api the data api from where to get the data
    :param data_setters the class to push the data to
    :param chain_index the index for this chainr#   N)chain_id_listchain_name_listgroups_per_chainset_chain_infogroup_counterr$   r@   chain_counter)	r   r   chain_indexchain_id
chain_name
num_groupsnext_indlast_ind	group_inds	            r   add_chain_inforO   @   s    
 %k2H)+6J*;7J*jAAA%
2H%H8X.. # #	(L)444"Ar    c                     | j         D ]b}|                    | j        |           | j        |z   }| j        }t	          ||          D ]}t          | ||           | xj        dz  c_        cdS )zAdd all the structural information.
    :param data_api the data api from where to get the data
    :param data_setters the class to push the data tor#   N)chains_per_modelset_model_infomodel_counterrG   r$   rO   )r   r   model_chainstot_chains_this_modellast_chain_counterrH   s         r   add_atomic_informationrW   Q   s     !1 " "##H$:LIII ( 6 E%3 !35JKK 	@ 	@K8\;????!" "r    c                     d}| j         D ]5}|dz  }|d         D ]%}|                    ||d         |d                    &6dS )zGenerate the bioassembly data.
    :param data_api the interface to the decoded data
    :param struct_inflator the interface to put the data into the client objectr   r#   transformListchainIndexListmatrixN)bio_assemblyset_bio_assembly_trans)r   struct_inflatorbioassembly_countbioassembly	transforms        r   generate_bio_assemblyrb   ^   s     , H HQ$_5 	H 	HI223D3<=M3N3<X3FH H H H	HH Hr    c                     t          t          | j                            D ]C}|                    | j        |dz           | j        |dz  dz            | j        |                    DdS )z	 Generate inter group bonds.
	 Bond indices are specified within the whole structure and start at 0.
	 :param data_api the interface to the decoded data
	 :param struct_inflator the interface to put the data into the client objectr"   r#   N)r$   r%   bond_order_listset_inter_group_bondbond_atom_list)r   r^   is      r   add_inter_group_bondsrh   j   s    
 3x/0011 J J,,X-DQU-K-5-DQUQY-O-5-Ea-H	J 	J 	J 	JJ Jr    c           	          |                     | j        | j        | j        | j        | j        | j        | j                   dS )z Add ancilliary header information to the structure.
	 :param data_api the interface to the decoded data
	 :param struct_inflator the interface to put the data into the client object
	 N)set_header_infor_freer_work
resolutiontitledeposition_daterelease_dateexperimental_methodsr   r^   s     r   add_header_infors   v   sQ    
 ##HO$,O$,$7$,N$,$<$,$9$,$AC C C C Cr    c                    | j         dk    r.| j        '|                    | j        t          j                   dS | j         .| j        '|                    t          j        | j                    dS | j         3| j        ,|                    t          j        t          j                   dS |                    | j        | j                    dS )z	 Add the crystallographic data to the structure.
	 :param data_api the interface to the decoded data
	 :param struct_inflator the interface to put the data into the client objectN)	unit_cellspace_groupset_xtal_infor   UNKNOWN_UNIT_CELLUNKNOWN_SPACE_GROUPrr   s     r   add_xtalographic_inforz      s     T!!h&:&F%%h&:&/&A	C 	C 	C 	C 	C			'H,@,H%%i&C&.&8	: 	: 	: 	: 	:			#(<(D%%i&C&/&A	C 	C 	C 	C 	C 	%%h&:&.&8	: 	: 	: 	: 	:r    c           	          | j         D ]@}|                    |d         |d         |                    dd          |d                    AdS )zAdd the entity info to the structure.
    :param data_api the interface to the decoded data
    :param struct_inflator the interface to put the data into the client object
    rZ   sequencedescription typeN)entity_listset_entity_infoget)r   r^   entitys      r   add_entity_infor      se    
 & 8 8''/?(@(.z(:(.

="(E(E(.v	8 	8 	8 	88 8r    c                     g }t          t          | j                            D ]8}|                    | j        |dz           | j        |dz  dz            f           9|S )z8Utility function to get indices (in pairs) of the bonds.r"   r#   )r$   r%   rd   appendrf   )input_groupout_listrg   s      r   	get_bondsr      sk    H3{23344 e e3AE:K<VWX[\W\_`W`<acddddOr    )sys
mmtf.utilsr   r   r*   r@   rO   rW   rb   rh   rs   rz   r   r    r    r   <module>r      s    



            X X X,u u u  8  "
" 
" 
"
H 
H 
HJ J JC C C: : :"	8 	8 	8    r    