예제 #1
0
def find_unconnected_xds_files(xds_files, min_ios=3, d_min=None):
    import networkx as nx
    from yamtbx.dataproc.xds import xds_ascii
    from yamtbx.dataproc.xds import integrate_hkl_as_flex

    if len(xds_files) < 2:
        return []

    G = nx.Graph()

    arrays = []
    for f in xds_files:
        if xds_ascii.is_xds_ascii(f):
            a = xds_ascii.XDS_ASCII(f, i_only=True).i_obs().resolution_filter(d_min=d_min)
        elif integrate_hkl_as_flex.is_integrate_hkl(f):
            a = integrate_hkl_as_flex.reader(f, ["IOBS", "SIGMA"]).i_obs().resolution_filter(d_min=d_min)
        else:
            raise "Never reaches here"

        a = a.select(a.sigmas() > 0)
        a = a.merge_equivalents(use_internal_variance=False).array()
        arrays.append(a.select(a.data() / a.sigmas() >= min_ios))

    for i in xrange(len(arrays) - 1):
        for j in xrange(i + 1, len(arrays)):
            matchs = arrays[i].match_indices(other=arrays[j], assert_is_similar_symmetry=False)
            if matchs.pairs().size() >= 10:
                G.add_edge(i, j)
                print "edge", i, j

    ccomps = map(lambda x: x, nx.connected_components(G))
    print "DEBUG:: Connected components=", ccomps
    keep_idxes = ccomps[0]
    remove_idxes = filter(lambda x: x not in keep_idxes, xrange(len(xds_files)))
    return remove_idxes
예제 #2
0
def load_xds_data_only_indices(xac_files, d_min=None):
    miller_sets = {}
    for f in xac_files:
        if xds_ascii.is_xds_ascii(f):
            print "Loading", f
            ms = xds_ascii.XDS_ASCII(f, i_only=True).as_miller_set()
            miller_sets[f] = ms.resolution_filter(d_min=d_min)
        elif integrate_hkl_as_flex.is_integrate_hkl(f):
            print "Sorry, skipping", f
        else:
            print "Skipping unrecognized:", f
    return miller_sets
예제 #3
0
파일: blend.py 프로젝트: keitaroyam/yamtbx
def load_xds_data_only_indices(xac_files, d_min=None):
    miller_sets = {}
    for f in xac_files:
        if xds_ascii.is_xds_ascii(f):
            print "Loading", f
            ms = xds_ascii.XDS_ASCII(f, i_only=True).as_miller_set()
            miller_sets[f] = ms.resolution_filter(d_min=d_min)
        elif integrate_hkl_as_flex.is_integrate_hkl(f):
            print "Sorry, skipping", f
        else:
            print "Skipping unrecognized:", f
    return miller_sets
예제 #4
0
파일: blend.py 프로젝트: nsls-ii-mx/yamtbx
def load_xds_data_only_indices(xac_files, d_min=None):
    miller_sets = {}
    for f in xac_files:
        try:
            indices = []
            miller_arrays = any_reflection_file(f).as_miller_arrays()
            symm = miller_arrays[0].crystal_symmetry()
            ms =  miller.set(crystal_symmetry=symm, indices=miller_arrays[0].indices(),anomalous_flag=False)
            miller_sets[f] = ms.resolution_filter(d_min=d_min)
        except:
            if xds_ascii.is_xds_ascii(f):
                print "Loading", f
                ms = xds_ascii.XDS_ASCII(f, i_only=True).as_miller_set()
                miller_sets[f] = ms.resolution_filter(d_min=d_min)
            elif integrate_hkl_as_flex.is_integrate_hkl(f):
                print "Sorry, skipping", f
            else:
                print "Skipping unrecognized:", f
    return miller_sets
예제 #5
0
def find_unconnected_xds_files(xds_files, min_ios=3, d_min=None):
    import networkx as nx
    from yamtbx.dataproc.xds import xds_ascii
    from yamtbx.dataproc.xds import integrate_hkl_as_flex

    if len(xds_files) < 2:
        return []

    G = nx.Graph()

    arrays = []
    for f in xds_files:
        if xds_ascii.is_xds_ascii(f):
            a = xds_ascii.XDS_ASCII(
                f, i_only=True).i_obs().resolution_filter(d_min=d_min)
        elif integrate_hkl_as_flex.is_integrate_hkl(f):
            a = integrate_hkl_as_flex.reader(
                f, ["IOBS", "SIGMA"]).i_obs().resolution_filter(d_min=d_min)
        else:
            raise "Never reaches here"

        a = a.select(a.sigmas() > 0)
        a = a.merge_equivalents(use_internal_variance=False).array()
        arrays.append(a.select(a.data() / a.sigmas() >= min_ios))

    for i in xrange(len(arrays) - 1):
        for j in xrange(i + 1, len(arrays)):
            matchs = arrays[i].match_indices(other=arrays[j],
                                             assert_is_similar_symmetry=False)
            if matchs.pairs().size() >= 10:
                G.add_edge(i, j)
                print "edge", i, j

    ccomps = map(lambda x: x, nx.connected_components(G))
    print "DEBUG:: Connected components=", ccomps
    keep_idxes = ccomps[0]
    remove_idxes = filter(lambda x: x not in keep_idxes,
                          xrange(len(xds_files)))
    return remove_idxes
                an, bn = params.variance_model
                i_obs = i_obs.customized_copy(sigmas = flex.sqrt(flex.abs(an * (i_obs.sigmas()**2/ao + (bn-bo)*flex.pow2(i_obs.data())))))
        else:
            ihkl = integrate_hkl_as_flex.reader(f, read_columns=("IOBS","SIGMA"))
            i_obs = ihkl.i_obs().resolution_filter(d_min=params.d_min, d_max=params.d_max)

            if params.fix_variance_model:
                a, b = params.variance_model
                i_obs = i_obs.customized_copy(sigmas = flex.sqrt(a * (i_obs.sigmas()**2 + b*flex.pow2(i_obs.data()))))

        cutoffs = eval_resolution(i_obs, params.n_bins, params.cut_ios)

        print "%s %s" % (f, " ".join(map(lambda x: "%.2f"%x, cutoffs)))
        

if __name__ == "__main__":
    import sys
    cmdline = iotbx.phil.process_command_line(args=sys.argv[1:],
                                              master_string=master_params_str)
    params = cmdline.work.extract()
    args = cmdline.remaining_args

    files = filter(lambda x: integrate_hkl_as_flex.is_integrate_hkl(x) or xds_ascii.is_xds_ascii(x), args)
    for arg in args:
        if arg.endswith(".lst"):
            for l in open(arg):
                if "#" in l: l = l[:l.index("#")]
                files.append(l.strip())

    run(files, params)