Exemple #1
0
def run(args):
  if (len(args) == 0 or "--help" in args or "--h" in args or "-h" in args):
    raise Usage(usage())
  import iotbx.pdb
  import iotbx.utils
  master_phil = get_master_phil()
  args = list(args)
  input_objects = iotbx.utils.process_command_line_inputs(
    args=args,
    master_phil=master_phil,
    input_types=("pdb",))
  work_phil = master_phil.fetch(sources=input_objects["phil"])
  work_params = work_phil.extract()
  if len(input_objects["pdb"]) != 1:
    summary, header = self.get_summary_and_header("ramalyze")
    raise Usage(summary)
  file_obj = input_objects["pdb"][0]
  file_name = file_obj.file_name
  pdb_io = iotbx.pdb.input(file_name)
  pdb_hierarchy = pdb_io.construct_hierarchy()
  pdb_hierarchy.reset_i_seq_if_necessary()
  cis_peptides, trans_peptides, outliers = \
    analyze(pdb_hierarchy=pdb_hierarchy)
  show(cis_peptides=cis_peptides,
       trans_peptides=trans_peptides,
       outliers=outliers,
       cis_only=work_params.analyze_peptides.cis_only)
def process_input(argv=None, flag_mkdir=True):
    user_phil = []
    if argv == None:
        master_phil.show()
        raise Usage(
            "Use the above list of parameters to generate your input file (.phil). For more information, run prime.postrefine -h."
        )
    else:
        for arg in argv:
            if os.path.isfile(arg):
                user_phil.append(iotbx.phil.parse(open(arg).read()))
            elif (os.path.isdir(arg)):
                user_phil.append(iotbx.phil.parse("""data=\"%s\"""" % arg))
            else:
                if arg == '--help' or arg == '-h':
                    print txt_help
                    master_phil.show(attributes_level=1)
                    raise Usage(
                        "Run prime.run to generate a list of initial parameters."
                    )
                else:
                    try:
                        user_phil.append(iotbx.phil.parse(arg))
                    except RuntimeError, e:
                        raise Sorry("Unrecognized argument '%s' (error: %s)" %
                                    (arg, str(e)))
def run(args):
  try:
    from cxi_xdr_xes.cftbx.cspad_ana import db as db
  except ImportError:
    raise Sorry("Trial logging not supported for this installation. Contact the developers for access.")

  phil = iotbx.phil.process_command_line(args=args, master_string=master_phil)
  params = phil.work.extract()

  if params.db.host is None:
    raise Usage("Please provide a host name")
  if params.db.name is None:
    raise Usage("Please provide a database name")
  if params.db.user is None:
    raise Usage("Please provide a user name")
  if params.db.password is None:
    import getpass
    password = getpass.getpass()
  else:
    password = params.db.password

  try:
    dbobj = db.dbconnect(host=params.db.host, db=params.db.name, username=params.db.user, password=password)
  except Exception, e:
    raise Sorry(e)
    def initialize(self, args):
        import iotbx.phil
        from xfel.command_line.cxi_merge import master_phil
        if ("--help" in args):
            iotbx.phil.parse(master_phil).show(attributes_level=2)
            return
        phil = iotbx.phil.process_command_line(
            args=args, master_string=master_phil).show()
        work_params = phil.work.extract()
        from xfel.merging.phil_validation import application
        application(work_params)

        if ((work_params.d_min is None) or (work_params.data is None)
                or ((work_params.model is None)
                    and work_params.scaling.algorithm != "mark1")):
            command_name = os.environ["LIBTBX_DISPATCHER_NAME"]
            raise Usage(command_name + " "
                        "d_min=4.0 "
                        "data=~/scratch/r0220/006/strong/ "
                        "model=3bz1_3bz2_core.pdb")
        if ((work_params.rescale_with_average_cell)
                and (not work_params.set_average_unit_cell)):
            raise Usage(
                "If rescale_with_average_cell=True, you must also specify " +
                "set_average_unit_cell=True.")
        if [
                work_params.raw_data.sdfac_auto,
                work_params.raw_data.sdfac_refine,
                work_params.raw_data.errors_from_sample_residuals
        ].count(True) > 1:
            raise Usage(
                "Specify only one of sdfac_auto, sdfac_refine or errors_from_sample_residuals."
            )

        # Read Nat's reference model from an MTZ file.  XXX The observation
        # type is given as F, not I--should they be squared?  Check with Nat!
        log = open("%s.log" % work_params.output.prefix, "w")
        out = multi_out()
        out.register("log", log, atexit_send_to=None)
        out.register("stdout", sys.stdout)
        print >> out, "I model"
        if work_params.model is not None:
            from xfel.merging.general_fcalc import run as run_fmodel
            i_model = run_fmodel(work_params)
            work_params.target_unit_cell = i_model.unit_cell()
            work_params.target_space_group = i_model.space_group_info()
            i_model.show_summary()
        else:
            i_model = None

        print >> out, "Target unit cell and space group:"
        print >> out, "  ", work_params.target_unit_cell
        print >> out, "  ", work_params.target_space_group
        from xfel.command_line.cxi_merge import consistent_set_and_model
        self.miller_set, self.i_model = consistent_set_and_model(
            work_params, i_model)
        self.work_params = work_params
        self.frame_files = get_observations(work_params)
        self.out = out
 def validate(self, comm):
     base_Script.validate(self)
     if (self.params.rescale_with_average_cell):
         raise Usage("""Rescaling_with_average_cell not supported with MPI
   (Would require a second round of scaling, inefficient).""")
     if (self.params.mpi.cs == True and comm.Get_size() <= 1):
         raise Usage(
             "Client-server algorithm requires a minimum size of 2 MPI ranks to process data. Currently size=%d"
             % comm.Get_size())
