Example #1
0
def no_images(xds_inp):

    firstlast, phi, records = rj_parse_idxref_xds_inp(
        open(xds_inp, 'r').readlines())

    images = [j for j in range(firstlast[0], firstlast[1] + 1)]

    # first run with all images, then define the 'correct' lattice
    # as the one which results from this autoindex step.

    xds_inp = open('XDS.INP', 'w')
    for record in records:
        xds_inp.write('%s\n' % record)
    xds_inp.write('SPOT_RANGE= %d %d\n' % firstlast)
    xds_inp.close()
    output = rj_run_job('xds', [], [])
    cell = rj_parse_idxref_lp(open('IDXREF.LP', 'r').readlines())
    result = lattice_symmetry(cell)

    lattice = sort_lattices(result.keys())[-1]
    score = result[lattice]['penalty']

    metrics = []

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

        xds_inp = open('XDS.INP', 'w')
        for record in records:
            xds_inp.write('%s\n' % record)
        for pair in result:
            xds_inp.write('SPOT_RANGE= %d %d\n' % pair)
        xds_inp.close()
        output = rj_run_job('xds', [], [])

        cell = rj_parse_idxref_lp(open('IDXREF.LP', 'r').readlines())
    
        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, score
Example #2
0
def phi_spacing(xds_inp):

    firstlast, phi, records = rj_parse_idxref_xds_inp(
        open(xds_inp, 'r').readlines())

    images = [j for j in range(firstlast[0], firstlast[1] + 1)]

    # first run with all images, then define the 'correct' lattice
    # as the one which results from this autoindex step.

    xds_inp = open('XDS.INP', 'w')
    for record in records:
        xds_inp.write('%s\n' % record)
    xds_inp.write('SPOT_RANGE= %d %d\n' % firstlast)
    xds_inp.close()
    output = rj_run_job('xds', [], [])
    cell = rj_parse_idxref_lp(open('IDXREF.LP', 'r').readlines())
    result = lattice_symmetry(cell)

    lattice = sort_lattices(result.keys())[-1]
    score = result[lattice]['penalty']

    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:

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

        xds_inp = open('XDS.INP', 'w')
        for record in records:
            xds_inp.write('%s\n' % record)
        for pair in result:
            xds_inp.write('SPOT_RANGE= %d %d\n' % pair)
        xds_inp.close()
        output = rj_run_job('xds', [], [])

        cell = rj_parse_idxref_lp(open('IDXREF.LP', 'r').readlines())
    
        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, spacings, score