def test_ncs_copies_naming(self): # print sys._getframe().f_code.co_name transforms_obj = ncs_group_object() result = transforms_obj.make_chains_names( ['chain A_001','chain B_001','chain A_002','chain B_002'],('A','B')) expected = {'chain A_001': 'C', 'chain B_001': 'D', 'chain A_002': 'E', 'chain B_002': 'F'} self.assertEqual(result,expected)
def test_pdb_writing(self): # print sys._getframe().f_code.co_name """ Verify that there are no errors processing the write command No inception of the output is done. To view the output change the write=False to ,write=True """ transforms_obj = ncs_group_object() pdb_inp = pdb.input(source_info=None, lines=pdb_test_data2) pdb_obj = pdb.hierarchy.input(pdb_string=pdb_test_data2) transform_info = pdb_inp.process_mtrix_records() transforms_obj.preprocess_ncs_obj( transform_info=transform_info, pdb_hierarchy_inp=pdb_obj) multimer_data = multimer( pdb_str=pdb_test_data2, reconstruction_type='cau') pdb_hierarchy_asu = multimer_data.assembled_multimer # print '--- using ASU hierarchy ---' pdbstr = transforms_obj.get_transform_records( ncs_only=True, pdb_hierarchy=pdb_hierarchy_asu, write=False) # print pdbstr # print '='*50 pdbstr = transforms_obj.get_transform_records( ncs_only=False, pdb_hierarchy=pdb_hierarchy_asu, write=False) # print pdbstr # print '--- using the hierarchy of only the master NCS ---' pdbstr = transforms_obj.get_transform_records( pdb_hierarchy=pdb_obj.hierarchy, biomt=True, write=False) # print pdbstr # print '--- from xray structure ---' xrs = pdb_hierarchy_asu.extract_xray_structure() pdbstr = transforms_obj.get_transform_records( # xrs=pdb_obj.xray_structure_simple(), xrs=xrs, biomt=True, write=False)
def test_writing_spec_file(self): # print sys._getframe().f_code.co_name """ Verify that there are no errors processing the write command No inception of the output is done. Just making sure it does not break To view the output change the write=False to ,write=True """ transforms_obj = ncs_group_object() pdb_inp = pdb.input(source_info=None, lines=pdb_test_data2) pdb_obj = pdb.hierarchy.input(pdb_string=pdb_test_data2) transform_info = pdb_inp.process_mtrix_records() transforms_obj.preprocess_ncs_obj( # transform_info=transform_info, # pdb_hierarchy_inp=pdb_obj, pdb_inp=pdb_inp) asu = multimer( pdb_str=pdb_test_data2, reconstruction_type='cau') transforms_obj.get_ncs_info_as_spec( pdb_hierarchy_asu=asu.assembled_multimer,write=False)
def __init__( self, reconstruction_type="cau", file_name=None, pdb_str=None, error_handle=True, eps=1e-3, round_coordinates=True, ): """ Arguments: reconstruction_type -- 'ba' or 'cau' 'ba': biological assembly 'cau': crystallographic asymmetric unit file_name -- the name of the pdb file we want to process. a string such as 'pdb_file_name.pdb' pdb_str -- a string containing pdb information, when not using a pdb file error_handle -- True: will stop execution on improper rotation matrices False: will continue execution but will replace the values in the rotation matrix with [0,0,0,0,0,0,0,0,0] eps -- Rounding accuracy for avoiding numerical issue when when testing proper rotation round_coordinates -- round coordinates of new NCS copies, for sites_cart constancy @author: Youval Dar (2013) """ # Todo : add ability to reconstruct ASU for multiple groups assert file_name or pdb_str # Read and process the pdb file if file_name: self.pdb_input_file_name = file_name pdb_obj = pdb.hierarchy.input(file_name=file_name) pdb_inp = pdb.input(file_name=file_name) else: self.pdb_input_file_name = "complete_reconstructed_unit.pdb" pdb_obj = pdb.hierarchy.input(pdb_string=pdb_str) pdb_inp = pdb.input(lines=pdb_str, source_info=None) if reconstruction_type == "ba": transform_info = pdb_inp.process_BIOMT_records(error_handle=error_handle, eps=eps) self.transform_type = "biological_assembly" elif reconstruction_type == "cau": transform_info = pdb_inp.process_mtrix_records(error_handle=error_handle, eps=eps) if transform_info.as_pdb_string() == "" or (not ncs_only(transform_info)): transform_info = None else: transform_info = insure_identity_is_in_transform_info(transform_info) self.transform_type = "crystall_asymmetric_unit" else: raise Sorry( "Sorry, wrong reconstruction type is given \n" + "Reconstruction type can be: \n" + "'ba': biological assembly \n" + "'cau': crystallographic asymmetric unit \n" ) if len(pdb_obj.hierarchy.models()) > 1: raise Sorry("Sorry, this feature currently supports on single models " + "hierarchies") self.transforms_obj = ncs_group_object() # Read the relevant transformation matrices self.transforms_obj.build_ncs_obj_from_pdb_ncs(transform_info=transform_info, pdb_hierarchy_inp=pdb_obj) # Calculate ASU (if there are any transforms to apply) self.number_of_transforms = len(self.transforms_obj.transform_to_be_used) self.assembled_multimer = self.transforms_obj.build_asu_hierarchy( pdb_hierarchy=pdb_obj.hierarchy, round_coordinates=round_coordinates ) annot = pdb_inp.extract_secondary_structure() self.new_annotation = None if annot is not None: annot.multiply_to_asu( ncs_copies_chain_names=self.transforms_obj.ncs_copies_chains_names, n_copies=self.number_of_transforms ) self.new_annotation = annot