def run(args, out=sys.stdout):
  show_development_warning(out=out)
  if (len(args) == 0) or ("--help" in args):
    raise Usage("""\
cctbx.patterson_map data.mtz [options]

Calculates a simple or anomalous difference Patterson map.  Output is in CCP4
format.

Full options:

%s
""" % master_phil.as_str(prefix="  "))
  import iotbx.phil
  from cctbx.array_family import flex
  from cctbx import miller
  from cctbx import xray
  hkl_in = None
  sources = []
  cmdline = iotbx.phil.process_command_line_with_files(
    args=args,
    master_phil=master_phil,
    reflection_file_def="data")
  params = cmdline.work.extract()
  if (params.data is None):
    raise Usage("mmtbx.patterson_map data [options]\n\nFull parameters:\n%s" %
      master_phil.as_str(prefix="  "))
  f_obs = extract_data(
    file_name=params.data,
    expected_labels=params.labels,
    out=out)
  if (f_obs is None):
    raise Sorry("No suitable data found.")
  f_obs = prepare_f_obs(f_obs, params=params)
  final_array = f_obs # default
  is_anom = False
  if (f_obs.anomalous_flag()):
    if (params.map_type in ["auto", "anom"]):
      print >> out, "Output will be anomalous Patterson map"
      is_anom = True
      final_array = f_obs.anomalous_differences()
      final_array = abs(final_array)
      if (params.diff_limit is not None):
        final_array = final_array.select(final_array.data() < params.diff_limit)
    else :
      final_array = f_obs.average_bijvoet_mates()
  map = calculate_patterson_map(data=final_array, params=params,
    normalize=is_anom)
  if (params.map_file_name is None):
    base = os.path.splitext(os.path.basename(params.data))[0]
    params.map_file_name = base + "_patt.ccp4"
  map.as_ccp4_map(
    file_name=params.map_file_name)
  print >> out, "Wrote %s" % params.map_file_name
