Example #1
0
def run(param_source, frame_num, wdir, sigmar=None, sigmab=None, need_adx=True, out_prefix=""):
    xparm_str = None

    # Get XPARM.XDS strings from XPARM.XDS, GXPARM.XDS, or INTEGRATE.LP (user-specified)
    try:
        XPARM(param_source)
        xparm_str = open(param_source).read()
    except:
        xparm_str = get_xparm_from_integrate_lp(param_source, frame_num)

    # Check all needed files exist
    if not check_needed_files(xds_files.needed_by_INTEGRATE+("XDS.INP",), wdir):
        return

    xdsinp = os.path.join(wdir, "XDS.INP")

    # 1. Backup XDS.INP, etc. (Make copies; not renaming)
    bk_prefix = make_backup(backup_needed, wdir=wdir)
    for f in xds_files.generated_by_INTEGRATE:
        if os.path.isfile(os.path.join(wdir, f)):
            os.remove(os.path.join(wdir, f))

    open(os.path.join(wdir, "XPARM.XDS"), "w").write(xparm_str)

    made_files = []

    try:
        # 2. Modify XDS.INP
        modify_params = ("JOB", "INTEGRATE"), ("MINPK", "0"), ("DATA_RANGE", "%d %d"%(frame_num,frame_num))
        if sigmar is not None: modify_params += ("REFLECTING_RANGE_E.S.D.", "%.4f"%sigmar), 
        if sigmab is not None: modify_params += ("BEAM_DIVERGENCE_E.S.D.", "%.4f"%sigmab),
            
        modify_xdsinp(xdsinp, modify_params)

        # 3. Run xds
        p = subprocess.Popen("xds", cwd=wdir)
        p.wait()
    
        # 4&5. Rename FRAME_%d.cbf, INTEGRATE_%d.{HKL,LP} and make .adx 
        for f in ("FRAME.cbf", "INTEGRATE.LP", "INTEGRATE.HKL"):
            if not os.path.isfile(os.path.join(wdir, f)):
                continue
            sp = os.path.splitext(f)
            dst = os.path.join(wdir, "%s%s_%.4d%s" % (out_prefix, sp[0], frame_num, sp[1]))
            os.rename(os.path.join(wdir, f), dst)
            made_files.append(dst)

        if need_adx:
            made_files.append(make_adxfile(os.path.join(wdir, "%sINTEGRATE_%.4d.HKL" % (out_prefix, frame_num))))
            
    finally:
        # 6. Revert XDS.INP, etc.
        revert_files(backup_needed, bk_prefix, wdir=wdir)

    return made_files
def run(integrate_lp, frame_num):
    xparm_str = get_xparm_from_integrate_lp(integrate_lp, frame_num)
    open("XPARM.XDS.%.4d"%frame_num, "w").write(xparm_str)
def run(integrate_lp, frame_num):
    xparm_str = get_xparm_from_integrate_lp(integrate_lp, frame_num)
    open("XPARM.XDS.%.4d" % frame_num, "w").write(xparm_str)