コード例 #1
0
ファイル: __init__.py プロジェクト: kek-pf-mx/dials
 def minimize_divide_clustering(self):
     x = self.coords_reduced[:, :1].as_1d()
     y = self.coords_reduced[:, 1:2].as_1d()
     from cctbx.merging.brehm_diederichs import minimize_divide
     selection = minimize_divide(x, y).plus_minus()
     self.cluster_labels = flex.int(x.size(), 0)
     self.cluster_labels.set_selected(selection, 1)
コード例 #2
0
    def _minimize_divide_clustering(self):
        assert self.params.cluster.n_clusters in (2, Auto)
        x = self.coords_reduced[:, :1].as_1d()
        y = self.coords_reduced[:, 1:2].as_1d()
        from cctbx.merging.brehm_diederichs import minimize_divide

        selection = minimize_divide(x, y).plus_minus()
        cluster_labels = flex.int(x.size(), 0)
        cluster_labels.set_selected(selection, 1)
        return cluster_labels
コード例 #3
0
def alignment_by_embedding(reports, plot=False):
    #from IPython import embed; embed()
    """reports is a list of tranch results, one list item per composite tranch
     Each item is a list, over cosets, e.g. two elements for a merohedral twinning op
     Each element is itself a list of uuid's assigned to that coset.
  """
    n_tranches = len(reports)
    reports = copy.deepcopy(reports)
    # will now amend the reports-list so that it has a new section for each permutation of cosets.

    for itranch in range(len(reports)):
        cache_permutations = list(permutations(reports[itranch]))
        reports.append(cache_permutations[1])
        # will have to rewrite this code if there is more that one symmetry operator XXX FIXME

    rij, wij = get_proposal_score(reports)
    mt = flex.mersenne_twister(seed=0)
    #from IPython import embed; embed()
    NN = len(reports)
    xcoord = mt.random_double(size=NN)
    ycoord = mt.random_double(size=NN)
    if plot:
        from matplotlib import pyplot as plt
        plt.plot(xcoord, ycoord, "g.")
        plt.show()

    from cctbx.merging.brehm_diederichs import minimize as mz, minimize_divide
    M = mz(xcoord, ycoord, rij, wij, verbose=True)
    coord_x = M.x[0:NN]
    coord_y = M.x[NN:2 * NN]
    P = minimize_divide(coord_x, coord_y)
    selection = P.plus_minus()
    if plot:
        plt.plot(coord_x.select(selection),
                 coord_y.select(selection),
                 "r.",
                 markersize=2.)
        plt.plot(coord_x.select(~selection),
                 coord_y.select(~selection),
                 "k.",
                 markersize=3.)
        plt.show()

    print(list(selection))
    reformed_reports = [[] for i in range(n_tranches)
                        ]  # output should have as many reports as tranches
    n_permutations = NN // n_tranches
    for iflag, select_flag in enumerate(selection):
        if select_flag:
            itranch = iflag % n_tranches
            #print( itranch, iflag, n_permutations)
            reformed_reports[itranch] = reports[iflag]

    assert [] not in reformed_reports  # all tranches must have coset assignments
    return reformed_reports