Ejemplo n.º 1
0
def exercise_2():
  symmetry = crystal.symmetry(
    unit_cell=(5.67, 10.37, 10.37, 90, 135.49, 90),
    space_group_symbol="C2")
  structure = xray.structure(crystal_symmetry=symmetry)
  atmrad = flex.double()
  xyzf = flex.vec3_double()
  for k in xrange(100):
    scatterer = xray.scatterer(
      site = ((1.+k*abs(math.sin(k)))/1000.0,
              (1.+k*abs(math.cos(k)))/1000.0,
              (1.+ k)/1000.0),
      scattering_type = "C")
    structure.add_scatterer(scatterer)
    atmrad.append(van_der_waals_radii.vdw.table[scatterer.element_symbol()])
    xyzf.append(scatterer.site)
  miller_set = miller.build_set(
    crystal_symmetry=structure,
    d_min=1.0,
    anomalous_flag=False)
  step = 0.5
  crystal_gridding = maptbx.crystal_gridding(
    unit_cell=structure.unit_cell(),
    step=step)
  nxyz = crystal_gridding.n_real()
  shrink_truncation_radius = 1.0
  solvent_radius = 1.0
  m1 = around_atoms(
    structure.unit_cell(),
    structure.space_group().order_z(),
    structure.sites_frac(),
    atmrad,
    nxyz,
    solvent_radius,
    shrink_truncation_radius)
  assert m1.solvent_radius == 1
  assert m1.shrink_truncation_radius == 1
  assert flex.max(m1.data) == 1
  assert flex.min(m1.data) == 0
  assert m1.data.size() == m1.data.count(1) + m1.data.count(0)
  m2 = mmtbx.masks.bulk_solvent(
    xray_structure=structure,
    gridding_n_real=nxyz,
    ignore_zero_occupancy_atoms = False,
    solvent_radius=solvent_radius,
    shrink_truncation_radius=shrink_truncation_radius)
  assert m2.data.all_eq(m1.data)
  m3 = mmtbx.masks.bulk_solvent(
    xray_structure=structure,
    grid_step=step,
    ignore_zero_occupancy_atoms = False,
    solvent_radius=solvent_radius,
    shrink_truncation_radius=shrink_truncation_radius)
  assert m3.data.all_eq(m1.data)
  f_mask2 = m2.structure_factors(miller_set=miller_set)
  f_mask3 = m3.structure_factors(miller_set=miller_set)
  assert approx_equal(f_mask2.data(), f_mask3.data())
  assert approx_equal(flex.sum(flex.abs(f_mask3.data())), 1095.17999134)
Ejemplo n.º 2
0
def exercise_2():
    symmetry = crystal.symmetry(unit_cell=(5.67, 10.37, 10.37, 90, 135.49, 90),
                                space_group_symbol="C2")
    structure = xray.structure(crystal_symmetry=symmetry)
    atmrad = flex.double()
    xyzf = flex.vec3_double()
    for k in xrange(100):
        scatterer = xray.scatterer(site=((1. + k * abs(math.sin(k))) / 1000.0,
                                         (1. + k * abs(math.cos(k))) / 1000.0,
                                         (1. + k) / 1000.0),
                                   scattering_type="C")
        structure.add_scatterer(scatterer)
        atmrad.append(
            van_der_waals_radii.vdw.table[scatterer.element_symbol()])
        xyzf.append(scatterer.site)
    miller_set = miller.build_set(crystal_symmetry=structure,
                                  d_min=1.0,
                                  anomalous_flag=False)
    step = 0.5
    crystal_gridding = maptbx.crystal_gridding(unit_cell=structure.unit_cell(),
                                               step=step)
    nxyz = crystal_gridding.n_real()
    shrink_truncation_radius = 1.0
    solvent_radius = 1.0
    m1 = around_atoms(structure.unit_cell(),
                      structure.space_group().order_z(),
                      structure.sites_frac(), atmrad, nxyz, solvent_radius,
                      shrink_truncation_radius)
    assert m1.solvent_radius == 1
    assert m1.shrink_truncation_radius == 1
    assert flex.max(m1.data) == 1
    assert flex.min(m1.data) == 0
    assert m1.data.size() == m1.data.count(1) + m1.data.count(0)
    m2 = mmtbx.masks.bulk_solvent(
        xray_structure=structure,
        gridding_n_real=nxyz,
        ignore_zero_occupancy_atoms=False,
        solvent_radius=solvent_radius,
        shrink_truncation_radius=shrink_truncation_radius)
    assert m2.data.all_eq(m1.data)
    m3 = mmtbx.masks.bulk_solvent(
        xray_structure=structure,
        grid_step=step,
        ignore_zero_occupancy_atoms=False,
        solvent_radius=solvent_radius,
        shrink_truncation_radius=shrink_truncation_radius)
    assert m3.data.all_eq(m1.data)
    f_mask2 = m2.structure_factors(miller_set=miller_set)
    f_mask3 = m3.structure_factors(miller_set=miller_set)
    assert approx_equal(f_mask2.data(), f_mask3.data())
    assert approx_equal(flex.sum(flex.abs(f_mask3.data())), 1095.17999134)
