§
    ÖX…f¸"  ã                   ó8   — d Z ddlZddlmZ  G d„ d¦  «        ZdS )z<Code handle loading mmtf-python into Biopython's structures.é    N)ÚStructureBuilderc                   ó`   — e Zd ZdZd„ Zd„ 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 )ÚStructureDecoderzHClass to pass the data from mmtf-python into a Biopython data structure.c                 ó   — d| _         dS )zInitialize the class.Ú N)Ú	this_type©Úselfs    ú:lib/python3.11/site-packages/Bio/PDB/mmtf/DefaultParser.pyÚ__init__zStructureDecoder.__init__   s   € àˆŒˆˆó    c                 óš   — t          ¦   «         | _        | j                             |¬¦  «         i | _        i | _        i | _        d| _        dS )aÍ  Initialize the structure object.

        :param total_num_bonds: the number of bonds in the structure
        :param total_num_atoms: the number of atoms in the structure
        :param total_num_groups: the number of groups in the structure
        :param total_num_chains: the number of chains in the structure
        :param total_num_models: the number of models in the structure
        :param structure_id: the id of the structure (e.g. PDB id)

        )Ústructure_idr   N)r   Ústructure_builderÚinit_structureÚchain_index_to_type_mapÚchain_index_to_seq_mapÚchain_index_to_description_mapÚchain_counter)r
   Útotal_num_bondsÚtotal_num_atomsÚtotal_num_groupsÚtotal_num_chainsÚtotal_num_modelsr   s          r   r   zStructureDecoder.init_structure   sR   € õ& "2Ñ!3Ô!3ˆÔØÔ×-Ò-¸<Ð-ÑHÔHÐHØ')ˆÔ$Ø&(ˆÔ#Ø.0ˆÔ+ØˆÔÐÐr   c                 óø   — |dk    rd}| j                              t          |¦  «        t          j        |||fd¦  «        |||t          |¦  «        |t          |	¦  «                             ¦   «         ¬¦  «         dS )a¿  Create an atom object an set the information.

        :param atom_name: the atom name, e.g. CA for this atom
        :param serial_number: the serial id of the atom (e.g. 1)
        :param alternative_location_id: the alternative location id for the atom, if present
        :param x: the x coordinate of the atom
        :param y: the y coordinate of the atom
        :param z: the z coordinate of the atom
        :param occupancy: the occupancy of the atom
        :param temperature_factor: the temperature factor of the atom
        :param element: the element of the atom, e.g. C for carbon. According to IUPAC. Calcium  is Ca
        :param charge: the formal atomic charge of the atom

        ú ú Úf)Úserial_numberÚelementN)r   Ú	init_atomÚstrÚnpÚarrayÚupper)r
   Ú	atom_namer   Úalternative_location_idÚxÚyÚzÚ	occupancyÚtemperature_factorr    Úcharges              r   Úset_atom_infozStructureDecoder.set_atom_info/   s‰   € ð: # fÒ,Ð,Ø&)Ð#ð 	Ô×(Ò(Ý	‰NŒNÝŒHa˜˜AY Ñ$Ô$ØØØ#Ý	‰NŒNØ'Ý˜‘L”L×&Ò&Ñ(Ô(ð 	)ñ 		
ô 		
ð 		
ð 		
ð 		
r   c                 ó  — | j                              |¬¦  «         | j        | j                 dk    rd| _        n;| j        | j                 dk    rd| _        n| j        | j                 dk    rd| _        | xj        dz  c_        d	S )
zÒSet the chain information.

        :param chain_id: the asym chain id from mmCIF
        :param chain_name: the auth chain id from mmCIF
        :param num_groups: the number of groups this chain has

        )Úchain_idÚpolymerr   znon-polymerÚHÚwaterÚWé   N)r   Ú
init_chainr   r   r   )r
   r0   Ú
chain_nameÚ
num_groupss       r   Úset_chain_infozStructureDecoder.set_chain_info[   s“   € ð 	Ô×)Ò)°:Ð)Ñ>Ô>Ð>ØÔ'¨Ô(:Ô;¸yÒHÐHØ ˆDŒNˆNØÔ)¨$Ô*<Ô=ÀÒNÐNØ ˆDŒNˆNØÔ)¨$Ô*<Ô=ÀÒHÐHØ ˆDŒNØÐÔ˜aÑÐÔÐÐr   c                 óL   — |D ] }|| j         |<   || j        |<   || j        |<   Œ!dS )aP  Set the entity level information for the structure.

        :param chain_indices: the indices of the chains for this entity
        :param sequence: the one letter code sequence for this entity
        :param description: the description for this entity
        :param entity_type: the entity type (polymer,non-polymer,water)

        N)r   r   r   )r
   Úchain_indicesÚsequenceÚdescriptionÚentity_typeÚ	chain_inds         r   Úset_entity_infoz StructureDecoder.set_entity_infon   sK   € ð 'ð 	Ið 	IˆIØ6AˆDÔ(¨Ñ3Ø5=ˆDÔ'¨	Ñ2Ø=HˆDÔ/°	Ñ:Ð:ð	Ið 	Ir   c
                 óŽ   — |dk    rd}| j                              d¦  «         | j                              || j        ||¦  «         dS )aQ  Set the information for a group.

        :param group_name: the name of this group, e.g. LYS
        :param group_number: the residue number of this group
        :param insertion_code: the insertion code for this group
        :param group_type: a string indicating the type of group (as found in the chemcomp dictionary.
            Empty string if none available.
        :param atom_count: the number of atoms in the group
        :param bond_count: the number of unique bonds in the group
        :param single_letter_code: the single letter code of the group
        :param sequence_index: the index of this group in the sequence defined by the entity
        :param secondary_structure_type: the type of secondary structure used
            (types are according to DSSP and number to type mappings are defined in the specification)

        r   r   N)r   Úinit_segÚinit_residuer   )
