示例#1
0
    if to_write:
        timer       = py_utils.my_timer()
        pm          = read_config.get_detector_config(args.config_file, show=args.vb)
        q_pm        = read_config.compute_q_params(pm['detd'], pm['dets_x'], pm['dets_y'], pm['pixsize'], pm['wavelength'], show=args.vb)
        timer.reset_and_report("Reading experiment parameters") if args.vb else timer.reset()

        fov_len     = int(np.ceil(q_pm['fov_in_A']/q_pm['half_p_res']) + 1)
        eV          = process_pdb.wavelength_in_A_to_eV(pm['wavelength'])

        if pdb_code is not None:
            process_pdb.fetch_pdb(pdb_code)
        atom_types  = process_pdb.find_atom_types(pdb_file)
        scatt_list  = process_pdb.make_scatt_list(atom_types, aux_dir, eV)
        atoms       = process_pdb.get_atom_coords(pdb_file, scatt_list)
        (s_l, t_l)  = process_pdb.read_symmetry(pdb_file)
	if len(s_l)*len(t_l)>0:
            all_atoms = process_pdb.apply_symmetry(atoms, s_l, t_l)
        else:
            all_atoms = atoms
        timer.reset_and_report("Reading PDB") if args.vb else timer.reset()
        # all_atoms=[.nff['f1'],x,y,z,mass]
        den         = process_pdb.atoms_to_density_map(all_atoms, q_pm['half_p_res'])
        lp_den      = process_pdb.low_pass_filter_density_map(den)
        timer.reset_and_report("Creating density map") if args.vb else timer.reset()

        py_utils.write_density(den_file, lp_den, binary=True)
        timer.reset_and_report("Writing densities to file") if args.vb else timer.reset()

        timer.report_time_since_beginning() if args.vb else timer.reset()
示例#2
0
def main():
    '''Parses command line arguments to create 3D intensity file using config file parameters'''
    logging.basicConfig(filename="recon.log",
                        level=logging.INFO,
                        format='%(asctime)s - %(levelname)s - %(message)s')
    parser = py_utils.MyArgparser(description="make intensities")
    args = parser.special_parse_args()

    den_file = os.path.join(
        args.main_dir,
        read_config.get_filename(args.config_file, 'make_intensities',
                                 'in_density_file'))
    intens_file = os.path.join(
        args.main_dir,
        read_config.get_filename(args.config_file, 'make_intensities',
                                 'out_intensity_file'))
    try:
        num_threads = int(
            read_config.get_param(args.config_file, 'make_intensities',
                                  'num_threads'))
    except read_config.configparser.NoOptionError:
        num_threads = 4
    if args.yes:
        to_write = True
    else:
        to_write = py_utils.check_to_overwrite(intens_file)
    logging.info("\n\nStarting.... make_intensities")
    logging.info(' '.join(sys.argv))

    if to_write:
        timer = py_utils.MyTimer()
        pm = read_config.get_detector_config(args.config_file, show=args.vb)  #pylint: disable=C0103
        q_pm = read_config.compute_q_params(pm['detd'],
                                            pm['dets_x'],
                                            pm['dets_y'],
                                            pm['pixsize'],
                                            pm['wavelength'],
                                            pm['ewald_rad'],
                                            show=args.vb)
        timer.reset_and_report(
            "Reading experiment parameters") if args.vb else timer.reset()

        fov_len = 2 * int(np.ceil(
            q_pm['fov_in_A'] / q_pm['half_p_res'] / 2.)) + 3
        logging.info('Volume size: %d', fov_len)
        den = py_utils.read_density(den_file)
        min_over = float(fov_len) / den.shape[0]
        if min_over > 12:
            if py_utils.confirm_oversampling(min_over) is False:
                sys.exit(0)
        timer.reset_and_report(
            "Reading densities") if args.vb else timer.reset()

        pad_den = np.zeros(3 * (fov_len, ))
        den_sh = den.shape
        pad_den[:den_sh[0], :den_sh[1], :den_sh[2]] = den.copy()
        if WITH_PYFFTW:
            intens = np.abs(
                np.fft.fftshift(
                    pyfftw.interfaces.numpy_fft.fftn(
                        pad_den,
                        threads=num_threads,
                        planner_effort='FFTW_ESTIMATE')))**2
        else:
            intens = np.abs(np.fft.fftshift(np.fft.fftn(pad_den)))**2
        timer.reset_and_report(
            "Computing intensities") if args.vb else timer.reset()

        py_utils.write_density(intens_file, intens, binary=True)
        timer.reset_and_report(
            "Writing intensities") if args.vb else timer.reset()

        timer.report_time_since_beginning() if args.vb else timer.reset()
    else:
        pass
示例#3
0
        timer = py_utils.my_timer()
        pm = read_config.get_detector_config(args.config_file, show=args.vb)
        q_pm = read_config.compute_q_params(pm['detd'],
                                            pm['detsize'],
                                            pm['pixsize'],
                                            pm['wavelength'],
                                            show=args.vb)
        timer.reset_and_report(
            "Reading experiment parameters") if args.vb else timer.reset()

        fov_len = int(np.ceil(q_pm['fov_in_A'] / q_pm['half_p_res']) + 1)
        den = py_utils.read_density(den_file, binary=True)
        timer.reset_and_report(
            "Reading densities") if args.vb else timer.reset()

        pad_den = np.zeros(3 * (fov_len, ))
        den_sh = den.shape
        pad_den[:den_sh[0], :den_sh[1], :den_sh[2]] = den.copy()
        ft = np.abs(np.fft.fftshift(np.fft.fftn(pad_den)))
        intens = ft * ft
        timer.reset_and_report(
            "Computing intensities") if args.vb else timer.reset()

        py_utils.write_density(intens_file, intens, binary=True)
        timer.reset_and_report(
            "Writing intensities") if args.vb else timer.reset()

        timer.report_time_since_beginning() if args.vb else timer.reset()
    else:
        pass
