def exercise_secondary_structure_from_sequence(): pdb_inp = iotbx.pdb.input(source_info=None, lines=correct_answer) cs = pdb_inp.xray_structure_simple().crystal_symmetry() correct_h = pdb_inp.construct_hierarchy() test_h = ssb.secondary_structure_from_sequence(alpha_pdb_str, sequence="ACEDGFIHKMLNQPSRTWVY") test_h.atoms().reset_serial() # correct_h.write_pdb_file("correct_h.pdb") # test_h.write_pdb_file("test_h.pdb") # why this passes... for m1, m2 in zip(correct_h.models(), test_h.models()): m1.is_similar_hierarchy( other=m2) m1.is_identical_hierarchy(other=m2) for c1, c2 in zip(m1.chains(), m2.chains()): c1.is_similar_hierarchy( other=c2) c1.is_identical_hierarchy(other=c2) for rg1, rg2 in zip(c1.residue_groups(), c2.residue_groups()): rg1.is_similar_hierarchy( other=rg2) rg1.is_identical_hierarchy(other=rg2) f1 = correct_h.extract_xray_structure(crystal_symmetry=cs).structure_factors( algorithm="direct", d_min=2).f_calc().data() f2 = test_h.extract_xray_structure(crystal_symmetry=cs).structure_factors( algorithm="direct", d_min=2).f_calc().data() assert approx_equal(f1, f2) assert test_h.as_str() == correct_h.as_str() #correct_h.write_pdb_file(file_name="tst_1_ex_last_correct.pdb") #test_h.write_pdb_file(file_name="tst_1_ex_last_out.pdb") # ...and this fails ? # assert correct_h.is_similar_hierarchy(other=test_h) assert approx_equal(test_h.atoms().extract_xyz(), correct_h.atoms().extract_xyz(), eps=0.002) try: ssb.secondary_structure_from_sequence(alpha_pdb_str, sequence="") except Exception as e: assert str(e) == "sequence should contain at least one residue."
def generate_perfect_helix( rs_values, ts_values, angular_rs_values, radial_eta, angular_eta, angular_zeta, n_residues=10, residue_code="G", ): """ Compute AEV values for the perfect helix. """ perfect_helix_ph = ssb.secondary_structure_from_sequence( ssb.alpha_helix_str, residue_code * n_residues) box = uctbx.non_crystallographic_unit_cell_with_the_sites_in_its_center( sites_cart=perfect_helix_ph.atoms().extract_xyz(), buffer_layer=5) model = mmtbx.model.manager(model_input=None, crystal_symmetry=box.crystal_symmetry(), pdb_hierarchy=perfect_helix_ph, build_grm=True, log=null_out()) return AEV( model=model, rs_values=rs_values, ts_values=ts_values, angular_rs_values=angular_rs_values, radial_eta=radial_eta, angular_eta=angular_eta, angular_zeta=angular_zeta, ).get_values()
def generate_perfect_helix( rs_values, ts_values, angular_rs_values, radial_eta, angular_eta, angular_zeta, n_residues=10, residue_code="G", ): """ Compute AEV values for the perfect helix. """ perfect_helix_ph = ssb.secondary_structure_from_sequence( ssb.alpha_helix_str, residue_code * n_residues) model = mmtbx.model.manager(model_input=None, pdb_hierarchy=perfect_helix_ph, build_grm=True, log=null_out()) return AEV( model=model, rs_values=rs_values, ts_values=ts_values, angular_rs_values=angular_rs_values, radial_eta=radial_eta, angular_eta=angular_eta, angular_zeta=angular_zeta, ).get_values()
def exercise_01(prefix="exercise_01"): "Build poly-ALA beta strand" ph = ssb.secondary_structure_from_sequence( beta_strand_template, "".join(["A"]*22)) sites_1 = ph.atoms().extract_xyz() sites_2 = iotbx.pdb.input(source_info=None, lines=beta_strand_answer).construct_hierarchy().atoms().extract_xyz() assert sites_1.size()==sites_2.size() assert approx_equal(sites_1, sites_2, eps=0.002)
def generate_perfect_helix(n_residues=10, residue_code="G"): """ Compute AEV values for the perfect helix. """ perfect_helix_ph = ssb.secondary_structure_from_sequence( ssb.alpha_helix_str, residue_code * n_residues) model = mmtbx.model.manager(model_input=None, pdb_hierarchy=perfect_helix_ph, build_grm=True, log=null_out()) return AEV(model=model).get_values()
def exercise_00(prefix="exercise_00"): "Build poly-ALA alpha helix" ph = ssb.secondary_structure_from_sequence( alpha_helix_template, "".join(["A"]*12)) ph.atoms().reset_i_seq() #ph.write_pdb_file(file_name="%s_result.pdb"%prefix) sites_1 = ph.atoms().extract_xyz() sites_2 = iotbx.pdb.input(source_info=None, lines=alpha_helix_answer).construct_hierarchy().atoms().extract_xyz() #of = open("1.pdb","w") #print >> of, alpha_helix_answer #of.close() assert sites_1.size()==sites_2.size(), [sites_1.size(),sites_2.size()] d1 = flex.sqrt((sites_1 - sites_2).dot()) rmsd = ssb.calculate_rmsd_smart(ph, iotbx.pdb.input(source_info=None, lines=alpha_helix_answer).construct_hierarchy()) assert rmsd < 0.1, rmsd