Ejemplo n.º 1
0
def no_images(labelit_log):

    # 3 images per wedge, maximum of 30 => 1 to 10 wedges.

    beam, lattice, metric, cell, image = rj_parse_labelit_log_file(labelit_log)
    template, directory = rj_get_template_directory(image)
    images = rj_find_matching_images(image)
    phi = rj_get_phi(image)

    if lattice == 'aP':
        raise RuntimeError, 'triclinic lattices useless'

    # right, what I want to do is autoindex with images at 0, 45, 90 or
    # thereabouts (in P1), then do the cell refinement, then score the
    # resulting cell constants

    ai_images = calculate_images_ai(images, phi, 3)

    metrics = []

    for count in range(1, 10):
        result = calculate_images(images, phi, count + 1)

        # first autoindex commands

        commands = [
            'template %s' % template,
            'directory %s' % directory,
            'beam %f %f' % beam]

        commands.append('symm P1')

        for image in ai_images:
            commands.append('autoindex dps refine image %d' % image)

        commands.append('mosaic estimate')
        commands.append('go')

        # the cell refinement commands

        commands.append('postref multi segments 3')

        for pair in result:
            commands.append('process %d %d' % pair)
            commands.append('go')

        output = rj_run_job('ipmosflm-7.0.3', [], commands)

        cell, mosaic = rj_parse_mosflm_cr_log(output)
        result = lattice_symmetry(cell)
        
        l = sort_lattices(result.keys())[-1]
        
        if l != lattice:
            raise RuntimeError, 'cell refinement gave wrong lattice'
        
        metrics.append(result[l]['penalty'])

    return metrics
Ejemplo n.º 2
0
def cr_test(labelit_log):
    
    beam, lattice, metric, cell, image = rj_parse_labelit_log_file(labelit_log)
    lattices, cells = rj_parse_labelit_log_lattices(
        open(labelit_log).readlines())
    template, directory = rj_get_template_directory(image)
    images = rj_find_matching_images(image)
    phi = rj_get_phi(image)

    if lattice == 'aP':
        raise RuntimeError, 'triclinic lattices useless'

    wedges = calculate_images(images, phi)
    
    ai_images = calculate_images_ai(images, phi, 3)

    # run a quick autoindex (or re-read the labelit log file above) to
    # generate the list of possible unit cell etc.

    rmsds_all = { }

    # then loop over these

    for lattice in lattices:
        commands = [
            'template %s' % template,
            'directory %s' % directory,
            'beam %f %f' % beam]

        commands.append('symm %d' % lattice_spacegroup(lattice))
        commands.append('cell %f %f %f %f %f %f' % tuple(cells[lattice]))

        for image in ai_images:
            commands.append('autoindex dps refine image %d' % image)

        commands.append('mosaic estimate')
        commands.append('go')

        # the cell refinement commands

        commands.append('postref multi segments 3')

        for pair in wedges:
            commands.append('process %d %d' % pair)
            commands.append('go')

        for c in commands:
            # print c
            pass

        output = rj_run_job('ipmosflm-7.0.3', [], commands)
        
        images, rmsds = rj_parse_mosflm_cr_log_rmsd(output)

        rmsds_all[lattice] = rmsds

    # and finally calculate the RMSD ratios.

    # break up by lattice, image and cycle

    for lattice in lattices[:-1]:
        print lattice
        values = []
        for cycle in rmsds_all[lattice]:
            if not cycle in rmsds_all['aP']:
                continue
            record = '%3d' % cycle
            for j in range(len(images)):
                record += ' %.3f' % (rmsds_all[lattice][cycle][j] /
                                     rmsds_all['aP'][cycle][j])
                values.append((rmsds_all[lattice][cycle][j] /
                               rmsds_all['aP'][cycle][j]))

            print record

        m, s = meansd(values)
        print ':: %s %.3f %.3f' % (lattice, m, s)
Ejemplo n.º 3
0
def phi_spacing(labelit_log):

    # 3 images per wedge, maximum of 30 => 1 to 10 wedges.

    beam, lattice, metric, cell, image = rj_parse_labelit_log_file(labelit_log)
    template, directory = rj_get_template_directory(image)
    images = rj_find_matching_images(image)
    phi = rj_get_phi(image)

    if lattice == 'aP':
        raise RuntimeError, 'triclinic lattices useless'

    # right, what I want to do is autoindex with images at 0, 45, 90 or
    # thereabouts (in P1), then do the cell refinement, then score the
    # resulting cell constants

    ai_images = calculate_images_ai(images, phi, 3)

    metrics = []
    spacings = []

    phis = [float(j + 1) for j in range(10, 45)]

    image_numbers = []

    for p in phis:
        result = calculate_images(images, phi, p)
        if phi * (result[-1][-1] - result[0][0] + 1) > 90.0:
            continue
        if not result in image_numbers:
            image_numbers.append(result)

    for result in image_numbers:
        # first autoindex commands

        spacing = nint(phi * (result[1][0] - result[0][0]))
        spacings.append(spacing)

        commands = [
            'template %s' % template,
            'directory %s' % directory,
            'beam %f %f' % beam]

        commands.append('symm P1')

        for image in ai_images:
            commands.append('autoindex dps refine image %d' % image)

        commands.append('mosaic estimate')
        commands.append('go')

        # the cell refinement commands

        commands.append('postref multi segments 3')

        for pair in result:
            commands.append('process %d %d' % pair)
            commands.append('go')

        output = rj_run_job('ipmosflm-7.0.3', [], commands)

        try:
            cell, mosaic = rj_parse_mosflm_cr_log(output)
        except RuntimeError, e:
            for record in output:
                print record[:-1]
            raise e
        result = lattice_symmetry(cell)
        
        l = sort_lattices(result.keys())[-1]
        
        if l != lattice:
            raise RuntimeError, 'cell refinement gave wrong lattice'
        
        metrics.append(result[l]['penalty'])