Пример #1
0
    def get_top_solutions(self, ai, input_directions, size, cutoff_divisor):
        # size was 30 in the Rossmann DPS paper
        kval_cutoff = ai.getXyzSize() / cutoff_divisor

        hemisphere_solutions = flex.Direction()
        hemisphere_solutions.reserve(size)

        for i in range(len(input_directions)):
            sampled_direction = ai.fft_result(input_directions[i])
            if sampled_direction.kval > kval_cutoff:
                hemisphere_solutions.append(sampled_direction)

        if (hemisphere_solutions.size() < 3):
            return hemisphere_solutions
        kvals = flex.double([
            hemisphere_solutions[x].kval
            for x in range(len(hemisphere_solutions))
        ])

        perm = flex.sort_permutation(kvals, True)

        #  conventional algorithm; just take the top scoring hits.
        #  use this for quick_grid, when it is known ahead of time
        #  that many (hundreds) of directions will be retained

        hemisphere_solutions_sort = flex.Direction(
            [hemisphere_solutions[p] for p in perm[0:min(size, len(perm))]])

        return hemisphere_solutions_sort
Пример #2
0
    def find_basis_vectors(self, reciprocal_lattice_vectors):
        """Find a list of likely basis vectors.

        Args:
            reciprocal_lattice_vectors (scitbx.array_family.flex.vec3_double):
                The list of reciprocal lattice vectors to search for periodicity.
        """
        used_in_indexing = flex.bool(reciprocal_lattice_vectors.size(), True)
        logger.info("Indexing from %i reflections" % used_in_indexing.count(True))

        vectors, weights = self.score_vectors(reciprocal_lattice_vectors)

        perm = flex.sort_permutation(weights, reverse=True)
        vectors = vectors.select(perm)
        weights = weights.select(perm)

        groups = group_vectors(vectors, weights, max_groups=self._params.max_vectors)
        unique_vectors = []
        unique_weights = []
        for g in groups:
            idx = flex.max_index(flex.double(g.weights))
            unique_vectors.append(g.vectors[idx])
            unique_weights.append(g.weights[idx])

        logger.info("Number of unique vectors: %i" % len(unique_vectors))

        for v, w in zip(unique_vectors, unique_weights):
            logger.debug("%s %s %s" % (w, v.length(), str(v.elems)))

        return unique_vectors, used_in_indexing
Пример #3
0
  def get_top_solutions(self,ai,input_directions,size,cutoff_divisor):
    # size was 30 in the Rossmann DPS paper
    kval_cutoff = ai.getXyzSize()/cutoff_divisor;

    hemisphere_solutions = flex.Direction();
    hemisphere_solutions.reserve(size);

    for i in xrange(len(input_directions)):
      sampled_direction = ai.fft_result(input_directions[i])
      if sampled_direction.kval > kval_cutoff:
        hemisphere_solutions.append(sampled_direction)

    if (hemisphere_solutions.size()<3):
      return hemisphere_solutions
    kvals = flex.double([
  hemisphere_solutions[x].kval for x in xrange(len(hemisphere_solutions))])

    perm = flex.sort_permutation(kvals,True)

    #  conventional algorithm; just take the top scoring hits.
    #  use this for quick_grid, when it is known ahead of time
    #  that many (hundreds) of directions will be retained

    hemisphere_solutions_sort = flex.Direction(
        [hemisphere_solutions[p] for p in perm[0:min(size,len(perm))]])

    return hemisphere_solutions_sort;
Пример #4
0
    def get_top_solutions(self, ai, input_directions, size, cutoff_divisor,
                          grid):

        kval_cutoff = ai.getXyzSize() / cutoff_divisor

        hemisphere_solutions = flex.Direction()
        hemisphere_solutions.reserve(size)
        #print "# of input directions", len(input_directions)
        for i in range(len(input_directions)):
            D = sampled_direction = ai.fft_result(input_directions[i])

            #hardcoded parameter in for silicon example.  Not sure at this point how
            #robust the algorithm is when this value is relaxed.

            if D.real < self.max_cell and sampled_direction.kval > kval_cutoff:
                if diagnostic: directional_show(D, "%5d" % i)
                hemisphere_solutions.append(sampled_direction)
        if (hemisphere_solutions.size() < 3):
            return hemisphere_solutions
        kvals = flex.double([
            hemisphere_solutions[x].kval
            for x in range(len(hemisphere_solutions))
        ])

        perm = flex.sort_permutation(kvals, True)

        #  need to be more clever than just taking the top 30.
        #  one huge cluster around a strong basis direction could dominate the
        #  whole hemisphere map, preventing the discovery of three basis vectors

        perm_idx = 0
        unique_clusters = 0
        hemisphere_solutions_sort = flex.Direction()
        while perm_idx < len(perm) and \
              unique_clusters < size:
            test_item = hemisphere_solutions[perm[perm_idx]]
            direction_ok = True
            for list_item in hemisphere_solutions_sort:
                distance = math.sqrt(
                    math.pow(list_item.dvec[0] - test_item.dvec[0], 2) +
                    math.pow(list_item.dvec[1] - test_item.dvec[1], 2) +
                    math.pow(list_item.dvec[2] - test_item.dvec[2], 2))
                if distance < 0.087:  #i.e., 5 degrees radius for clustering analysis
                    direction_ok = False
                    break
            if direction_ok:
                unique_clusters += 1
            hemisphere_solutions_sort.append(test_item)
            perm_idx += 1

        return hemisphere_solutions_sort
