def pass_data_on(self, data_setters): """Write the data from the getters to the setters. :param data_setters: a series of functions that can fill a chemical data structure :type data_setters: DataTransferInterface """ data_setters.init_structure(self.num_bonds, len(self.x_coord_list), len(self.group_type_list), len(self.chain_id_list), len(self.chains_per_model), self.structure_id) decoder_utils.add_entity_info(self, data_setters) decoder_utils.add_atomic_information(self, data_setters) decoder_utils.add_header_info(self, data_setters) decoder_utils.add_xtalographic_info(self, data_setters) decoder_utils.generate_bio_assembly(self, data_setters) decoder_utils.add_inter_group_bonds(self, data_setters) data_setters.finalize_structure()
def pass_data_on(self, data_setters): """Write the data from the getters to the setters. Attributes ---------- data_setters (DataTransferInterface): a series of functions that can\ fill a chemical """ self.set_alt_loc_list() data_setters.init_structure(self.num_bonds, len(self.x_coord_list), len(self.group_type_list), len(self.chain_id_list), len(self.chains_per_model), self.structure_id) decoder_utils.add_entity_info(self, data_setters) decoder_utils.add_atomic_information(self, data_setters) decoder_utils.add_header_info(self, data_setters) decoder_utils.add_xtalographic_info(self, data_setters) decoder_utils.generate_bio_assembly(self, data_setters) decoder_utils.add_inter_group_bonds(self, data_setters) data_setters.finalize_structure()
def __call__(self, t): structure = t[1] # Precalculate indices numChains = structure.chains_per_model[0] chainToEntityIndex = self._get_chain_to_entity_index(structure) atomsPerChain, bondsPerChain = self._get_num_atoms_and_bonds(structure) chainList = list() seqSet = set() groupCounter = 0 atomCounter = 0 for i in range(numChains): polymerChain = MMTFEncoder() entityToChainIndex = chainToEntityIndex[i] chain_type = structure.entity_list[entityToChainIndex]['type'] polymer = chain_type == "polymer" polymerAtomCount = 0 atomMap = {} structureId = '' if polymer: # To avoid of information loss, add chainName/IDs and entity id # This required by some queries structureId = structure.structure_id + '.' +\ structure.chain_name_list[i] + '.' +\ structure.chain_id_list[i] + '.' +\ str(entityToChainIndex + 1) # Set header polymerChain.init_structure(bondsPerChain[i], atomsPerChain[i], structure.groups_per_chain[i], 1, 1, structureId) decoder_utils.add_xtalographic_info(structure, polymerChain) decoder_utils.add_header_info(structure, polymerChain) # Set model info (only one model: 0) polymerChain.set_model_info(0, 1) # Set entity and chain info polymerChain.set_entity_info( [0], structure.entity_list[entityToChainIndex]['sequence'], structure.entity_list[entityToChainIndex]['description'], structure.entity_list[entityToChainIndex]['type']) polymerChain.set_chain_info(structure.chain_id_list[i], structure.chain_name_list[i], structure.groups_per_chain[i]) for j in range(structure.groups_per_chain[i]): groupIndex = structure.group_type_list[groupCounter] if polymer: # Set group info polymerChain.set_group_info( structure.group_list[groupIndex]['groupName'], structure.group_id_list[groupCounter], structure.ins_code_list[groupCounter], structure.group_list[groupIndex]['chemCompType'], len(structure.group_list[groupIndex]['atomNameList']), len(structure.group_list[groupIndex]['bondOrderList']), structure.group_list[groupIndex]['singleLetterCode'], structure.sequence_index_list[groupCounter], structure.sec_struct_list[groupCounter]) for k in range( len(structure.group_list[groupIndex]['atomNameList'])): if polymer: atomMap[atomCounter] = polymerAtomCount polymerAtomCount += 1 polymerChain.set_atom_info( structure.group_list[groupIndex]['atomNameList'] [k], structure.atom_id_list[atomCounter], structure.alt_loc_list[atomCounter], structure.x_coord_list[atomCounter], structure.y_coord_list[atomCounter], structure.z_coord_list[atomCounter], structure.occupancy_list[atomCounter], structure.b_factor_list[atomCounter], structure.group_list[groupIndex]['elementList'][k], structure.group_list[groupIndex] ['formalChargeList'][k], ) atomCounter += 1 if polymer: # Add intra-group bond info for l in range( len(structure.group_list[groupIndex] ['bondOrderList'])): bondIndOne = structure.group_list[groupIndex][ 'bondAtomList'][l * 2] bondIndTwo = structure.group_list[groupIndex][ 'bondAtomList'][l * 2 + 1] bondOrder = structure.group_list[groupIndex][ 'bondOrderList'][l] polymerChain.set_group_bond(bondIndOne, bondIndTwo, bondOrder) groupCounter += 1 if polymer: # TODO skipping adding inter group bond info for now polymerChain.finalize_structure() chId = structure.chain_name_list[i] if self.useChainIdInsteadOfChainName: chId = structure.chain_id_list[i] if self.excludeDuplicates: if chainToEntityIndex[i] in seqSet: continue seqSet.add(chainToEntityIndex[i]) chainList.append( (structure.structure_id + "." + chId, polymerChain)) return chainList