Exemple #7
0
def run(args=(), params=None, out=sys.stdout):
    if (len(args) == 0) and (params is None):
        raise Usage("""
iotbx.file_reader filename [force_type=None]

(where force_type can be optionally set to one of these keywords:
  %s)
""" % ",".join(iotbx.file_reader.standard_file_types))
    user_phil = []
    for arg in args:
        if (os.path.isfile(arg)):
            user_phil.append(
                libtbx.phil.parse("""file_reader.file_name='%s'""" % arg))
        else:
            if (arg.startswith("force_type")):
                arg = "file_reader." + arg
            try:
                user_phil.append(libtbx.phil.parse(arg))
            except RuntimeError as e:
                print(e)
                print("Unrecognized argument '%s'" % arg)
    params = master_phil.fetch(sources=user_phil).extract()
    validate_params(params)
    f = file_reader.any_file(file_name=params.file_reader.file_name,
                             valid_types=file_reader.standard_file_types,
                             force_type=params.file_reader.force_type)
    f.show_summary(out=out)
Exemple #8
0
    def run(self):
        ''' Parse the options. '''
        # Parse the command line arguments
        params, options = self.parser.parse_args(show_diff_phil=True)
        self.params = params

        if params.tag is None:
            raise Usage(self.parser.usage)

        level_json = "%s_%d_refined_experiments_level%d.json"
        level_pickle = "%s_%d_refined_reflections_level%d.mpack"

        command = "cspad.detector_congruence %s %s %s %s hierarchy_level=%d show_plots=False"

        help_strs = [
            "detector as a whole block", "quadrants", "sensors, I.E. 2x1s",
            "ASICs, I.E. individual tiles"
        ]

        for i in range(3):
            c = command % (level_json % (params.tag, 1, i), level_pickle %
                           (params.tag, 1, i), level_json %
                           (params.tag, 2, i), level_pickle %
                           (params.tag, 2, i), i)

            print "*" * 80
            print "Showing statistics for detector at level %d (%s)" % (
                i, help_strs[i])
            print "*" * 80
            print c
            result = easy_run.fully_buffered(c).raise_if_errors()
            result.show_stdout()
Exemple #9
0
def run(args):
    if ("--help" in args) or ("--options" in args):
        raise Usage("""\
phenix.compare_datasets data1.mtz data2.mtz

Side-by-side visualization of pseudo-precession planes through reciprocal
space for a pair of datasets - essentially a duplex version of 2D view in
phenix.data_viewer.
""")
    a = wx.App(0)
    app_icon = wx.EmptyIcon()
    app_icon.CopyFromBitmap(icons.hklview_2d.GetBitmap())
    if (wx.VERSION >= (2, 9)):
        tb_icon = wx.TaskBarIcon(wx.TBI_DOCK)
    else:
        tb_icon = wx.TaskBarIcon()
    tb_icon.SetIcon(app_icon, "PHENIX data viewer")
    frame = comparison.ComparisonFrame(None, -1, "Dataset comparison")
    frame.Show()
    file_name_1 = file_name_2 = None
    for arg in args:
        if (os.path.isfile(arg)):
            if (file_name_1 is None):
                file_name_1 = arg
            elif (file_name_2 is None):
                file_name_2 = arg
            else:
                raise Sorry("Only two files at a time are supported.")
    if (file_name_1 is not None) and (file_name_2 is not None):
        frame.load_files(file_name_1, file_name_2)
    a.SetTopWindow(frame)
    a.Bind(wx.EVT_WINDOW_DESTROY, lambda evt: tb_icon.Destroy(), frame)
    a.MainLoop()
