def _grow(self, tolerance=0.2): """ A single grid is iteratively inflated, and the top 20% of neighbouring grid points added until the volume is with the tolerance of the target volume. :param float tolerance: allowable error in volume extraction :return float: threshold """ self.best_island = self._single_grid.common_boundaries( self.best_island) current_num_gp = self.best_island.count_grid() f = 0 while f < 100 and abs( ((self.settings._num_gp - current_num_gp) / self.settings._num_gp )) > tolerance and self.settings._num_gp >= current_num_gp: grown = Grid.grow(self.best_island, self.single_grid) self.best_island = grown current_num_gp = self.best_island.count_grid() print(current_num_gp, 'out of', self.settings._num_gp) f += 1 tmp_best_island = self.best_island * self.single_grid g_vals = tmp_best_island.grid_values() g_vals[::-1].sort() try: threshold = g_vals[self.settings._num_gp] except IndexError: threshold = min(g_vals) # assert abs(((self.settings._num_gp - current_num_gp) / self.settings._num_gp)) < tolerance return threshold
def _grow(self): """ A single grid is iteratively inflated, and the top 20% of neighbouring grid points added until the volume is with the tolerance of the target volume. :param float tolerance: allowable error in volume extraction :return float: threshold """ self.best_island = self._single_grid.common_boundaries( self.best_island) self.second_best_island = self._single_grid.common_boundaries( self.second_best_island) current_num_gp = self.best_island.count_grid() f = 0 for f in range(0, 10): if self.settings._num_gp <= current_num_gp: break grown = Grid.grow(self.best_island, self.second_best_island) self.best_island = self._remove_protein_vol(grown) old_num_gp = current_num_gp current_num_gp = self.best_island.count_grid() print(current_num_gp, 'out of', self.settings._num_gp) growth = current_num_gp - old_num_gp if growth == 0: break tmp_best_island = (self.best_island > 0.5) * (self._single_grid) g_vals = tmp_best_island.grid_values() g_vals[::-1].sort() print(len(g_vals)) print(self.settings._num_gp) try: threshold = g_vals[self.settings._num_gp] except IndexError: threshold = min(g_vals) return threshold