コード例 #1
0
def tst_01():
  print "Comparing mixed model with target..."
  import iotbx.pdb
  from cctbx.array_family import flex
  model_pdb_inp=iotbx.pdb.input(source_info='model',
       lines=flex.split_lines(model))
  crystal_symmetry=model_pdb_inp.crystal_symmetry()
  model_hierarchy=model_pdb_inp.construct_hierarchy()
  query_hierarchy=iotbx.pdb.input(source_info='query',
       lines=flex.split_lines(query)).construct_hierarchy()

  f=StringIO()
  r=run(crystal_symmetry=crystal_symmetry,
    chain_hierarchy=query_hierarchy,target_hierarchy=model_hierarchy,out=f)

  expected_text="""
Residues matching in forward direction:     16  RMSD:   1.45
Residues matching in reverse direction:     31  RMSD:   1.40
Residues near but not matching one-to-one:  12  RMSD:   1.87
Residues far from target:                    2  RMSD:   2.04
"""

  found_text="\n".join(f.getvalue().splitlines()[-4:])
  if remove_blank(found_text)!=remove_blank(expected_text):
    print "Expected: \n%s \nFound: \n%s" %(expected_text,found_text)
    raise AssertionError, "FAILED"
  print "OK"
コード例 #2
0
def tst_02():
    print("Comparing mixed model with target with 2 chains...")
    import iotbx.pdb
    from cctbx.array_family import flex
    model_pdb_inp = iotbx.pdb.input(source_info='model',
                                    lines=flex.split_lines(model1))
    crystal_symmetry = model_pdb_inp.crystal_symmetry()
    model_hierarchy = model_pdb_inp.construct_hierarchy()
    query_hierarchy = iotbx.pdb.input(
        source_info='query',
        lines=flex.split_lines(query)).construct_hierarchy()

    f = StringIO()
    r = run(crystal_symmetry=crystal_symmetry,
            chain_hierarchy=query_hierarchy,
            target_hierarchy=model_hierarchy,
            out=f)
    expected_text = """
  SEQ SCORE is fraction (close and matching target sequence).
MEAN LENGTH is the mean length of contiguous segments in the match with target sequence. (Each gap/reverse of direction starts new segment).



               ----ALL RESIDUES---  CLOSE RESIDUES ONLY    %
     MODEL     --CLOSE-    --FAR-- FORWARD REVERSE MIXED FOUND  CA                  SEQ
               RMSD   N      N       N       N      N          SCORE  SEQ MATCH(%)  SCORE  MEAN LENGTH

 Unique_target 1.55   54      7     14      29      11   39.7   0.26     9.3        0.04    6.0"""
    found_text = "\n".join(f.getvalue().splitlines()[-10:])
    if remove_blank(found_text) != remove_blank(expected_text):
        print("\n\nExpected: \n%s \n\nFound: \n%s" %
              (expected_text, found_text))
        raise AssertionError("FAILED")

    from libtbx.test_utils import approx_equal
    print(r.get_values("forward"))
    assert approx_equal(r.get_values("forward"), (1.6751069901864204, 14))
    print(r.get_values("reverse"))
    assert approx_equal(r.get_values("reverse"), (1.388466550576198, 29))
    print(r.get_values("close"))
    assert approx_equal(r.get_values("close"), (1.545835235099158, 54))
    print(r.get_values("all_far"))
    assert approx_equal(r.get_values("all_far"), (0, 0))
    print("OK")
