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, e: assert str(e) == "sequence should contain at least one residue."
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 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
def run(): h = ssb.secondary_structure_from_sequence(ssb.alpha_helix_str, "GGGGGGGGGGGGGGGGGGGG") h.write_pdb_file(file_name="m-helix.pdb")