Exemple #10
0
    def format_usage_message(self):
        raise Usage("""\
phenix.dynamics: perform simple dynamics to perturb a model
Usage examples:
  phenix.dynamics model.pdb
  phenix.dynamics model.pdb ligands.cif
""")
Exemple #11
0
def run (args, out=sys.stdout) :
  if (len(args) == 0) or ("--help" in args) :
    raise Usage("""\
mmtbx.compare_ligands model1.pdb model2.pdb ligand_code=LIG

Given a pair of PDB files and a ligand ID, identifies equivalent copies of the
ligand in each model and calculates RMSDs between them.  Used for validating
ligand fitting tools in Phenix.""")

  import iotbx.phil
  class _cmdline (iotbx.phil.process_command_line_with_files) :
    def process_other (self, arg) :
      if (len(arg) <= 3) and (arg.isalnum()) :
        return iotbx.phil.parse("""ligand_code=%s""" % arg)
  cmdline = _cmdline(
    args=args,
    master_phil_string=master_phil,
    pdb_file_def="pdb_file")
  params = cmdline.work.extract()
  if (len(params.pdb_file) != 2) :
    raise Sorry("Exactly two PDB files required as input.")
  if (params.ligand_code is None) :
    raise Sorry("Must specify ligand ID (ligand_code=LIG)")
  from mmtbx.validation import ligands
  rmsds, pbss = ligands.compare_ligands(
    ligand_code=params.ligand_code,
    pdb_file_1=params.pdb_file[0],
    pdb_file_2=params.pdb_file[1],
    exclude_hydrogens=params.exclude_hydrogens,
    verbose=params.verbose,
    out=out)
  if (len(rmsds) == 0) :
    raise Sorry("No matching ligands found!")
Exemple #12
0
def run(args=(), params=None, out=None):
    if (out is None): out = sys.stdout
    if (params is None):
        if (len(args) == 0):
            raise Usage("pdb_split_chains.py model.pdb")
        import iotbx.phil
        cmdline = iotbx.phil.process_command_line_with_files(
            args=args,
            master_phil=master_phil,
            pdb_file_def="split_chains.pdb_file")
        params = cmdline.work.extract()
    validate_params(params)
    params = params.split_chains
    if (params.output_dir is None):
        params.output_dir = os.getcwd()
    if (params.output_base is None):
        params.output_base = os.path.basename(
            os.path.splitext(params.pdb_file)[0])
    from iotbx import file_reader
    from iotbx.pdb.hierarchy import new_hierarchy_from_chain
    pdb_in = file_reader.any_file(params.pdb_file, force_type="pdb")
    pdb_in.check_file_type("pdb")
    symm = pdb_in.file_object.crystallographic_section()
    hierarchy = pdb_in.file_object.hierarchy
    if (len(hierarchy.models()) > 1):
        raise Sorry(
            "Multi-model PDB files are not supported.  You can use " +
            "iotbx.pdb.split_models to break the structure into individual model "
            + "files.")
    id_counts = {}
    outputs = []
    for chain in hierarchy.models()[0].chains():
        main_conf = chain.conformers()[0]
        if (params.exclude_heteroatoms):
            if ((not main_conf.is_protein()) and (not main_conf.is_na())):
                continue
            elif (len(chain.residue_groups()) == 1):
                continue
        id = chain.id
        if (id == " "):
            id = "_"
        if (id_counts.get(id, 0) > 0):
            suffix = "%s-%d" % (id, id_counts[id] + 1)
        else:
            suffix = id
        if (not id in id_counts):
            id_counts[id] = 0
        id_counts[id] += 1
        output_file = os.path.join(params.output_dir,
                                   "%s_%s.pdb" % (params.output_base, suffix))
        f = open(output_file, "w")
        if (params.preserve_symmetry):
            f.write("\n".join(symm))
            f.write("\n")
        new_hierarchy = new_hierarchy_from_chain(chain)
        f.write(new_hierarchy.as_pdb_string())
        f.close()
        outputs.append(output_file)
        print >> out, "Wrote chain '%s' to %s" % (chain.id, output_file)
    return outputs
  def usage():
    raise Usage("""\
%s file1.pdb file2.pdb [...]

or define the environment variable
  PDB_MIRROR_PDB
to join all fragment files in the PDB.""" % command_name)
def run(args):
    if (len(args) != 2):
        raise Usage("""\
iotbx.cns.transfer_crystal_symmetry any_symmetry_source_file cns_input_file
  *********************************************
  NOTE: the cns_input_file is changed in place.
  *********************************************""")
    #
    for file_name in args:
        if (not os.path.exists(file_name)):
            raise Sorry("No such file: %s" % show_string(file_name))
    source, target = args
    crystal_symmetry = crystal_symmetry_from_any.extract_from(source)
    if (crystal_symmetry is None):
        raise Sorry("Unknown file format or unit cell and/or space group"
                    " missing from file: " + show_string(source))
    cns_space_group_symbol = cns.space_group_symbols.cns_format(
        space_group_info=crystal_symmetry.space_group_info())
    if (cns_space_group_symbol is None):
        raise Sorry("Space group not available in CNS: %s" %
                    show_string(str(crystal_symmetry.space_group_info())))
    sg = '"%s"' % cns_space_group_symbol
    a, b, c, alpha, beta, gamma = [
        "%.6g" % p for p in crystal_symmetry.unit_cell().parameters()
    ]
    parameter_names = ["sg", "a", "b", "c", "alpha", "beta", "gamma"]
    parameters_found = dict(zip(parameter_names, [0] * len(parameter_names)))
    parameters_changed = []
    lines_out = []
    detect_binary = detect_binary_file(monitor_initial=100)
    try:
        cns_inp = open(target).read().splitlines()
    except IOError, e:
        raise Sorry("Error reading file %s (%s)" %
                    (show_string(target), str(e)))