r
   Ú
group_nameÚgroup_numberÚinsertion_codeÚ
group_typeÚ
atom_countÚ
bond_countÚsingle_letter_codeÚsequence_indexÚsecondary_structure_types
             r   Úset_group_infozStructureDecoder.set_group_info|   s[   € ð: ˜VÒ#Ð#Ø ˆNàÔ×'Ò'¨Ñ,Ô,Ð,ØÔ×+Ò+Ø˜œ¨°nñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó:   — | j                              |¦  «         dS )zšSet the information for a model.

        :param model_id: the index for the model
        :param chain_count: the number of chains in the model

        N)r   Ú
init_model)r
   Úmodel_idÚchain_counts      r   Úset_model_infozStructureDecoder.set_model_info¡   s!   € ð 	Ô×)Ò)¨(Ñ3Ô3Ð3Ð3Ð3r   c                 ó<   — | j                              ||¦  «         dS )zùSet the crystallographic information for the structure.

        :param space_group: the space group name, e.g. "P 21 21 21"
        :param unit_cell: an array of length 6 with the unit cell parameters in order: a, b, c, alpha, beta, gamma

        N)r   Úset_symmetry)r
   Úspace_groupÚ	unit_cells      r   Úset_xtal_infozStructureDecoder.set_xtal_infoª   s#   € ð 	Ô×+Ò+¨K¸ÑCÔCÐCÐCÐCr   c                 ó   — dS )aæ  Set the header information.

        :param r_free: the measured R-Free for the structure
        :param r_work: the measure R-Work for the structure
        :param resolution: the resolution of the structure
        :param title: the title of the structure
        :param deposition_date: the deposition date of the structure
        :param release_date: the release date of the structure
        :param experimnetal_methods: the list of experimental methods in the structure

        N© )r
   Úr_freeÚr_workÚ
resolutionÚtitleÚdeposition_dateÚrelease_dateÚexperimnetal_methodss           r   Úset_header_infoz StructureDecoder.set_header_info³   ó   € € € r   c                 ó   — dS )a}  Set the Bioassembly transformation information. A single bioassembly can have multiple transforms.

        :param bio_assembly_index: the integer index of the bioassembly
        :param input_chain_indices: the list of integer indices for the chains of this bioassembly
        :param input_transform: the list of doubles for  the transform of this bioassmbly transform.

        NrY   )r
   Úbio_assembly_indexÚinput_chain_indicesÚinput_transforms       r   Úset_bio_assembly_transz'StructureDecoder.set_bio_assembly_transÉ   rb   r   c                 ó   — dS )z.Any functions needed to cleanup the structure.NrY   r	   s    r   Úfinalize_structurez#StructureDecoder.finalize_structureÔ   rb   r   c                 ó   — dS )a#  Add bonds within a group.

        :param atom_index_one: the integer atom index (in the group) of the first partner in the bond
        :param atom_index_two: the integer atom index (in the group) of the second partner in the bond
        :param bond_order: the integer bond order

        NrY   ©r
   Úatom_index_oneÚatom_index_twoÚ
bond_orders       r   Úset_group_bondzStructureDecoder.set_group_bond×   rb   r   c                 ó   — dS )a#  Add bonds between groups.

        :param atom_index_one: the integer atom index (in the structure) of the first partner in the bond
        :param atom_index_two: the integer atom index (in the structure) of the second partner in the bond
        :param bond_order: the bond order

        NrY   rk   s       r   Úset_inter_group_bondz%StructureDecoder.set_inter_group_bondà   rb   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r.   r9   r@   rM   rR   rW   ra   rg   ri   ro   rq   rY   r   r   r   r      så   € € € € € ØRÐRðð ð ðð ð ð4*
ð *
ð *
ðX ð  ð  ð&Ið Ið Ið#
ð #
ð #
ðJ4ð 4ð 4ðDð Dð Dðð ð ð,	ð 	ð 	ð=ð =ð =ðð ð ðð ð ð ð r   r   )ru   Únumpyr#   ÚBio.PDB.StructureBuilderr   r   rY   r   r   ú<module>rx      sh   ðð CÐ Bà Ð Ð Ð à 5Ð 5Ð 5Ð 5Ð 5Ð 5ðYð Yð Yð Yð Yñ Yô Yð Yð Yð Yr   