示例#4
0
def main():
    '''Parses command line arguments to create 3D intensity file using config file parameters'''
    logging.basicConfig(filename="recon.log", level=logging.INFO,
                        format='%(asctime)s - %(levelname)s - %(message)s')
    parser = py_utils.MyArgparser(description="make intensities")
    args = parser.special_parse_args()

    den_file = os.path.join(args.main_dir,
                            read_config.get_filename(args.config_file,
                                                     'make_intensities',
                                                     'in_density_file'))
    intens_file = os.path.join(args.main_dir,
                               read_config.get_filename(args.config_file,
                                                        'make_intensities',
                                                        'out_intensity_file'))
    try:
        num_threads = int(read_config.get_param(args.config_file,
                                                'make_intensities',
                                                'num_threads'))
    except read_config.configparser.NoOptionError:
        num_threads = 4
    if args.yes:
        to_write = True
    else:
        to_write = py_utils.check_to_overwrite(intens_file)
    logging.info("\n\nStarting.... make_intensities")
    logging.info(' '.join(sys.argv))

    if to_write:
        timer = py_utils.MyTimer()
        pm = read_config.get_detector_config(args.config_file, show=args.vb) #pylint: disable=C0103
        q_pm = read_config.compute_q_params(pm['detd'], pm['dets_x'],
                                            pm['dets_y'], pm['pixsize'],
                                            pm['wavelength'], pm['ewald_rad'], show=args.vb)
        timer.reset_and_report("Reading experiment parameters") if args.vb else timer.reset()

        fov_len = 2 * int(np.ceil(q_pm['fov_in_A']/q_pm['half_p_res']/2.)) + 3
        logging.info('Volume size: %d', fov_len)
        den = py_utils.read_density(den_file)
        min_over = float(fov_len)/den.shape[0]
        if min_over > 12:
            if py_utils.confirm_oversampling(min_over) is False:
                sys.exit(0)
        timer.reset_and_report("Reading densities") if args.vb else timer.reset()

        pad_den = np.zeros(3*(fov_len,))
        den_sh = den.shape
        pad_den[:den_sh[0], :den_sh[1], :den_sh[2]] = den.copy()
        if WITH_PYFFTW:
            intens = np.abs(np.fft.fftshift(pyfftw.interfaces.numpy_fft.fftn(
                pad_den, threads=num_threads, planner_effort='FFTW_ESTIMATE')))**2
        else:
            intens = np.abs(np.fft.fftshift(np.fft.fftn(pad_den)))**2
        timer.reset_and_report("Computing intensities") if args.vb else timer.reset()

        py_utils.write_density(intens_file, intens, binary=True)
        timer.reset_and_report("Writing intensities") if args.vb else timer.reset()

        timer.report_time_since_beginning() if args.vb else timer.reset()
    else:
        pass
示例#5
0
def main():
    '''Parse command line arguments and generate electron density volume with config file'''
    logging.basicConfig(filename="recon.log",
                        level=logging.INFO,
                        format='%(asctime)s - %(levelname)s - %(message)s')
    parser = py_utils.MyArgparser(description="make electron density")
    args = parser.special_parse_args()
    logging.info("\n\nStarting.... make_densities")
    logging.info(' '.join(sys.argv))

    try:
        pdb_file = os.path.join(
            args.main_dir,
            read_config.get_filename(args.config_file, 'make_densities',
                                     'in_pdb_file'))
        pdb_code = None
    except read_config.configparser.NoOptionError:
        pdb_code = read_config.get_filename(args.config_file, 'make_densities',
                                            'pdb_code')
        pdb_file = 'aux/%s.pdb' % pdb_code.upper()
    try:
        num_threads = int(
            read_config.get_param(args.config_file, 'make_densities',
                                  'num_threads'))
    except read_config.configparser.NoOptionError:
        num_threads = 4
    aux_dir = os.path.join(
        args.main_dir,
        read_config.get_filename(args.config_file, 'make_densities',
                                 'scatt_dir'))
    den_file = os.path.join(
        args.main_dir,
        read_config.get_filename(args.config_file, 'make_densities',
                                 'out_density_file'))
    if args.yes:
        to_write = True
    else:
        to_write = py_utils.check_to_overwrite(den_file)

    if to_write:
        timer = py_utils.MyTimer()
        pm = read_config.get_detector_config(args.config_file, show=args.vb)  # pylint: disable=C0103
        q_pm = read_config.compute_q_params(pm['detd'],
                                            pm['dets_x'],
                                            pm['dets_y'],
                                            pm['pixsize'],
                                            pm['wavelength'],
                                            pm['ewald_rad'],
                                            show=args.vb)
        timer.reset_and_report(
            "Reading experiment parameters") if args.vb else timer.reset()

        if pdb_code is not None:
            process_pdb.fetch_pdb(pdb_code)
        all_atoms = process_pdb.process(pdb_file, aux_dir, pm['wavelength'])
        timer.reset_and_report("Reading PDB") if args.vb else timer.reset()

        den = process_pdb.atoms_to_density_map(all_atoms, q_pm['half_p_res'])
        lp_den = process_pdb.low_pass_filter_density_map(den,
                                                         threads=num_threads)
        timer.reset_and_report(
            "Creating density map") if args.vb else timer.reset()

        py_utils.write_density(den_file, lp_den, binary=True)
        timer.reset_and_report(
            "Writing densities to file") if args.vb else timer.reset()

        timer.report_time_since_beginning() if args.vb else timer.reset()