Exemple #15
0
def run(args, out=sys.stdout):
    if (len(args) == 0) or ("--help" in args):
        raise Usage("mmtbx.rigid_bond_test model.pdb")
    from mmtbx.monomer_library import pdb_interpretation
    import mmtbx.restraints
    import mmtbx.model
    import iotbx.phil
    cmdline = iotbx.phil.process_command_line_with_files(
        args=args,
        master_phil=master_phil,
        pdb_file_def="model",
        cif_file_def="restraints")
    params = cmdline.work.extract()
    validate_params(params)
    processed_pdb_file = pdb_interpretation.run(args=[params.model] +
                                                params.restraints)
    geometry = processed_pdb_file.geometry_restraints_manager(
        show_energies=True)
    restraints_manager = mmtbx.restraints.manager(geometry=geometry,
                                                  normalization=True)
    model = mmtbx.model.manager(
        xray_structure=processed_pdb_file.xray_structure(),
        pdb_hierarchy=processed_pdb_file.all_chain_proxies.pdb_hierarchy,
        restraints_manager=restraints_manager,
        log=out)
    make_header("Rigid-bond test", out=out)
    model.show_rigid_bond_test(out=out, use_id_str=True, prefix="  ")
Exemple #16
0
def run(args):
    if ("--help" in args or "-h" in args):
        print("Write a SLAC metrology file from a CSPAD CBF. Parameters:")
        master_phil.show(attributes_level=2)
        return

    user_phil = []
    for arg in args:
        try:
            user_phil.append(libtbx.phil.parse(arg))
        except RuntimeError as e:
            raise Sorry("Unrecognized argument '%s' (error: %s)" %
                        (arg, str(e)))

    params = master_phil.fetch(sources=user_phil).extract()

    if params.cbf_header is None or \
       params.out_metrology_file is None:
        raise Usage("%s cbf_header=<path> out_metrology_file=<path>" %
                    libtbx.env.dispatcher_name)

    if not os.path.exists(params.cbf_header):
        raise Sorry("File not found: %s" % params.cbf_header)

    print("Converting", params.cbf_header, "to", params.out_metrology_file)

    geometry = GeometryAccessFromCspadCBF(params.cbf_header)

    geometry.save_pars_in_file(params.out_metrology_file)
Exemple #17
0
def run(args):
    if (len(args) == 0):
        n_iterations = 1000
    elif (len(args) == 1):
        n_iterations = int(args[0])
        assert n_iterations > 0
    else:
        from libtbx.utils import Usage
        raise Usage("scitbx.show_exp_times [n_iterations]")
    evar = "LIBTBX_NO_LD_PRELOAD"
    evar_set = evar in os.environ
    if (evar_set):
        print("%s set:" % evar)
    else:
        print("%s not set:" % evar)
    from scitbx.math.tests.tst_exp_functions import \
      exercise_with_random_arguments as exercise
    exercise(n_arguments=10000, n_iterations=n_iterations)
    print()
    sys.stdout.flush()
    if (not evar_set):
        if ("LD_PRELOAD" in os.environ):
            del os.environ["LD_PRELOAD"]
        os.environ[evar] = "1"
        from libtbx import easy_run
        easy_run.call(command="scitbx.show_exp_times %d" % n_iterations)