Ejemplo n.º 3
0
def exercise_1():
#------------------------------------------------------------------------TEST-1
 if(1):
  r=(1.67,0.68,0.0,0.5,-0.31,-0.64,-1.63)
  d = 2.0*van_der_waals_radii.vdw.table["C"]
  a = (d/2.) * (4./3.*math.pi*2.)**(1./3.)
  for x in r:
   for y in r:
    for z in r:
     structure, xyzf, atmrad = structure_init((x,y,z),
                                              "P1",
                                              (a, a, a, 90, 90, 90))
     step = 0.1
     crystal_gridding = maptbx.crystal_gridding(
       unit_cell = structure.unit_cell(),
       step = step)
     shrink_truncation_radius = 0.0
     solvent_radius = 0.0
     m = around_atoms(
       structure.unit_cell(),
       structure.space_group().order_z(),
       xyzf,
       atmrad,
       crystal_gridding.n_real(),
       solvent_radius,
       shrink_truncation_radius)
     assert m.solvent_radius == 0
     assert m.shrink_truncation_radius == 0
     assert approx_equal(1./m.accessible_surface_fraction, 2.0, 1e-2)
     assert approx_equal(1./m.contact_surface_fraction, 2.0, 1e-2)
     assert flex.max(m.data) == 1
     assert flex.min(m.data) == 0
     assert m.data.size() == m.data.count(1) + m.data.count(0)
#------------------------------------------------------------------------TEST-2
 if(1):
  r=(-2.0,-1.0,-0.5,0.0,0.5,1.0,2.0)
  asf=[]
  csf=[]
  for x in r:
   for y in r:
     for z in r:
       structure, xyzf, atmrad = structure_init((x,y,z),
                                                "C2",
                                                (5.0, 5.5, 7.0, 90, 80, 90))
       step = 0.25
       crystal_gridding = maptbx.crystal_gridding(
         unit_cell = structure.unit_cell(),
         step = step)
       shrink_truncation_radius = 0.0
       solvent_radius = 0.0
       m = around_atoms(
         structure.unit_cell(),
         structure.space_group().order_z(),
         xyzf,
         atmrad,
         crystal_gridding.n_real(),
         solvent_radius,
         shrink_truncation_radius)
       asf.append(m.accessible_surface_fraction)
       csf.append(m.contact_surface_fraction)
       assert m.accessible_surface_fraction == m.contact_surface_fraction
  assert approx_equal(min(asf),max(asf))
#------------------------------------------------------------------------TEST-3
 if(1):
  r=(1.673,0.685,-0.315,-0.649,-1.637)
  asf=[]
  csf=[]
  for x in r:
   for y in r:
     for z in r:
       structure, xyzf, atmrad = structure_init((x,y,z),
                                                "P1",
                                                (5.0, 5.5, 6.0, 70, 80, 100))
       step = 0.1
       crystal_gridding = maptbx.crystal_gridding(
         unit_cell = structure.unit_cell(),
         step = step)
       shrink_truncation_radius = 0.0
       solvent_radius = 0.0
       m = around_atoms(
          structure.unit_cell(),
          structure.space_group().order_z(),
          xyzf,
          atmrad,
          crystal_gridding.n_real(),
          solvent_radius,
          shrink_truncation_radius)
       asf.append(m.accessible_surface_fraction)
       csf.append(m.contact_surface_fraction)
       assert m.accessible_surface_fraction == m.contact_surface_fraction
  assert approx_equal(min(asf),max(asf), 1e-3)
