コード例 #1
0
    def determine_extent(numpy_in, tolerance):
        """Reads numpy array, determines the extent of the electron density
        
        Parameters:
          numpy_in -- a numpy array containing grid points
          tolerance -- number of points in a plane with value greater than 1 sigma
        
        Returns:
          a vector of grid indices: (min_u, max_u, min_v, max_v, min_w, max_w)"""

        log_string = ''
        min = clipper.Coord_orth()
        max = clipper.Coord_orth()

        map_mean = numpy.mean(map_numpy)
        map_std = numpy.std(map_numpy)

        mask = map_numpy > map_mean + map_std

        sum_u = sum(sum(mask))
        sum_w = sum(sum(numpy.transpose(mask)))
        sum_v = sum(numpy.transpose(sum(mask)))

        log_string += '\n  >> dumping 1D summaries of the map\'s content:\n\n  >> U:\n %s\n' % sum_u
        log_string += '\n  >> V:\n %s\n' % sum_v
        log_string += '\n  >> W:\n %s\n' % sum_w

        point_list = []

        for idx_u, val_u in enumerate(sum_u):
            if val_u > tolerance:
                point_list.append(idx_u)

        min_u = point_list[0]
        max_u = point_list[-1]

        log_string += '\n  >> First meaningful U: %i ; Last meaningful U: %i' % (
            min_u, max_u)

        point_list = []

        for idx_v, val_v in enumerate(sum_v):
            if val_v > tolerance:
                point_list.append(idx_v)

        min_v = point_list[0]
        max_v = point_list[-1]

        log_string += '\n  >> First meaningful V: %i ; Last meaningful V: %i' % (
            min_v, max_v)

        point_list = []

        for idx_w, val_w in enumerate(sum_w):
            if val_w > tolerance:
                point_list.append(idx_w)

        min_w = point_list[0]
        max_w = point_list[-1]

        log_string += '\n  >> First meaningful W: %i ; Last meaningful W: %i\n' % (
            min_w, max_w)

        extent = [min_u, max_u, min_v, max_v, min_w, max_w]

        return extent, log_string
コード例 #2
0
def atom_kicks(mmol=None, amplitude=0.0, frequency=0.0):

    log_string = "\n  >> clipper_tools: atom_kicks"
    log_string += "\n     amplitude: %f" % amplitude
    log_string += "\n     frequency: %f" % frequency

    xml_root = etree.Element('atom_kicks')
    xml_root.attrib['amplitude'] = str(amplitude)
    xml_root.attrib['frequency'] = str(frequency)

    if mmol is None:
        log_string += "\n     ERROR: no valid molecule object supplied\n\n"
        log_string += "\n  << atom_kicks has finished\n"
        xml_root.attrib['ok'] = 'no'
        return log_string, xml_root

    if amplitude == 0.0 or frequency == 0.0:
        log_string += "\n     ERROR: cannot compute kicks with zero amplitude and/or frequency\n\n"
        log_string += "\n  << atom_kicks has finished\n"
        xml_root.attrib['ok'] = 'no'
        return log_string, xml_root

    if frequency < 0.0 or frequency > 100.0:
        log_string += "\n     ERROR: frequency is not in the (0,100] range\n\n"
        log_string += "\n  << atom_kicks has finished\n"
        xml_root.attrib['ok'] = 'no'
        return log_string, xml_root

    import random

    model = mmol.model()

    kicked = not_kicked = 0

    for chain in model:
        for residue in chain:
            for atom in residue:
                if random.uniform(0.0, 100.0) < frequency:
                    sign = random.choice([-1, 1])
                    x = atom.coord_orth().x() + sign * random.uniform(
                        0.01, amplitude)
                    sign = random.choice([-1, 1])
                    y = atom.coord_orth().y() + sign * random.uniform(
                        0.01, amplitude)
                    sign = random.choice([-1, 1])
                    z = atom.coord_orth().z() + sign * random.uniform(
                        0.01, amplitude)
                    coords = clipper.Coord_orth(x, y, z)
                    atom.set_coord_orth(coords)
                    kicked += 1
                else:
                    not_kicked += 1

    log_string += "\n     %i atoms have been kicked, while %i remain in their original positions" % (
        kicked, not_kicked)
    log_string += "\n     That means %f percent of the atoms have been kicked" % (
        (kicked / (kicked + not_kicked)) * 100.0)

    log_string += "\n  << atom_kicks has finished\n"
    xml_root.attrib['ok'] = 'yes'

    return log_string, xml_root
コード例 #3
0
at = clipper.Atom()
at.set_element("H")
# Do not know why this is necessary.
print clipper.ClipperStringAsString(at.element())

stats = clipper.Map_stats(xmap)
print stats.mean(), stats.min(), stats.max(), stats.std_dev()

# Range is unwrapped memory leak, but Range<double> and Range<float> are OK, but require specialized methods.
# There may be a better way, but this works!
print stats.range_double().max()
print stats.range_double().min()
print stats.range_double().contains(0)
print stats.range_double().contains(100)

c1 = clipper.Coord_orth(1, 2, 3)
c2 = clipper.Coord_orth(10, 10, 10)

c = c1 + c2
cm = -c

print c.x(), c.y(), c.z()
print cm.x(), cm.y(), cm.z()

cif = clipper.CIFfile()
mydata = clipper.HKL_info()

if len(sys.argv) > 2:
    cif.open_read(sys.argv[2])
    cif.import_hkl_info(mydata)
    print dir(mydata)
コード例 #4
0
stats = clipper._clipper.Map_stats(xmap)
print ('Stats from clipper::Map_stats:')
print (stats.mean(), stats.min(),stats.max(),stats.std_dev())

print ('Stats from Xmap.stats:')
print (xmap.mean, xmap.min, xmap.max, xmap.sigma)

# Range is unwrapped memory leak, but Range<double> and Range<float> are OK, but require specialized methods.
# There may be a better way, but this works!
print (stats.range().max())
print (stats.range().min())
print (0 in stats.range())
print (100 in stats.range())

c1 = clipper.Coord_orth([1,2,3])
c2 = clipper.Coord_orth([10,10,10])

c = c1+c2
cm = -c

print c.xyz
print cm.xyz

cif = clipper.CIFfile()
mydata = clipper.HKL_info()

fphi1 = clipper._clipper.HKL_data_F_phi_double(mydata)
fphi2 = clipper._clipper.HKL_data_F_phi_double(mydata)
fphi3 = fphi1.copy()