def run(args):
  if ("--help" in args or "-h" in args) :
    print "Write a CBF header from a SLAC metrology file. Parameters:"
    master_phil.show(attributes_level=2)
    return

  user_phil = []
  for arg in args:
    if (os.path.isfile(arg)) :
      user_phil.append(libtbx.phil.parse("""metrology_file=\"%s\"""" % arg))
    else :
      try :
        user_phil.append(libtbx.phil.parse(arg))
      except RuntimeError as e :
        raise Sorry("Unrecognized argument '%s' (error: %s)" % (arg, str(e)))

  params = master_phil.fetch(sources=user_phil).extract()
  if (params.metrology_file is None) :
    master_phil.show()
    raise Usage("metrology_file must be defined (either metrology_file=XXX, or the file path alone).")
  assert params.plot is not None
  assert params.out is not None

  print params.metrology_file

  metro = read_slac_metrology(params.metrology_file, plot=params.plot)

  write_cspad_cbf(None, metro, 'cbf', None, params.out, None, 0, header_only=True)
Exemple #19
0
def run(args):
    phil = iotbx.phil.process_command_line(args=args,
                                           master_string=master_phil).show()
    work_params = phil.work.extract()
    if ("--help" in args):
        libtbx.phil.parse(master_phil.show())
        return

    if ((work_params.run_numbers is None
         and work_params.outdir_template is None)
            or (work_params.outdir_template is None)
            or (work_params.bravais_setting_id is None)):
        from libtbx.utils import Usage
        raise Usage(
            "cxi.plotcv "
            "run_numbers=16,17,18,19,20,21,22,23,24,25,26,27,71,72,73 "
            "outdir_template=/reg/data/ana11/cxi/cxi49812/scratch/april_2012/r%%04d/042/stdout "
            "bravais_setting_id=5")
    if work_params.show_plots is True:
        from matplotlib import pyplot as plt  # special import

    from xfel.cxi.correction_vector_plot import run_correction_vector_plot
    run_correction_vector_plot(work_params)

    return None
def run(args, out=sys.stdout, quiet=False):
    cmdline = iotbx.phil.process_command_line_with_files(
        args=args,
        master_phil=get_master_phil(),
        pdb_file_def="model",
        usage_string=usage_string)
    params = cmdline.work.extract()
    if (params.model is None):
        raise Usage(usage_string)
    pdb_in = cmdline.get_file(params.model, force_type="pdb")
    hierarchy = pdb_in.file_object.hierarchy
    result = mmtbx.validation.rotalyze.rotalyze(
        pdb_hierarchy=hierarchy,
        data_version="8000",  #params.data_version,
        show_errors=params.show_errors,
        outliers_only=params.outliers_only,
        out=out,
        quiet=quiet)
    if params.verbose:
        result.show_old_output(out=out, verbose=True)
    if params.wxplot:
        try:
            import wxtbx.app
        except ImportError, e:
            raise Sorry("wxPython not available.")
        else:
            app = wxtbx.app.CCTBXApp(0)
            result.display_wx_plots()
            app.MainLoop()
Exemple #21
0
def run(args=(), params=None, out=sys.stdout):
    from iotbx.pdb.remediation import remediator
    from iotbx import file_reader
    if (params is None):
        interpreter = master_phil.command_line_argument_interpreter()
        pdb_file = None
        sources = []
        for arg in args:
            if os.path.isfile(arg):
                input_file = file_reader.any_file(arg)
                if (input_file.file_type == "pdb"):
                    pdb_file = input_file
                    sources.append(
                        interpreter.process(arg="file_name=\"%s\"" % arg))
            else:
                arg_phil = interpreter.process(arg=arg)
                sources.append(arg_phil)
        work_phil = master_phil.fetch(sources=sources)
        work_params = work_phil.extract()
    else:  # XXX for phenix GUI
        work_params = params
        if (work_params.remediator.output_file is None):
            base, ext = os.path.splitext(work_params.remediator.file_name)
            work_params.remediator.output_file = base + "_remediated.pdb"
    if (work_params.remediator.file_name is None):
        if (pdb_file is None):
            summary = remediator.Program.description
            raise Usage(summary)
        else:
            work_params.remediator.file_name = pdb_file.file_name
    params = work_params.remediator
    remediator.remediator(params)
    return work_params.remediator.output_file
