From: Ralf W. Grosse-K. <rw...@us...> - 2006-06-03 03:54:09
|
Update of /cvsroot/cctbx/cctbx/cctbx/maptbx In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv22937/cctbx/maptbx Modified Files: __init__.py Log Message: crystal.site_cluster_analysis integrated into maptbx.peak_cluster_analysis; new site_cluster_analysis.discard_last(), insert_fixed_site_frac(), distinction between min_cross_distance and min_self_distance Index: __init__.py =================================================================== RCS file: /cvsroot/cctbx/cctbx/cctbx/maptbx/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** __init__.py 12 Aug 2005 08:55:01 -0000 1.4 --- __init__.py 3 Jun 2006 03:54:04 -0000 1.5 *************** *** 11,15 **** from scitbx.python_utils import dicts from libtbx import adopt_init_args ! import sys def value_at_closest_grid_point(map, x_frac): --- 11,18 ---- from scitbx.python_utils import dicts from libtbx import adopt_init_args ! import sys, os ! ! debug_peak_cluster_analysis = os.environ.get( ! "CCTBX_MAPTBX_DEBUG_PEAK_CLUSTER_ANALYSIS", "") def value_at_closest_grid_point(map, x_frac): *************** *** 279,282 **** --- 282,299 ---- else: self._is_processed = None + if ( effective_resolution is not None + or debug_peak_cluster_analysis == "use_old"): + self._site_cluster_analysis = None + self.next = self.next_with_effective_resolution + self.all = self.all_with_effective_resolution + else: + self._site_cluster_analysis = \ + self._special_position_settings.site_cluster_analysis( + min_cross_distance=self._min_cross_distance, + min_self_distance + =self._special_position_settings.min_distance_sym_equiv(), + general_positions_only=self._general_positions_only) + self.next = self.next_site_cluster_analysis + self.all = self.all_site_cluster_analysis self._peak_list_indices = flex.size_t() self._peak_list_index = 0 *************** *** 309,312 **** --- 326,332 ---- return self._max_clusters + def site_cluster_analysis(self): + return self._site_cluster_analysis + def peak_list_indices(self): return self._peak_list_indices *************** *** 327,330 **** --- 347,352 ---- def append_fixed_site(self, site, height=0): + if (self._site_cluster_analysis is not None): + self._site_cluster_analysis.insert_fixed_site_frac(original_site=site) self._fixed_site_indices.append(self._sites.size()) self._sites.append(site) *************** *** 332,336 **** self._peak_list_indices.append(self._peak_list.size()) ! def next(self): while 1: peak_list_index = self._peak_list_index --- 354,397 ---- self._peak_list_indices.append(self._peak_list.size()) ! def discard_last(self): ! assert self._peak_list_indices.size() > 0 ! if (self._site_cluster_analysis is not None): ! self._site_cluster_analysis.discard_last() ! self._peak_list_indices.pop_back() ! self._sites.pop_back() ! self._heights.pop_back() ! ! def next_site_cluster_analysis(self): ! while 1: ! peak_list_index = self._peak_list_index ! if (peak_list_index >= self._peak_list.size()): return None ! self._peak_list_index += 1 ! site_symmetry = self._special_position_settings.site_symmetry( ! site=self._peak_list.sites()[peak_list_index]) ! site = site_symmetry.exact_site() ! if (not self._site_cluster_analysis.process_site_frac( ! original_site=site, ! site_symmetry_ops=site_symmetry)): continue ! height = self._peak_list.heights()[peak_list_index] ! self._peak_list_indices.append(peak_list_index) ! self._sites.append(site) ! self._heights.append(height) ! return cluster_site_info( ! peak_list_index=peak_list_index, ! grid_index=self._peak_list.grid_indices(peak_list_index), ! grid_height=self._peak_list.grid_heights()[peak_list_index], ! site=site, ! height=height) ! ! def all_site_cluster_analysis(self, max_clusters=None): ! if (max_clusters is None): ! max_clusters = self._max_clusters ! assert max_clusters is not None ! while 1: ! if (self._sites.size() >= max_clusters): break ! if (self.next_site_cluster_analysis() is None): break ! return self ! ! def next_with_effective_resolution(self): while 1: peak_list_index = self._peak_list_index *************** *** 351,354 **** --- 412,421 ---- equiv_sites = sgtbx.sym_equiv_sites(site_symmetry) keep = True + if (self._sites.size() > 50): + import warnings + warnings.warn( + message="This function should not be used for" + " processing a large number of peaks.", + category=RuntimeWarning) for s in self._sites: dist = sgtbx.min_sym_equiv_distance_info(equiv_sites, s).dist() *************** *** 402,406 **** return frac(sum_w_sites / sum_w), height ! def all(self, max_clusters=None): if (max_clusters is None): max_clusters = self._max_clusters --- 469,473 ---- return frac(sum_w_sites / sum_w), height ! def all_with_effective_resolution(self, max_clusters=None): if (max_clusters is None): max_clusters = self._max_clusters *************** *** 408,417 **** while 1: if (self._sites.size() >= max_clusters): break ! if (self.next() is None): break return self - - def discard_last(self): - assert self._peak_list_indices.size() > 0 - self._peak_list_indices.pop_back() - self._sites.pop_back() - self._heights.pop_back() --- 475,478 ---- while 1: if (self._sites.size() >= max_clusters): break ! if (self.next_with_effective_resolution() is None): break return self |