コード例 #3
0
def tst_03():
    print("Comparing mixed model with target with 2 chains...as group")
    import iotbx.pdb
    from cctbx.array_family import flex
    model_pdb_inp = iotbx.pdb.input(source_info='model',
                                    lines=flex.split_lines(model1))
    crystal_symmetry = model_pdb_inp.crystal_symmetry()
    model_hierarchy = model_pdb_inp.construct_hierarchy()
    query_hierarchy = iotbx.pdb.input(
        source_info='query',
        lines=flex.split_lines(query)).construct_hierarchy()
    import os
    if not os.path.isdir("files"):
        os.mkdir("files")

    ff = open(os.path.join("files", "query.pdb"), 'w')
    print("CRYST1  113.949  113.949   32.474  90.00  90.00  90.00 I 4",
          file=ff)
    print(query_hierarchy.as_pdb_string(), file=ff)
    ff.close()
    ff = open("model.pdb", 'w')
    print(model_hierarchy.as_pdb_string(), file=ff)
    ff.close()

    f = StringIO()
    args = ["query_dir=files", "model.pdb"]
    r = run(args, out=f)
    expected_text = """
  SEQ SCORE is fraction (close and matching target sequence).
MEAN LENGTH is the mean length of contiguous segments in the match with target sequence. (Each gap/reverse of direction starts new segment).



               ----ALL RESIDUES---  CLOSE RESIDUES ONLY    %
     MODEL     --CLOSE-    --FAR-- FORWARD REVERSE MIXED FOUND  CA                  SEQ
               RMSD   N      N       N       N      N          SCORE  SEQ MATCH(%)  SCORE  MEAN LENGTH

     query.pdb 1.55   54      7     14      29      11   39.7   0.26     9.3        0.04    6.0"""
    found_text = "\n".join(f.getvalue().splitlines()[-10:])
    if remove_blank(found_text) != remove_blank(expected_text):
        print("Expected: \n%s \nFound: \n%s" % (expected_text, found_text))
        raise AssertionError("FAILED")
    print("OK")
コード例 #4
0
def tst_02():
  print "Comparing mixed model with target with 2 chains..."
  import iotbx.pdb
  from cctbx.array_family import flex
  model_pdb_inp=iotbx.pdb.input(source_info='model',
       lines=flex.split_lines(model1))
  crystal_symmetry=model_pdb_inp.crystal_symmetry()
  model_hierarchy=model_pdb_inp.construct_hierarchy()
  query_hierarchy=iotbx.pdb.input(source_info='query',
       lines=flex.split_lines(query)).construct_hierarchy()

  f=StringIO()
  r=run(crystal_symmetry=crystal_symmetry,
    chain_hierarchy=query_hierarchy,target_hierarchy=model_hierarchy,out=f)
  expected_text="""
Space group: I 4 Unit cell:  113.95  113.95   32.47    90.00   90.00   90.00 

Looking for chain similarity for None (61 residues) in the model None (272 residues)

Residues matching in forward direction:     16  RMSD:   1.45
Residues matching in reverse direction:     31  RMSD:   1.40
Residues near but not matching one-to-one:  12  RMSD:   1.87

All residues near target:   59  RMSD:   1.52 Seq match (%):  6.8  % Found:  43.4
Residues far from target:    2  RMSD:   3.31
"""

  found_text="\n".join(f.getvalue().splitlines()[-10:])
  if remove_blank(found_text)!=remove_blank(expected_text):
    print "Expected: \n%s \nFound: \n%s" %(expected_text,found_text)
    raise AssertionError, "FAILED"

  from libtbx.test_utils import approx_equal
  print r.get_values("forward")
  assert approx_equal(r.get_values("forward"),(1.4473857036049544, 16))
  print r.get_values("reverse")
  assert approx_equal(r.get_values("reverse"),(1.3969610738798282, 31))
  print r.get_values("close")
  assert approx_equal(r.get_values("close"),(1.5184018499613678, 59))
  print r.get_values("all_far")
  assert approx_equal(r.get_values("all_far"),(0,0))
  print "OK"
コード例 #5
0
def tst_03():
  print "Comparing mixed model with target with 2 chains...as group"
  import iotbx.pdb
  from cctbx.array_family import flex
  model_pdb_inp=iotbx.pdb.input(source_info='model',
       lines=flex.split_lines(model1))
  crystal_symmetry=model_pdb_inp.crystal_symmetry()
  model_hierarchy=model_pdb_inp.construct_hierarchy()
  query_hierarchy=iotbx.pdb.input(source_info='query',
       lines=flex.split_lines(query)).construct_hierarchy()
  import os,shutil
  if not os.path.isdir("files"):
    os.mkdir("files")

  ff=open(os.path.join("files","query.pdb"),'w')
  print >>ff,"CRYST1  113.949  113.949   32.474  90.00  90.00  90.00 I 4"
  print >>ff,query_hierarchy.as_pdb_string()
  ff.close()
  ff=open("model.pdb",'w')
  print >>ff,model_hierarchy.as_pdb_string()
  ff.close()

  f=StringIO()
  args=["query_dir=files","model.pdb"]
  r=run(args,out=f)
  expected_text="""
SEQ SCORE is fraction (close and matching target sequence).



               ----ALL RESIDUES----     CLOSE RESIDUES ONLY    %
     MODEL     --CLOSE-    ---FAR--    FORWARD REVERSE MIXED FOUND   CA                   SEQ
               RMSD   N    RMSD   N       N       N      N          SCORE  SEQ MATCH(%)  SCORE

     query.pdb 1.52   59    3.3    2     16      31      12   43.4   0.29     6.8        0.03
"""
  found_text="\n".join(f.getvalue().splitlines()[-10:])
  if remove_blank(found_text)!=remove_blank(expected_text):
    print "Expected: \n%s \nFound: \n%s" %(expected_text,found_text)
    raise AssertionError, "FAILED"
  print "OK"