Exemple #22
0
def show_usage():
  help_msg = """\
iotbx.pdb.flip_symmetric_amino_acids model.pdb

"""

  raise Usage(help_msg)
def run(args=(), params=None, out=sys.stdout):
    if (len(args) == 0) and (params is None):
        raise Usage("iotbx.pdb.add_conformations model.pdb [selection=...]\n" +
                    "Full parameters:\n" + master_phil.as_str())
    from iotbx import file_reader
    pdb_in = None
    if (params is None):
        user_phil = []
        interpreter = master_phil.command_line_argument_interpreter(
            home_scope="")
        for arg in args:
            if os.path.isfile(arg):
                f = file_reader.any_file(os.path.abspath(arg))
                if (f.file_type == "pdb"):
                    pdb_in = f.file_object
                    user_phil.append(
                        libtbx.phil.parse("add_conformations.pdb_file=\"%s\"" %
                                          f.file_name))
                elif (f.file_type == "phil"):
                    user_phil.append(f.file_object)
                else:
                    raise Sorry("Unknown file type '%s' (%s)" %
                                (f.file_type, arg))
            else:
                try:
                    arg_phil = interpreter.process(arg=arg)
                except RuntimeError, e:
                    raise Sorry("Error parsing '%s': %s" % (arg, str(e)))
                else:
                    user_phil.append(arg_phil)
Exemple #24
0
def run(args, out=sys.stdout, quiet=None):
  """
  Calculates nonbonded clashscore using MolProbity (PROBE)

  Returns:
    When verbose=True the function print detailed results to log
    When verbose=False it will print clashscore
  """
  cmdline = iotbx.phil.process_command_line_with_files(
    args=args,
    master_phil_string=master_phil_str,
    pdb_file_def="model",
    usage_string=usage_string)
  params = cmdline.work.extract()
  if (params.model is None):
    raise Usage(usage_string)
  # if do_flips, make keep_hydrogens false
  if params.do_flips : params.keep_hydrogens = False

  pdb_in = cmdline.get_file(params.model, force_type="pdb")
  hierarchy = pdb_in.file_object.hierarchy
  result = clashscore(
    pdb_hierarchy=hierarchy,
    fast = params.fast,
    condensed_probe = params.condensed_probe,
    keep_hydrogens=params.keep_hydrogens,
    nuclear=params.nuclear,
    out=out,
    verbose=params.verbose and not quiet,
    b_factor_cutoff=params.b_factor_cutoff,
    do_flips=params.do_flips)
  if params.verbose:
    result.show_old_output(out=out)
  else:
    print >> out,round(result.get_clashscore(),2)
Exemple #25
0
def run(args):
  verbose = False
  mtz_file_names = []
  for arg in args:
    if (arg == "--help"):
      from libtbx.utils import Usage
      raise Usage("iotbx.python tst_dano.py [your_dano.mtz] [--verbose]")
    elif (arg == "--verbose"):
      verbose = True
    else:
      mtz_file_names.append(arg)
  exercise_systematic(verbose)
  if (len(mtz_file_names) == 0):
    import libtbx.load_env
    import os
    op = os.path
    have_regression = libtbx.env.has_module("phenix_regression")
    if have_regression:
      mtz_file_names.append(libtbx.env.find_in_repositories(
        relative_path="phenix_regression/reflection_files/dano.mtz",
        test=op.isfile,
        optional=False))
    else:
      print 'Skipping tests on dano.mtz: no phenix_regression'
  for mtz_file_name in mtz_file_names:
    recycle_dano_mtz(mtz_file_name)
  for missing in [None, "+", "-"]:
    recycle_one_dano(missing, verbose)
  print "OK"
