def exercise(): pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str) ann = pdb_inp.extract_secondary_structure() pdb_int_params = mmtbx.model.manager.get_default_pdb_interpretation_params() pdb_int_params.pdb_interpretation.ncs_search.enabled=True model = mmtbx.model.manager( model_input = pdb_inp, pdb_interpretation_params=pdb_int_params, build_grm = True) model.setup_ncs_constraints_groups() log = StringIO() rm = ssb.substitute_ss( model, log=log) rm.run() # with open("res.pdb", 'w') as f: # f.write(model.model_as_pdb()) # check that strict NCS was implemented throughout dif = get_difference_chainsAB(strings=model.model_as_pdb()) for d in dif: assert approx_equal(d, (0,0,0), eps=0.005) log_cont = log.getvalue() # print("===========================") # print (log_cont) # print("===========================") assert log_cont.find("1 element(s) were skipped because they are in NCS copies") > 0 print("OK")
def exercise_2(): """ Same as 1 but automatic NCS search procedure does not match short chains, in this case chains B,C, so they left out of NCS. Not clear if we should utilize MTRIX instead of searching for NCS because currently we don't output them and in consecutive runs NCS search would be utilized anyway, potentially yelding different groups. """ inp = iotbx.pdb.input(source_info=None, lines=pdb_str_2) pdb_int_params = mmtbx.model.manager.get_default_pdb_interpretation_params( ) pdb_int_params.pdb_interpretation.ncs_search.enabled = True model = mmtbx.model.manager(model_input=inp, pdb_interpretation_params=pdb_int_params, process_input=True, log=null_out()) # model.get_xray_structure() ss = model.get_ss_annotation() assert ss.get_n_helices() == 3 assert ss.get_n_sheets() == 3 assert not model.ncs_constraints_present() assert model.get_ncs_obj() is not None model.setup_ncs_constraints_groups() # print model.get_ncs_obj() assert model.ncs_constraints_present() assert model.get_master_hierarchy().atoms_size() == 15 # print model.get_master_hierarchy().as_pdb_string() assert list(model.get_master_selection()).count(True) == 15
def test_2(): inp = iotbx.pdb.input(source_info=None, lines=pdb_str_0) model = mmtbx.model.manager(model_input=inp) model.expand_with_BIOMT_records() model = shift_and_box_model(model) model.search_for_ncs() model.setup_ncs_constraints_groups(filter_groups=True) assert model.ncs_constraints_present() assert not model.can_be_unique_with_biomt() assert "" == model.model_as_mmcif(try_unique_with_biomt=True)
def test_1(): inp = iotbx.pdb.input(source_info=None, lines=pdb_str_0) model = mmtbx.model.manager(model_input=inp) model.expand_with_BIOMT_records() model = shift_and_box_model(model) sel = model.selection("chain '0' or chain 'C' or chain 'F' or chain 'I' or chain 'L' or chain 'O' or chain 'R' or chain 'U' or chain 'X'") model = model.select(sel) model.search_for_ncs() model.setup_ncs_constraints_groups(filter_groups=True) n1 = model.get_number_of_atoms() assert n1 == 648, n1 assert model.ncs_constraints_present() nrgl = model.get_ncs_groups() assert len(nrgl[0].master_iselection) == 72 assert len(nrgl[0].copies) == 8 # nrgl._show() # print (model.can_be_unique_with_biomt()) cif_txt = model.model_as_mmcif(try_unique_with_biomt=True) # print (cif_txt) assert_lines_in_text(cif_txt, """ loop_ _pdbx_struct_assembly_gen.assembly_id _pdbx_struct_assembly_gen.oper_expression _pdbx_struct_assembly_gen.asym_id_list 1 (1-9) A""") assert_lines_in_text(cif_txt, """ loop_ _pdbx_struct_assembly.id _pdbx_struct_assembly.details _pdbx_struct_assembly.method_details _pdbx_struct_assembly.oligomeric_details _pdbx_struct_assembly.oligomeric_count 1 'Symmetry assembly' ? ? ? """) assert_lines_in_text(cif_txt, """ _pdbx_struct_oper_list.vector[1] _pdbx_struct_oper_list.vector[2] _pdbx_struct_oper_list.vector[3] 1 'point symmetry operation' ? ? 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0""") inp = iotbx.pdb.input(source_info=None, lines=cif_txt) m2 = mmtbx.model.manager(model_input=inp) n2_1 = m2.get_number_of_atoms() assert n2_1 == 72 m2.expand_with_BIOMT_records() n2_2 = m2.get_number_of_atoms() # print (n1, n2) assert n1 == n2_2, "%d, %d" % (n1, n2)
def exercise_1(): inp = iotbx.pdb.input(source_info=None, lines=pdb_str_1) model = mmtbx.model.manager( model_input = inp, log = null_out()) assert model.get_number_of_atoms() == 21 assert model.get_hierarchy().atoms_size() == 21 assert model.get_xray_structure().scatterers().size() == 21 ss = model.get_ss_annotation() # print ss.as_pdb_str() # STOP() assert ss.get_n_helices() == 3 # because the second strand contains chain B which is not in ATOM records # whole sheet got discarded. assert ss.get_n_sheets() == 0 rm = model.get_restraints_manager() assert rm.geometry.pair_proxies().bond_proxies.simple.size() == 6 # since No NCS was set, these functions return the whole thing and no # master selection assert model.get_master_hierarchy().atoms_size() == 21 assert model.get_master_selection().size() == 0 # print model.model_as_pdb() # print "="*40 # Here we set NCS constraints inp = iotbx.pdb.input(source_info=None, lines=pdb_str_1) pdb_int_params = mmtbx.model.manager.get_default_pdb_interpretation_params() pdb_int_params.pdb_interpretation.ncs_search.enabled=True model = mmtbx.model.manager( model_input = inp, pdb_interpretation_params = pdb_int_params, process_input=True, log = null_out()) # model.get_xray_structure() assert not model.ncs_constraints_present() assert model.get_ncs_obj() is not None model.setup_ncs_constraints_groups() # print model.get_ncs_obj() assert model.ncs_constraints_present() assert model.get_master_hierarchy().atoms_size() == 7 # print model.get_master_hierarchy().as_pdb_string() # print list(model.get_master_selection()) assert list(model.get_master_selection()).count(True) == 7