Beispiel #1
0
def run(args, log):
    t0 = time.time()
    if len(args) == 0:
        print_legend_and_usage(log)
        return
    params = get_inputs(
        args=args,
        log=log,
        master_params=master_params(),
        #validated     = validated,
    )
    if (params.verbose):
        print("Starting Q|R charge", file=log)
        print('version: ', __version__, file=log)
    del sys.argv[1:]
    cc = charges.charges_class(
        params.model_file_name,
        ligand_cif_file_names=params.ligand_cif_file_name,
        electrons=params.electrons,
        verbose=params.verbose,
    )
    rc = cc.get_total_charge(
        list_charges=params.list_charges,
        assert_correct_chain_terminii=params.assert_correct_chain_terminii,
    )
    if (params.verbose):
        print('Charge: %s' % rc, file=log)
        print("Time: %6.4f" % (time.time() - t0), file=log)
    if (params.list_charges):
        print('Charges:', file=log)
        print(rc, file=log)
        print("Time: %6.4f" % (time.time() - t0), file=log)
Beispiel #2
0
def run(file_name,
        d_min=0.8,
        maxnum_residues_in_cluster=3,
        filter_non_protein_and_hd=True):
    prefix = os.path.basename(file_name)[3:7]
    print file_name, prefix
    pdb_inp = iotbx.pdb.input(file_name=file_name)
    resolution = pdb_inp.resolution()
    data_type = pdb_inp.get_experiment_type()
    if (resolution is not None and resolution <= d_min):
        if (data_type in ["X-RAY DIFFRACTION", "NEUTRON DIFFRACTION"]):
            pdb_hierarchy = pdb_inp.construct_hierarchy()
            xray_structure = pdb_hierarchy.extract_xray_structure()
            xray_structure.convert_to_isotropic()
            pdb_hierarchy.adopt_xray_structure(xray_structure)
            if (filter_non_protein_and_hd):
                pdb_hierarchy = keep_protein_only(pdb_hierarchy=pdb_hierarchy)
            if (pdb_hierarchy is not None):
                if (have_conformers(pdb_hierarchy=pdb_hierarchy)):
                    pdb_hierarchy.remove_alt_confs(
                        always_keep_one_conformer=True)
                pdb_hierarchy = add_hydrogens_using_ReadySet(
                    pdb_hierarchy=pdb_hierarchy)
                box = box_pdb(pdb_hierarchy=pdb_hierarchy)
                fq = fragments(
                    pdb_hierarchy=box.pdb_hierarchy,
                    maxnum_residues_in_cluster=maxnum_residues_in_cluster,
                    debug=True,
                    crystal_symmetry=box.cs)
                print "clusters:", fq.clusters
                os.mkdir(prefix)
                cntr = 0
                for fname in os.listdir(os.getcwd()):
                    if fname.endswith("_cluster.pdb"):
                        if check_missing_atom(pdb_filename=fname):
                            os.remove(fname)
                        else:
                            cl_fn = "%s_%d.pdb" % (prefix, cntr)
                            fo = open(cl_fn, "w")
                            ph_i = iotbx.pdb.input(
                                file_name=fname).construct_hierarchy()
                            ph_i = completion.run(pdb_hierarchy=ph_i,
                                                  crystal_symmetry=box.cs,
                                                  model_completion=False)
                            pdb_str = ph_i.as_pdb_string(
                                crystal_symmetry=box.cs, append_end=True)
                            pdb_str = validate(pdb_str=pdb_str)
                            if (pdb_str is None): continue
                            charge = charges_class(
                                raw_records=pdb_str).get_total_charge()
                            fo.write("REMARK charge= %s \n" % str(charge))
                            fo.write(pdb_str)
                            fo.close()
                            cntr += 1
                            libtbx.easy_run.fully_buffered("mv %s %s" %
                                                           (cl_fn, prefix))
                libtbx.easy_run.fully_buffered("rm -rf *.pdb ase/")
    if not os.listdir(prefix):
        os.rmdir(prefix)
        print "Empty dir"
Beispiel #3
0
def get_charge(fn, assert_correct_chain_terminii=True):
  cc=charges_class(fn)
  return cc.get_total_charge(
    assert_correct_chain_terminii=assert_correct_chain_terminii)