Пример #5
0
    def get_top_solutions(self, ai, input_directions, size, cutoff_divisor,
                          grid):
        # size was 30 in the Rossmann DPS paper

        kval_cutoff = ai.getXyzSize() / cutoff_divisor

        hemisphere_solutions = flex.Direction()
        hemisphere_solutions.reserve(size)
        for i in range(len(input_directions)):
            D = sampled_direction = ai.fft_result(input_directions[i])

            if D.real < self.max_cell_input and sampled_direction.kval > kval_cutoff:
                #directional_show(D, "ddd %5d"%i)
                hemisphere_solutions.append(sampled_direction)

        if (hemisphere_solutions.size() < 3):
            return hemisphere_solutions
        kvals = flex.double([
            hemisphere_solutions[x].kval
            for x in range(len(hemisphere_solutions))
        ])

        perm = flex.sort_permutation(kvals, True)

        #  need to be more clever than just taking the top 30.
        #  one huge cluster around a strong basis direction could dominate the
        #  whole hemisphere map, preventing the discovery of three basis vectors

        perm_idx = 0
        unique_clusters = 0
        hemisphere_solutions_sort = flex.Direction()
        while perm_idx < len(perm) and \
              unique_clusters < size:
            test_item = hemisphere_solutions[perm[perm_idx]]
            direction_ok = True
            for list_item in hemisphere_solutions_sort:
                distance = math.sqrt(
                    math.pow(list_item.dvec[0] - test_item.dvec[0], 2) +
                    math.pow(list_item.dvec[1] - test_item.dvec[1], 2) +
                    math.pow(list_item.dvec[2] - test_item.dvec[2], 2))
                if distance < 0.087:  #i.e., 5 degrees
                    direction_ok = False
                    break
            if direction_ok:
                unique_clusters += 1
                hemisphere_solutions_sort.append(test_item)
            perm_idx += 1

        return hemisphere_solutions_sort
Пример #6
0
  def get_top_solutions(self,ai,input_directions,size,cutoff_divisor,grid):

    kval_cutoff = ai.getXyzSize()/cutoff_divisor;

    hemisphere_solutions = flex.Direction();
    hemisphere_solutions.reserve(size);
    #print "# of input directions", len(input_directions)
    for i in xrange(len(input_directions)):
      D = sampled_direction = ai.fft_result(input_directions[i])

      #hardcoded parameter in for silicon example.  Not sure at this point how
      #robust the algorithm is when this value is relaxed.

      if D.real < self.max_cell and sampled_direction.kval > kval_cutoff:
        if diagnostic:  directional_show(D, "%5d"%i)
        hemisphere_solutions.append(sampled_direction)
    if (hemisphere_solutions.size()<3):
      return hemisphere_solutions
    kvals = flex.double([
  hemisphere_solutions[x].kval for x in xrange(len(hemisphere_solutions))])

    perm = flex.sort_permutation(kvals,True)

    #  need to be more clever than just taking the top 30.
    #  one huge cluster around a strong basis direction could dominate the
    #  whole hemisphere map, preventing the discovery of three basis vectors

    perm_idx = 0
    unique_clusters = 0
    hemisphere_solutions_sort = flex.Direction()
    while perm_idx < len(perm) and \
          unique_clusters < size:
      test_item = hemisphere_solutions[perm[perm_idx]]
      direction_ok = True
      for list_item in hemisphere_solutions_sort:
        distance = math.sqrt(math.pow(list_item.dvec[0]-test_item.dvec[0],2) +
                     math.pow(list_item.dvec[1]-test_item.dvec[1],2) +
                     math.pow(list_item.dvec[2]-test_item.dvec[2],2)
                     )
        if distance < 0.087: #i.e., 5 degrees radius for clustering analysis
           direction_ok=False
           break
      if direction_ok:
        unique_clusters+=1
      hemisphere_solutions_sort.append(test_item)
      perm_idx+=1

    return hemisphere_solutions_sort;
Пример #7
0
  def get_top_solutions(self,ai,input_directions,size,cutoff_divisor,grid):
    # size was 30 in the Rossmann DPS paper

    kval_cutoff = ai.getXyzSize()/cutoff_divisor;

    hemisphere_solutions = flex.Direction();
    hemisphere_solutions.reserve(size);
    for i in xrange(len(input_directions)):
      D = sampled_direction = ai.fft_result(input_directions[i])

      if D.real < self.max_cell_input and sampled_direction.kval > kval_cutoff:
        #directional_show(D, "ddd %5d"%i)
        hemisphere_solutions.append(sampled_direction)

    if (hemisphere_solutions.size()<3):
      return hemisphere_solutions
    kvals = flex.double([
  hemisphere_solutions[x].kval for x in xrange(len(hemisphere_solutions))])

    perm = flex.sort_permutation(kvals,True)

    #  need to be more clever than just taking the top 30.
    #  one huge cluster around a strong basis direction could dominate the
    #  whole hemisphere map, preventing the discovery of three basis vectors

    perm_idx = 0
    unique_clusters = 0
    hemisphere_solutions_sort = flex.Direction()
    while perm_idx < len(perm) and \
          unique_clusters < size:
      test_item = hemisphere_solutions[perm[perm_idx]]
      direction_ok = True
      for list_item in hemisphere_solutions_sort:
        distance = math.sqrt(math.pow(list_item.dvec[0]-test_item.dvec[0],2) +
                     math.pow(list_item.dvec[1]-test_item.dvec[1],2) +
                     math.pow(list_item.dvec[2]-test_item.dvec[2],2)
                     )
        if distance < 0.087: #i.e., 5 degrees
           direction_ok=False
           break
      if direction_ok:
        unique_clusters+=1
      hemisphere_solutions_sort.append(test_item)
      perm_idx+=1

    return hemisphere_solutions_sort;