Exemple #26
0
def run(args, out=sys.stdout):
    import optparse
    if (len(args) == 0) or ("--help" in args):
        raise Usage("""
mmtbx.validation_summary model.pdb

Prints a brief summary of validation criteria, including Ramachandran
statistics, rotamer outliers, clashscore, C-beta deviations, plus R-factors
and RMS(bonds)/RMS(angles) if found in PDB header.  (This is primarily used
for evaluating the output of refinement tests; general users are advised to
run phenix.model_vs_data or the validation GUI.)
""")
    parser = optparse.OptionParser()
    options, args = parser.parse_args(args)
    pdb_file = args[0]
    if (not os.path.isfile(pdb_file)):
        raise Sorry("Not a file: %s" % pdb_file)
    from iotbx.file_reader import any_file
    pdb_in = any_file(pdb_file, force_type="pdb").check_file_type("pdb")
    hierarchy = pdb_in.file_object.hierarchy
    xrs = pdb_in.file_object.input.xray_structures_simple()
    s = None
    extra = ""
    if (len(xrs) == 1):
        s = summary(pdb_file=pdb_file)
    else:
        s = ensemble(pdb_hierarchy=hierarchy, n_models=len(xrs))
        extra = " (%d models)" % len(xrs)
    print("", file=out)
    print("Validation summary for %s%s:" % (pdb_file, extra), file=out)
    s.show(out=out, prefix="  ", show_percentiles=True)
    print("", file=out)
    return s
Exemple #27
0
def run(args):
    if (len(args) == 0):
        from libtbx.utils import Usage
        import libtbx.load_env
        raise Usage("%s your.cbf ..." % libtbx.env.dispatcher_name)
    for file_name in args:
        process(file_name)
Exemple #28
0
def run(args):
    if (len(args) != 2):
        from libtbx.utils import Usage
        import libtbx.load_env
        raise Usage("%s first.pdb second.pdb" % libtbx.env.dispatcher_name)
    import iotbx.pdb
    inp_hier = []
    lbls_sets = []
    for file_name in args:
        pdb_inp = iotbx.pdb.input(file_name=file_name)
        print "%6d atoms in %s" % (pdb_inp.atoms().size(), file_name)
        pdb_hierarchy = pdb_inp.construct_hierarchy()
        inp_hier.append((pdb_inp, pdb_hierarchy))
        # need to keep hierarchy alive to get all labels
        lbls_set = set()
        for atom in pdb_inp.atoms():
            lbls = atom.id_str()
            if (lbls in lbls_set):
                raise RuntimeError("Duplicate atom labels: %s" % lbls)
            lbls_set.add(lbls)
        lbls_sets.append(lbls_set)
    print "%6d matching atom labels" % (len(lbls_sets[0].intersection(
        lbls_sets[1])))

    def show_missing(i, j):
        diff = lbls_sets[j].difference(lbls_sets[i])
        print "%6d missing in %s" % (len(diff), args[i])
        for atom in inp_hier[j][0].atoms():
            lbls = atom.id_str()
            if (lbls in diff):
                print "         %s" % lbls

    show_missing(0, 1)
    show_missing(1, 0)
def run(args, command_name=libtbx.env.dispatcher_name):
  if (len(args) == 0):
    raise Usage("%s cif [...]" % command_name)
  for file_name in args:
    obj_count = cif_triage.check_comp(file_name=file_name)
    if (obj_count == 0):
      raise Sorry("No data found in file: %s" % show_string(file_name))
  print "OK"
Exemple #30
0
def show_usage():
    help_msg = """\
iotbx.pdb.sort_atoms model.pdb

Sort atoms in residues so they will be in the same order in all residues.
Also renumbers atoms (atom serial number field 7-11 columns)."""

    raise Usage(help_msg)