コード例 #6
0
def tst_06():
    print("Comparing mixed model with target with 2 chains...using ncs")
    import iotbx.pdb
    from cctbx.array_family import flex
    model_pdb_inp = iotbx.pdb.input(source_info='model',
                                    lines=flex.split_lines(model1))
    crystal_symmetry = model_pdb_inp.crystal_symmetry()
    f = open('ncs.ncs_spec', 'w')
    print(ncs_spec, file=f)
    f.close()
    f = open('model.pdb', 'w')
    print(model1, file=f)  #model_hierarchy.as_pdb_string()
    f.close()
    f = open('query.pdb', 'w')
    print(query, file=f)  #query_hierarchy.as_pdb_string()
    f.close()

    f = StringIO()
    args = ['model.pdb', 'query.pdb', 'ncs_file=ncs.ncs_spec']
    r = run(args, out=f)
    expected_text = """
  SEQ SCORE is fraction (close and matching target sequence).
MEAN LENGTH is the mean length of contiguous segments in the match with target sequence. (Each gap/reverse of direction starts new segment).



               ----ALL RESIDUES---  CLOSE RESIDUES ONLY    %
     MODEL     --CLOSE-    --FAR-- FORWARD REVERSE MIXED FOUND  CA                  SEQ
               RMSD   N      N       N       N      N          SCORE  SEQ MATCH(%)  SCORE  MEAN LENGTH

 Unique_target 1.67   58     64     15      29      14   42.6   0.25     8.6        0.04    4.5"""
    found_text = "\n".join(f.getvalue().splitlines()[-10:])
    if remove_blank(found_text) != remove_blank(expected_text):
        print("\n\nExpected: \n%s \n\nFound: \n%s" %
              (expected_text, found_text))
        raise AssertionError("FAILED")

    print("OK")
コード例 #7
0
def tst_06():
    print "Comparing mixed model with target with 2 chains...using ncs"
    import iotbx.pdb
    from cctbx.array_family import flex
    model_pdb_inp = iotbx.pdb.input(source_info='model',
                                    lines=flex.split_lines(model1))
    crystal_symmetry = model_pdb_inp.crystal_symmetry()
    f = open('ncs.ncs_spec', 'w')
    print >> f, ncs_spec
    f.close()
    f = open('model.pdb', 'w')
    print >> f, model1  #model_hierarchy.as_pdb_string()
    f.close()
    f = open('query.pdb', 'w')
    print >> f, query  #query_hierarchy.as_pdb_string()
    f.close()

    f = StringIO()
    args = ['model.pdb', 'query.pdb', 'ncs_file=ncs.ncs_spec']
    r = run(args, out=f)
    expected_text = """
SEQ SCORE is fraction (close and matching target sequence).



               ----ALL RESIDUES---  CLOSE RESIDUES ONLY    %
     MODEL     --CLOSE-    --FAR-- FORWARD REVERSE MIXED FOUND  CA                  SEQ
               RMSD   N      N       N       N      N          SCORE  SEQ MATCH(%)  SCORE

 Unique_target 1.67   58     64     15      29      14   42.6   0.25     8.6        0.04
"""
    found_text = "\n".join(f.getvalue().splitlines()[-10:])
    if remove_blank(found_text) != remove_blank(expected_text):
        print "\n\nExpected: \n%s \n\nFound: \n%s" % (expected_text,
                                                      found_text)
        raise AssertionError, "FAILED"

    print "OK"