Ejemplo n.º 4
0
def tst2_run(angles, nspacing, af ):
  rad = van_der_waals_radii.vdw.table["C"]
  a = (2.0*rad)*2.0*af;
  pos1=(0.25,0.25,0.25)
  pos2=(0.25+0.9*2.0*rad/a,0.25,0.25)
  solvent_radius1 = rad*0.5
  solvent_radius2 = rad*3.1
  # shrink_truncation_radius = 1.3*solvent_radius2
  shrink_truncation_radius = 0.0
  cell = [a,a,a, angles[0], angles[1], angles[2] ]
  structure1, xyzf1, atmrad1 = structure_init2(pos1,pos2, "P1", cell)
  structure2, xyzf2, atmrad2 = structure_init2(pos1,pos2, "P1", cell)
  step = (1.0/nspacing) * a
  #
  crystal_gridding = maptbx.crystal_gridding(
    unit_cell = structure1.unit_cell(),
    step = step)
  #
  m1 = around_atoms(
    structure1.unit_cell(),
    structure1.space_group().order_z(),
    xyzf1,
    atmrad1,
    crystal_gridding.n_real(),
    solvent_radius1,
    shrink_truncation_radius, explicit_distance=False, debug=True )
  #
  m2 = around_atoms(
    structure2.unit_cell(),
    structure2.space_group().order_z(),
    xyzf2,
    atmrad2,
    crystal_gridding.n_real(),
    solvent_radius2,
    shrink_truncation_radius, explicit_distance=False, debug=True )
  #
  m3 = around_atoms(
    structure1.unit_cell(),
    structure1.space_group().order_z(),
    xyzf1,
    atmrad1,
    crystal_gridding.n_real(),
    solvent_radius1,
    shrink_truncation_radius, explicit_distance=True, debug=True)
  #
  m4 = around_atoms(
    structure2.unit_cell(),
    structure2.space_group().order_z(),
    xyzf2,
    atmrad2,
    crystal_gridding.n_real(),
    solvent_radius2,
    shrink_truncation_radius, explicit_distance=True, debug=True)
  #
  assert m3.n_atom_points == m4.n_atom_points
  mx1 = max(abs(m1.n_atom_points),abs(m2.n_atom_points))
  mx2 = max(abs(m1.n_atom_points),abs(m3.n_atom_points))
  mx3 =  max(abs(m2.n_atom_points),abs(m3.n_atom_points))
  if mx1!=0:
    assert float(abs(m1.n_atom_points - m2.n_atom_points))/float(mx1) < 0.01
  if mx2!=0:
    assert float(abs(m1.n_atom_points - m3.n_atom_points))/float(mx2) < 0.01
  if mx3!=0:
    assert float(abs(m2.n_atom_points - m3.n_atom_points))/float(mx3) < 0.01
Ejemplo n.º 5
0
def exercise_1():
    #------------------------------------------------------------------------TEST-1
    if (1):
        r = (1.67, 0.68, 0.0, 0.5, -0.31, -0.64, -1.63)
        d = 2.0 * van_der_waals_radii.vdw.table["C"]
        a = (d / 2.) * (4. / 3. * math.pi * 2.)**(1. / 3.)
        for x in r:
            for y in r:
                for z in r:
                    structure, xyzf, atmrad = structure_init(
                        (x, y, z), "P1", (a, a, a, 90, 90, 90))
                    step = 0.1
                    crystal_gridding = maptbx.crystal_gridding(
                        unit_cell=structure.unit_cell(), step=step)
                    shrink_truncation_radius = 0.0
                    solvent_radius = 0.0
                    m = around_atoms(structure.unit_cell(),
                                     structure.space_group().order_z(), xyzf,
                                     atmrad, crystal_gridding.n_real(),
                                     solvent_radius, shrink_truncation_radius)
                    assert m.solvent_radius == 0
                    assert m.shrink_truncation_radius == 0
                    assert approx_equal(1. / m.accessible_surface_fraction,
                                        2.0, 1e-2)
                    assert approx_equal(1. / m.contact_surface_fraction, 2.0,
                                        1e-2)
                    assert flex.max(m.data) == 1
                    assert flex.min(m.data) == 0
                    assert m.data.size() == m.data.count(1) + m.data.count(0)
#------------------------------------------------------------------------TEST-2
    if (1):
        r = (-2.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0)
        asf = []
        csf = []
        for x in r:
            for y in r:
                for z in r:
                    structure, xyzf, atmrad = structure_init(
                        (x, y, z), "C2", (5.0, 5.5, 7.0, 90, 80, 90))
                    step = 0.25
                    crystal_gridding = maptbx.crystal_gridding(
                        unit_cell=structure.unit_cell(), step=step)
                    shrink_truncation_radius = 0.0
                    solvent_radius = 0.0
                    m = around_atoms(structure.unit_cell(),
                                     structure.space_group().order_z(), xyzf,
                                     atmrad, crystal_gridding.n_real(),
                                     solvent_radius, shrink_truncation_radius)
                    asf.append(m.accessible_surface_fraction)
                    csf.append(m.contact_surface_fraction)
                    assert m.accessible_surface_fraction == m.contact_surface_fraction
        assert approx_equal(min(asf), max(asf))


