def main(): parser = OptionParser( usage="usage: python %prog [options] file_name ...") parser.add_option("-t", "--itvc", action="store", metavar="FILE", help="file name for international tables data") parser.add_option("-k", "--kissel", action="store", metavar="DIRECTORY", help="directory name for Kissel data") parser.add_option("-c", "--cross_check", action="store_true", default=0, help="compare two quick_summary.pickle files") (options, args) = parser.parse_args() if (len(args) < 1): parser.print_help() return assert not (options.itvc and options.kissel) if (options.cross): assert len(args) == 2 if (not options.cross): run( gaussian_fit_pickle_file_names=args, itvc_file_name=options.itvc, kissel_dir=options.kissel) else: cross_check(args)
def main(): parser = OptionParser( usage="usage: python %prog [options] file_name_1 file_name_2") (options, args) = parser.parse_args() if (len(args) != 2): parser.print_help() return run(file_names=args)
def setup_parser(): usage = """ elbow.generate_all_chemical_component_restraint_files only_code=NAG """ parser = OptionParser( prog="elbow.generate_all_chemical_component_restraint_files", version=""" up-to-date version """, usage=usage, ) # Input options parser.add_option( "", "--show_defaults", dest="show_defaults", default=False, action="store_true", help="Display defaults", ) parser.add_option( "", "--dry-run", dest="dry_run", default=False, action="store_true", help="Display which residues will be processed", ) if 0: parser.add_option( "", "--verbose", dest="verbose", default=False, action="store_true", help="Verbose output", ) parser.add_option( "", "--silent", dest="silent", default=False, action="store_true", help="No output to screen", ) return parser
def main(): parser = OptionParser(usage="usage: python %prog [options] file_name ...") parser.add_option("-c", "--cutoff", type="float", default=6.05, metavar="FLOAT", help="maximum sin(theta)/lambda") (options, args) = parser.parse_args() if (len(args) < 1): parser.print_help() return cutoff = options.cutoff for file_name in args: tab = read_table(file_name) if (tab.element == "Es"): continue wk = xray_scattering.wk1995(tab.element, True).fetch() sel = tab.x <= cutoff tab_x = tab.x.select(sel) tab_y = tab.y.select(sel) sigmas = flex.double(tab_x.size(), 0.0005) wky = wk.at_x(tab_x) errors_abs = flex.abs(wky - tab_y) fit = scitbx.math.gaussian.fit(tab_x, tab_y, sigmas, wk) errors_rel = fit.significant_relative_errors(1.e-6) print(tab.element, tab.atomic_number, end=' ') print("max error < %.1fA-1 abs, rel: %7.4f %7.4f" % (cutoff, flex.max(errors_abs), flex.max(errors_rel))) for x, y, f, ea, er in zip(tab_x, tab_y, wky, errors_abs, errors_rel): print("%7.4f %7.4f %7.4f %7.4f %7.4f" % (x, y, f, ea, er)) print()
def setup_parser(): parser = OptionParser( prog="phenix.perigee", version=""" up-to-date version """, usage=""" phenix.perigee pdb_file_name=pdb3a37.ent """, ) # Input options parser.add_option("", "--show_defaults", dest="show_defaults", default=False, action="store_true", help="Display defaults", ) return parser
def setup_parser(): parser = OptionParser( prog="phenix.perigee", version=""" up-to-date version """, usage=""" phenix.perigee pdb_file_name=pdb3a37.ent """, ) # Input options parser.add_option( "", "--show_defaults", dest="show_defaults", default=False, action="store_true", help="Display defaults", ) return parser
def main(): parser = OptionParser( usage="usage: python %prog [options] itvc_table kissel_files ...") parser.add_option("-c", "--cutoff", type="float", default=6, metavar="FLOAT", help="maximum sin(theta)/lambda") parser.add_option("-g", "--high_resolution_only", action="store_true", default=0, help="analyze points beyond sin(theta)/lambda=2A-1 only") (options, args) = parser.parse_args() if (len(args) < 2): parser.print_help() return run( args=args, cutoff=options.cutoff, high_resolution_only=options.high_resolution_only)
def main(): parser = OptionParser(usage="usage: python %prog [options] file_name ...") parser.add_option("-c", "--cutoff", type="float", default=6.05, metavar="FLOAT", help="maximum sin(theta)/lambda") (options, args) = parser.parse_args() if len(args) < 1: parser.print_help() return cutoff = options.cutoff for file_name in args: tab = read_table(file_name) if tab.element == "Es": continue wk = xray_scattering.wk1995(tab.element, True).fetch() sel = tab.x <= cutoff tab_x = tab.x.select(sel) tab_y = tab.y.select(sel) sigmas = flex.double(tab_x.size(), 0.0005) wky = wk.at_x(tab_x) errors_abs = flex.abs(wky - tab_y) fit = scitbx.math.gaussian.fit(tab_x, tab_y, sigmas, wk) errors_rel = fit.significant_relative_errors(1.0e-6) print tab.element, tab.atomic_number, print "max error < %.1fA-1 abs, rel: %7.4f %7.4f" % (cutoff, flex.max(errors_abs), flex.max(errors_rel)) for x, y, f, ea, er in zip(tab_x, tab_y, wky, errors_abs, errors_rel): print "%7.4f %7.4f %7.4f %7.4f %7.4f" % (x, y, f, ea, er) print
def setup_parser(): usage=""" elbow.generate_all_chemical_component_restraint_files only_code=NAG """ parser = OptionParser( prog="elbow.generate_all_chemical_component_restraint_files", version=""" up-to-date version """, usage=usage, ) # Input options parser.add_option("", "--show_defaults", dest="show_defaults", default=False, action="store_true", help="Display defaults", ) parser.add_option("", "--dry-run", dest="dry_run", default=False, action="store_true", help="Display which residues will be processed", ) if 0: parser.add_option("", "--verbose", dest="verbose", default=False, action="store_true", help="Verbose output", ) parser.add_option("", "--silent", dest="silent", default=False, action="store_true", help="No output to screen", ) return parser
def run(http_server_name=None, html_subdir="asu_gallery"): parser = OptionParser( usage="usage: python jv_asu.py [options] [numbers...]") parser.add_option("-s", "--server", action="store", type="string", help="network name of http server", metavar="NAME") parser.add_option("-p", "--plane_group", action="store_true") options, args = parser.parse_args() if (options.server is not None): http_server_name = options.server if (not os.path.isdir(html_subdir)): os.makedirs(html_subdir) jv_index.write_html(open("%s/index.html" % html_subdir, "w")) guide_to_notation.write_html( open("%s/guide_to_notation.html" % html_subdir, "w")) if (len(args) == 0): if (options.plane_group): args = ["1-17"] else: args = ["1-230"] for arg in args: numbers = [int(n) for n in arg.split('-')] assert len(numbers) in (1, 2) if (len(numbers) == 1): numbers *= 2 for group_type_number in xrange(numbers[0], numbers[1] + 1): if (options.plane_group): print "Plane group number:", group_type_number from cctbx.sgtbx.direct_space_asu import plane_group_reference_table asu = plane_group_reference_table.get_asu(group_type_number) group_type_number *= -1 else: print "Space group number:", group_type_number asu = reference_table.get_asu(group_type_number) for colored_grid_points in [None, []]: asu_as_jvx(group_type_number=group_type_number, asu=asu, colored_grid_points=colored_grid_points, http_server_name=http_server_name, html_subdir=html_subdir)
def run(http_server_name=None, html_subdir="asu_gallery"): parser = OptionParser(usage="usage: python jv_asu.py [options] [numbers...]") parser.add_option( "-s", "--server", action="store", type="string", help="network name of http server", metavar="NAME" ) parser.add_option("-p", "--plane_group", action="store_true") options, args = parser.parse_args() if options.server is not None: http_server_name = options.server if not os.path.isdir(html_subdir): os.makedirs(html_subdir) jv_index.write_html(open("%s/index.html" % html_subdir, "w")) guide_to_notation.write_html(open("%s/guide_to_notation.html" % html_subdir, "w")) if len(args) == 0: if options.plane_group: args = ["1-17"] else: args = ["1-230"] for arg in args: numbers = [int(n) for n in arg.split("-")] assert len(numbers) in (1, 2) if len(numbers) == 1: numbers *= 2 for group_type_number in xrange(numbers[0], numbers[1] + 1): if options.plane_group: print "Plane group number:", group_type_number from cctbx.sgtbx.direct_space_asu import plane_group_reference_table asu = plane_group_reference_table.get_asu(group_type_number) group_type_number *= -1 else: print "Space group number:", group_type_number asu = reference_table.get_asu(group_type_number) for colored_grid_points in [None, []]: asu_as_jvx( group_type_number=group_type_number, asu=asu, colored_grid_points=colored_grid_points, http_server_name=http_server_name, html_subdir=html_subdir, )
def main(): parser = OptionParser( usage="usage: python %prog [options]" +" itvc_table all_fits_six_terms.pickle" +" all_fits_decremental.pickle all_fits_incremental.pickle") (options, args) = parser.parse_args() if (len(args) != 4): parser.print_help() return itvc_tab = itvc_section61_io.read_table6111(args[0]) six_term_fits = easy_pickle.load(args[1]) fits = [] for file_name in args[2:]: fits.append(easy_pickle.load(file_name)) for label,fit_group in fits[-1].all.items(): for fit in fit_group: reset_max_error(itvc_tab.entries[label], fit) best_fits = {} n_less = 0 n_greater = 0 n_equal = 0 n_less_list = [0] * 10 n_greater_list = [0] * 10 n_equal_list = [0] * 10 for label in expected_labels(kissel_dir=None): fit_group_0 = fits[0].all.get(label, None) fit_group_1 = fits[1].all.get(label, None) if (fit_group_0 is None and fit_group_1 is None): best_fits[label] = None continue if (fit_group_0 is None): best_fits[label] = fit_group_0 continue if (fit_group_1 is None): best_fits[label] = fit_group_1 continue best_group = [] all_n_terms = {} n_terms_dicts = [] for fit_group in [fit_group_0, fit_group_1]: n_terms_dict = {} for fit in fit_group: n_terms_dict[fit.n_terms()] = fit n_terms_dicts.append(n_terms_dict) all_n_terms.update(n_terms_dicts[-1]) all_n_terms = all_n_terms.keys() all_n_terms.sort() for n_terms in all_n_terms: fit_0 = n_terms_dicts[0].get(n_terms, None) fit_1 = n_terms_dicts[1].get(n_terms, None) if (fit_0 is None): best_group.append(fit_1) continue if (fit_1 is None): best_group.append(fit_0) continue if (fit_0.stol < fit_1.stol): best_group.append(fit_1) status = "less" n_less += 1 n_less_list[n_terms] += 1 elif (fit_0.stol > fit_1.stol): best_group.append(fit_0) status = "greater" n_greater += 1 n_greater_list[n_terms] += 1 else: best_group.append(pick_nicest_fit(fit_0, fit_1)) status = "equal" n_equal += 1 n_equal_list[n_terms] += 1 print "%-4s n_terms=%d %4.2f %4.2f %s" % ( label, n_terms, fit_0.stol, fit_1.stol, status) best_fits[label] = best_group print "n_less:", n_less print "n_greater:", n_greater print "n_equal:", n_equal print "total:", n_less + n_greater + n_equal n_terms = -1 for n_less,n_greater,n_equal in zip(n_less_list,n_greater_list,n_equal_list): n_terms += 1 if (n_less == 0 and n_greater == 0 and n_equal == 0): continue print "n_terms:", n_terms print " n_less:", n_less print " n_greater:", n_greater print " n_equal:", n_equal print " total:", n_less + n_greater + n_equal print for label in expected_labels(kissel_dir=None): if (best_fits[label] is None): print "# Warning: Missing scattering_type:", label print print "Best fits:" print for label in expected_labels(kissel_dir=None): fit_group = best_fits[label] if (fit_group is None): continue print "scattering_type:", label assert len(six_term_fits.all[label]) == 1 assert six_term_fits.all[label][0].n_terms() == 6 fit_group.append(six_term_fits.all[label][0]) reset_max_error(itvc_tab.entries[label], fit_group[-1]) trimmed_fit_group =[] prev_fit = None for fit in fit_group: if (prev_fit is None or fit.stol > prev_fit.stol or (fit.stol == prev_fit.stol and fit.max_error < prev_fit.max_error)): trimmed_fit_group.append(fit) fit.show() prev_fit = fit else: print "# skipped: %s, n_terms: %d, stol: %.2f, max_error: %.4f" % ( label, fit.n_terms(), fit.stol, fit.max_error) best_fits[label] = trimmed_fit_group print easy_pickle.dump("best_fits.pickle", best_fits)
def main(): parser = OptionParser(usage="usage: python %prog [options] file_name ...") parser.add_option("-t", "--itvc", action="store", metavar="FILE", help="file name for international tables data") parser.add_option("-k", "--kissel", action="store", metavar="DIRECTORY", help="directory name for Kissel data") parser.add_option("-c", "--cross_check", action="store_true", default=0, help="compare two quick_summary.pickle files") (options, args) = parser.parse_args() if (len(args) < 1): parser.print_help() return assert not (options.itvc and options.kissel) if (options.cross): assert len(args) == 2 if (not options.cross): run(gaussian_fit_pickle_file_names=args, itvc_file_name=options.itvc, kissel_dir=options.kissel) else: cross_check(args)
def main(): parser = OptionParser( usage="usage: python %prog file_name [n_chunks,i_chunk] [scatterer...]" ) parser.add_option("-v", "--verbose", action="store_true", default=0, help="show comparison table for each element") parser.add_option("-c", "--cutoff", type="float", default=6, metavar="FLOAT", help="maximum sin(theta)/lambda") parser.add_option("-q", "--quick", action="store_true", default=0, help="quick mode for debugging") parser.add_option("-n", "--max_n_terms", type="int", default=5, metavar="INT", help="maximum number of Gaussian terms") parser.add_option("-e", "--max_max_error", type="float", default=0.01, metavar="FLOAT", help="max acceptable max_error") parser.add_option("-s", "--six_term", action="store_true", default=0, help="fit six-term Gaussians using Golay based starts") parser.add_option("-z", "--zig_zag", action="store_true", default=0, help="zig-zag fits starting from six-term Gaussians") parser.add_option("-r", "--full_fits", action="store", help="pickled six-term Gaussian fits") (options, args) = parser.parse_args() if (len(args) < 1): parser.print_help() return assert [options.six_term, options.zig_zag, options.full_fits ].count(True) < 2 if (options.full_fits is not None): full_fits = easy_pickle.load(options.full_fits) else: full_fits = None params = cctbx.eltbx.gaussian_fit.fit_parameters( max_n_terms=options.max_n_terms, max_max_error=options.max_max_error) if (options.quick): params = params.quick() run_and_time(file_name=args[0], args=args[1:], cutoff=options.cutoff, params=params, zig_zag=options.zig_zag, six_term=options.six_term, full_fits=full_fits, verbose=options.verbose)
def main(): parser = OptionParser( usage="usage: python %prog file_name [n_chunks,i_chunk] [scatterer...]") parser.add_option("-v", "--verbose", action="store_true", default=0, help="show comparison table for each element") parser.add_option("-c", "--cutoff", type="float", default=6, metavar="FLOAT", help="maximum sin(theta)/lambda") parser.add_option("-q", "--quick", action="store_true", default=0, help="quick mode for debugging") parser.add_option("-n", "--max_n_terms", type="int", default=5, metavar="INT", help="maximum number of Gaussian terms") parser.add_option("-e", "--max_max_error", type="float", default=0.01, metavar="FLOAT", help="max acceptable max_error") parser.add_option("-s", "--six_term", action="store_true", default=0, help="fit six-term Gaussians using Golay based starts") parser.add_option("-z", "--zig_zag", action="store_true", default=0, help="zig-zag fits starting from six-term Gaussians") parser.add_option("-r", "--full_fits", action="store", help="pickled six-term Gaussian fits") (options, args) = parser.parse_args() if (len(args) < 1): parser.print_help() return assert [options.six_term, options.zig_zag, options.full_fits].count(True) < 2 if (options.full_fits is not None): full_fits = easy_pickle.load(options.full_fits) else: full_fits = None params = cctbx.eltbx.gaussian_fit.fit_parameters( max_n_terms=options.max_n_terms, max_max_error=options.max_max_error) if (options.quick): params = params.quick() run_and_time( file_name=args[0], args=args[1:], cutoff=options.cutoff, params=params, zig_zag=options.zig_zag, six_term=options.six_term, full_fits=full_fits, verbose=options.verbose)
def main(): parser = OptionParser( usage="usage: python %prog file_name [n_chunks,i_chunk] [scatterer...]") parser.add_option("-v", "--verbose", action="store_true", default=0, help="show comparison table for each element") parser.add_option("-c", "--cutoff", type="float", default=6, metavar="FLOAT", help="maximum sin(theta)/lambda") parser.add_option("-n", "--max_n_terms", type="int", default=5, metavar="INT", help="maximum number of Gaussian terms") parser.add_option("-s", "--six_term", action="store_true", default=0, help="fit six-term Gaussians using Golay based starts") (options, args) = parser.parse_args() if (len(args) < 1): parser.print_help() return run_and_time( args=args, cutoff=options.cutoff, max_n_terms=options.max_n_terms, six_term=options.six_term, verbose=options.verbose)
def main(): parser = OptionParser(usage="usage: python %prog [options] file_name") parser.add_option("-t", "--table", default="wk1995", action="store", dest="table_of_gaussians", help="wk1995 or it1992") parser.add_option("-q", "--quiet", action="store_true", default=0, help="do not show values for large errors, only stol") parser.add_option("-v", "--verbose", action="store_true", default=0, help="show comparison table for each element") parser.add_option("-l", "--low_resolution_only", action="store_true", default=0, help="analyze points up to sin(theta)/lambda=2A-1 only") parser.add_option("-g", "--high_resolution_only", action="store_true", default=0, help="analyze points beyond sin(theta)/lambda=2A-1 only") parser.add_option("-s", "--significant_errors_only", action="store_true", default=0, help="show errors greater than 1% only") (options, args) = parser.parse_args() if (len(args) != 1): parser.print_help() return assert options.table_of_gaussians in ["wk1995", "it1992"] if (options.table_of_gaussians == "wk1995"): table_of_gaussians = xray_scattering.wk1995 plots_dir = "itvc_wk1995_plots" cutoff = 6 else: table_of_gaussians = xray_scattering.it1992 plots_dir = "itvc_it1992_plots" cutoff = 2 assert not options.low_resolution_only assert not options.high_resolution_only print("table_of_gaussians:", options.table_of_gaussians) run(file_name=args[0], table_of_gaussians=table_of_gaussians, cutoff=cutoff, low_resolution_only=options.low_resolution_only, high_resolution_only=options.high_resolution_only, significant_errors_only=options.significant_errors_only, plots_dir=plots_dir, quiet=options.quiet, verbose=options.verbose)
def main(): parser = OptionParser(usage="usage: python %prog [options] file_name") parser.add_option( "-t", "--table", default="wk1995", action="store", dest="table_of_gaussians", help="wk1995 or it1992" ) parser.add_option( "-q", "--quiet", action="store_true", default=0, help="do not show values for large errors, only stol" ) parser.add_option("-v", "--verbose", action="store_true", default=0, help="show comparison table for each element") parser.add_option( "-l", "--low_resolution_only", action="store_true", default=0, help="analyze points up to sin(theta)/lambda=2A-1 only", ) parser.add_option( "-g", "--high_resolution_only", action="store_true", default=0, help="analyze points beyond sin(theta)/lambda=2A-1 only", ) parser.add_option( "-s", "--significant_errors_only", action="store_true", default=0, help="show errors greater than 1% only" ) (options, args) = parser.parse_args() if len(args) != 1: parser.print_help() return assert options.table_of_gaussians in ["wk1995", "it1992"] if options.table_of_gaussians == "wk1995": table_of_gaussians = xray_scattering.wk1995 plots_dir = "itvc_wk1995_plots" cutoff = 6 else: table_of_gaussians = xray_scattering.it1992 plots_dir = "itvc_it1992_plots" cutoff = 2 assert not options.low_resolution_only assert not options.high_resolution_only print "table_of_gaussians:", options.table_of_gaussians run( file_name=args[0], table_of_gaussians=table_of_gaussians, cutoff=cutoff, low_resolution_only=options.low_resolution_only, high_resolution_only=options.high_resolution_only, significant_errors_only=options.significant_errors_only, plots_dir=plots_dir, quiet=options.quiet, verbose=options.verbose, )
def main(): parser = OptionParser( usage="usage: python %prog [options]" + " itvc_table all_fits_six_terms.pickle" + " all_fits_decremental.pickle all_fits_incremental.pickle") (options, args) = parser.parse_args() if (len(args) != 4): parser.print_help() return itvc_tab = itvc_section61_io.read_table6111(args[0]) six_term_fits = easy_pickle.load(args[1]) fits = [] for file_name in args[2:]: fits.append(easy_pickle.load(file_name)) for label, fit_group in fits[-1].all.items(): for fit in fit_group: reset_max_error(itvc_tab.entries[label], fit) best_fits = {} n_less = 0 n_greater = 0 n_equal = 0 n_less_list = [0] * 10 n_greater_list = [0] * 10 n_equal_list = [0] * 10 for label in expected_labels(kissel_dir=None): fit_group_0 = fits[0].all.get(label, None) fit_group_1 = fits[1].all.get(label, None) if (fit_group_0 is None and fit_group_1 is None): best_fits[label] = None continue if (fit_group_0 is None): best_fits[label] = fit_group_0 continue if (fit_group_1 is None): best_fits[label] = fit_group_1 continue best_group = [] all_n_terms = {} n_terms_dicts = [] for fit_group in [fit_group_0, fit_group_1]: n_terms_dict = {} for fit in fit_group: n_terms_dict[fit.n_terms()] = fit n_terms_dicts.append(n_terms_dict) all_n_terms.update(n_terms_dicts[-1]) all_n_terms = all_n_terms.keys() all_n_terms.sort() for n_terms in all_n_terms: fit_0 = n_terms_dicts[0].get(n_terms, None) fit_1 = n_terms_dicts[1].get(n_terms, None) if (fit_0 is None): best_group.append(fit_1) continue if (fit_1 is None): best_group.append(fit_0) continue if (fit_0.stol < fit_1.stol): best_group.append(fit_1) status = "less" n_less += 1 n_less_list[n_terms] += 1 elif (fit_0.stol > fit_1.stol): best_group.append(fit_0) status = "greater" n_greater += 1 n_greater_list[n_terms] += 1 else: best_group.append(pick_nicest_fit(fit_0, fit_1)) status = "equal" n_equal += 1 n_equal_list[n_terms] += 1 print "%-4s n_terms=%d %4.2f %4.2f %s" % ( label, n_terms, fit_0.stol, fit_1.stol, status) best_fits[label] = best_group print "n_less:", n_less print "n_greater:", n_greater print "n_equal:", n_equal print "total:", n_less + n_greater + n_equal n_terms = -1 for n_less, n_greater, n_equal in zip(n_less_list, n_greater_list, n_equal_list): n_terms += 1 if (n_less == 0 and n_greater == 0 and n_equal == 0): continue print "n_terms:", n_terms print " n_less:", n_less print " n_greater:", n_greater print " n_equal:", n_equal print " total:", n_less + n_greater + n_equal print for label in expected_labels(kissel_dir=None): if (best_fits[label] is None): print "# Warning: Missing scattering_type:", label print print "Best fits:" print for label in expected_labels(kissel_dir=None): fit_group = best_fits[label] if (fit_group is None): continue print "scattering_type:", label assert len(six_term_fits.all[label]) == 1 assert six_term_fits.all[label][0].n_terms() == 6 fit_group.append(six_term_fits.all[label][0]) reset_max_error(itvc_tab.entries[label], fit_group[-1]) trimmed_fit_group = [] prev_fit = None for fit in fit_group: if (prev_fit is None or fit.stol > prev_fit.stol or (fit.stol == prev_fit.stol and fit.max_error < prev_fit.max_error)): trimmed_fit_group.append(fit) fit.show() prev_fit = fit else: print "# skipped: %s, n_terms: %d, stol: %.2f, max_error: %.4f" % ( label, fit.n_terms(), fit.stol, fit.max_error) best_fits[label] = trimmed_fit_group print easy_pickle.dump("best_fits.pickle", best_fits)