Ejemplo n.º 1
0
    default=1,
    help="Number of cores used for parallel processing. (default: 1)")
parser.set_defaults(enan=True)
parser.set_defaults(center=True)
args = parser.parse_args()

if __name__ == "__main__":

    if args.output is None:
        fname_nopath = os.path.basename(args.file)
        basename, ext = os.path.splitext(fname_nopath)
        output = basename + "_enan"
    else:
        output = args.output

    rho, side = saxs.read_mrc(args.file)

    if args.ref is not None:
        #allow input of reference for enantiomer selection
        if args.ref.endswith('.mrc'):
            refrho, refside = saxs.read_mrc(args.ref)
        else:
            print("Invalid reference filename given. .mrc file required")
            sys.exit(1)

        rho_nsamples = rho.shape[0]
        rho_voxel = side / rho_nsamples
        ref_nsamples = refrho.shape[0]
        ref_voxel = refside / ref_nsamples

        if (not np.isclose(side, refside)
Ejemplo n.º 2
0
import sys, argparse, os
import logging

parser = argparse.ArgumentParser(
    description=
    "DENSS: DENsity from Solution Scattering.\n A tool for calculating an electron density map from solution scattering data",
    formatter_class=argparse.RawTextHelpFormatter)
args = dopts.parse_arguments(parser)

if args.rho_start is None:
    print(
        " denss.refine.py requires a .mrc file to be given to the --rho_start option."
    )
    sys.exit()

args.rho_start, rho_side = saxs.read_mrc(args.rho_start)

rho_nsamples = args.rho_start.shape[0]
rho_voxel = rho_side / rho_nsamples

args.side = args.dmax * args.oversampling

if (not np.isclose(rho_side, args.side)
        or not np.isclose(rho_voxel, args.voxel)
        or not np.isclose(rho_nsamples, args.nsamples)):
    print("rho_start density dimensions do not match given options.")
    print(
        "Oversampling and voxel size adjusted to match rho_start dimensions.")

args.voxel = rho_voxel
args.oversampling = rho_side / args.dmax
Ejemplo n.º 3
0
                        format='%(asctime)s %(message)s',
                        datefmt='%Y-%m-%d %I:%M:%S %p')
    logging.info('BEGIN')
    logging.info('Command: %s', ' '.join(sys.argv))
    #logging.info('Script name: %s', sys.argv[0])
    logging.info('DENSS Version: %s', __version__)

    rhosum = None
    n = 1
    nmaps = len(args.files)
    rhos = []
    for file in args.files:
        sys.stdout.write("\r% 5i / % 5i" % (n, nmaps))
        sys.stdout.flush()
        n += 1
        rho, side = saxs.read_mrc(file)
        rhos.append(rho)
        if rhosum is None:
            rhosum = rho
        else:
            rhosum += rho
    print()
    rhos = np.array(rhos)
    average_rho = rhosum / nmaps
    saxs.write_mrc(average_rho, side, output + "_avg.mrc")
    print("%s_avg.mrc written." % output)
    """
    #split maps into 2 halves--> enan, align, average independently with same refrho
    avg_rho1 = np.mean(aligned[::2],axis=0)
    avg_rho2 = np.mean(aligned[1::2],axis=0)
    fsc = saxs.calc_fsc(avg_rho1,avg_rho2,sides[0])
Ejemplo n.º 4
0
                    help="Desired number of electrons in map.")
parser.add_argument("-o",
                    "--output",
                    default=None,
                    help="Output filename prefix")
args = parser.parse_args()

if __name__ == "__main__":

    if args.output is None:
        basename, ext = os.path.splitext(args.file)
        output = basename + '_resampled'
    else:
        output = args.output

    rho, (a, b, c) = saxs.read_mrc(args.file, returnABC=True)
    ne = np.sum(rho)
    vx, vy, vz = np.array((a, b, c)) / np.array(rho.shape)
    #print vx, vy, vz

    if args.voxel is None:
        voxel = min((vx, vy, vz))
    else:
        voxel = args.voxel

    print "prezoom"
    print "Shape:  ", rho.shape
    print "Sides:  ", a, b, c
    print "Voxels: ", vx, vy, vz
    rho = saxs.zoom_rho(rho, (vx, vy, vz), voxel)
Ejemplo n.º 5
0
    #if plotting is enabled, try to import matplotlib
    #if import fails, set plotting to false
    try:
        import matplotlib.pyplot as plt
    except ImportError:
        args.plot = False

if __name__ == "__main__":

    if args.output is None:
        basename, ext = os.path.splitext(args.file)
        output = basename + '_rho'
    else:
        output = args.output

    rho, side = saxs.read_mrc(args.file)
    if rho.shape[0] % 2 == 1:
        rho = rho[:-1, :-1, :-1]
    #if nstmp%2==1: args.ns+=1
    rho = np.copy(rho[::args.ns, ::args.ns, ::args.ns])
    if args.threshold is not None:
        rho[np.abs(rho) <= args.threshold] = 0
    halfside = side / 2
    nx, ny, nz = rho.shape[0], rho.shape[1], rho.shape[2]
    n = nx
    voxel = side / n
    #want n to be even for speed/memory optimization with the FFT, ideally a power of 2, but wont enforce that
    #store n for later use if needed
    n_orig = n
    dx = side / n
    dV = dx**3
Ejemplo n.º 6
0
            voxel = (refside / allrhos[0].shape)[0]
            halfside = refside / 2
            n = int(refside / voxel)
            dx = refside / n
            x_ = np.linspace(-halfside, halfside, n)
            x, y, z = np.meshgrid(x_, x_, x_, indexing='ij')
            xyz = np.column_stack((x.ravel(), y.ravel(), z.ravel()))
            pdb = saxs.PDB(superargs.ref)
            if superargs.center:
                pdb.coords -= pdb.coords.mean(axis=0)
            refrho = saxs.pdb2map_gauss(pdb,
                                        xyz=xyz,
                                        sigma=superargs.resolution)
            refrho = refrho * np.sum(allrhos[0]) / np.sum(refrho)
        if superargs.ref.endswith('.mrc'):
            refrho, refside = saxs.read_mrc(superargs.ref)

    if superargs.enan:
        print
        print " Selecting best enantiomers..."
        try:
            allrhos, scores = saxs.select_best_enantiomers(
                allrhos, cores=superargs.cores)
        except KeyboardInterrupt:
            sys.exit(1)

    if superargs.ref is None:
        print
        print " Generating reference..."
        try:
            refrho = saxs.binary_average(allrhos, superargs.cores)