#------------------------------------------------------------------------TEST-3
    if (1):
        r = (1.673, 0.685, -0.315, -0.649, -1.637)
        asf = []
        csf = []
        for x in r:
            for y in r:
                for z in r:
                    structure, xyzf, atmrad = structure_init(
                        (x, y, z), "P1", (5.0, 5.5, 6.0, 70, 80, 100))
                    step = 0.1
                    crystal_gridding = maptbx.crystal_gridding(
                        unit_cell=structure.unit_cell(), step=step)
                    shrink_truncation_radius = 0.0
                    solvent_radius = 0.0
                    m = around_atoms(structure.unit_cell(),
                                     structure.space_group().order_z(), xyzf,
                                     atmrad, crystal_gridding.n_real(),
                                     solvent_radius, shrink_truncation_radius)
                    asf.append(m.accessible_surface_fraction)
                    csf.append(m.contact_surface_fraction)
                    assert m.accessible_surface_fraction == m.contact_surface_fraction
        assert approx_equal(min(asf), max(asf), 1e-3)
Ejemplo n.º 6
0
def tst2_run(angles, nspacing, af):
    rad = van_der_waals_radii.vdw.table["C"]
    a = (2.0 * rad) * 2.0 * af
    pos1 = (0.25, 0.25, 0.25)
    pos2 = (0.25 + 0.9 * 2.0 * rad / a, 0.25, 0.25)
    solvent_radius1 = rad * 0.5
    solvent_radius2 = rad * 3.1
    # shrink_truncation_radius = 1.3*solvent_radius2
    shrink_truncation_radius = 0.0
    cell = [a, a, a, angles[0], angles[1], angles[2]]
    structure1, xyzf1, atmrad1 = structure_init2(pos1, pos2, "P1", cell)
    structure2, xyzf2, atmrad2 = structure_init2(pos1, pos2, "P1", cell)
    step = (1.0 / nspacing) * a
    #
    crystal_gridding = maptbx.crystal_gridding(
        unit_cell=structure1.unit_cell(), step=step)
    #
    m1 = around_atoms(structure1.unit_cell(),
                      structure1.space_group().order_z(),
                      xyzf1,
                      atmrad1,
                      crystal_gridding.n_real(),
                      solvent_radius1,
                      shrink_truncation_radius,
                      explicit_distance=False,
                      debug=True)
    #
    m2 = around_atoms(structure2.unit_cell(),
                      structure2.space_group().order_z(),
                      xyzf2,
                      atmrad2,
                      crystal_gridding.n_real(),
                      solvent_radius2,
                      shrink_truncation_radius,
                      explicit_distance=False,
                      debug=True)
    #
    m3 = around_atoms(structure1.unit_cell(),
                      structure1.space_group().order_z(),
                      xyzf1,
                      atmrad1,
                      crystal_gridding.n_real(),
                      solvent_radius1,
                      shrink_truncation_radius,
                      explicit_distance=True,
                      debug=True)
    #
    m4 = around_atoms(structure2.unit_cell(),
                      structure2.space_group().order_z(),
                      xyzf2,
                      atmrad2,
                      crystal_gridding.n_real(),
                      solvent_radius2,
                      shrink_truncation_radius,
                      explicit_distance=True,
                      debug=True)
    #
    assert m3.n_atom_points == m4.n_atom_points
    mx1 = max(abs(m1.n_atom_points), abs(m2.n_atom_points))
    mx2 = max(abs(m1.n_atom_points), abs(m3.n_atom_points))
    mx3 = max(abs(m2.n_atom_points), abs(m3.n_atom_points))
    if mx1 != 0:
        assert float(
            abs(m1.n_atom_points - m2.n_atom_points)) / float(mx1) < 0.01
    if mx2 != 0:
        assert float(
            abs(m1.n_atom_points - m3.n_atom_points)) / float(mx2) < 0.01
    if mx3 != 0:
        assert float(
            abs(m2.n_atom_points - m3.n_atom_points)) / float(mx3) < 0.01