コード例 #1
0
ファイル: denss.average.py プロジェクト: egallmeier6/denss
    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])
    np.savetxt(args.output+'_fsc.dat',fsc,delimiter=" ",fmt="%.5e",header="qbins, FSC")
    """
    #rather than compare two halves, average all fsc's to the reference
    fscs = []
    for map in range(nmaps):
        fscs.append(saxs.calc_fsc(rhos[map], average_rho, side))
    fscs = np.array(fscs)
    fsc = np.mean(fscs, axis=0)
    np.savetxt(args.output + '_fsc.dat',
               fsc,
               delimiter=" ",
               fmt="%.5e",
               header="1/resolution, FSC")
    x = np.linspace(fsc[0, 0], fsc[-1, 0], 100)
    y = np.interp(x, fsc[:, 0], fsc[:, 1])
    resi = np.argmin(y >= 0.5)
    resx = np.interp(0.5, [y[resi + 1], y[resi]], [x[resi + 1], x[resi]])
    resn = round(float(1. / resx), 1)
    print('Resolution: %.1f' % resn, '\u212B')

    logging.info('Resolution: %.1f ' + '\u212B', resn)
コード例 #2
0
                     allrhos.shape[0])
    superlogger.info('Number of aligned maps accepted: %i', aligned.shape[0])
    superlogger.info('Correlation score between average and reference: %.3f',
                     -saxs.rho_overlap_score(average_rho, refrho))
    saxs.write_mrc(average_rho, sides[0], output + '_avg.mrc')
    """
    #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])
    np.savetxt(output+'_fsc.dat',fsc,delimiter=" ",fmt="%.5e",header="qbins, FSC")
    """
    #rather than compare two halves, average all fsc's to the reference
    fscs = []
    for calc_map in range(len(aligned)):
        fscs.append(saxs.calc_fsc(aligned[calc_map], refrho, sides[0]))
    fscs = np.array(fscs)
    fsc = np.mean(fscs, axis=0)
    np.savetxt(output + '_fsc.dat',
               fsc,
               delimiter=" ",
               fmt="%.5e",
               header="1/resolution, FSC")
    x = np.linspace(fsc[0, 0], fsc[-1, 0], 100)
    y = np.interp(x, fsc[:, 0], fsc[:, 1])
    resi = np.argmin(y >= 0.5)
    resx = np.interp(0.5, [y[resi + 1], y[resi]], [x[resi + 1], x[resi]])
    resn = round(float(1. / resx), 1)
    print("Resolution: %.1f A" % resn)

    superlogger.info('Resolution: %.1f ', resn)
コード例 #3
0
ファイル: denss.average.py プロジェクト: tdgrant1/denss
        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)

    #rather than compare two halves, average all fsc's to the reference
    fscs = []
    resns = []
    for calc_map in range(nmaps):
        fsc_map = saxs.calc_fsc(rhos[calc_map], average_rho, side)
        fscs.append(fsc_map)
        resn_map = saxs.fsc2res(fsc_map)
        resns.append(resn_map)

    fscs = np.array(fscs)
    resns = np.array(resns)
    fsc = np.mean(fscs, axis=0)
    resn, x, y, resx = saxs.fsc2res(fsc, return_plot=True)
    resn_sd = np.std(resns)
    if np.min(fsc[:, 1]) > 0.5:
        print("Resolution: < %.1f +- %.1f A (maximum possible)" %
              (resn, resn_sd))
    else:
        print("Resolution: %.1f +- %.1f A " % (resn, resn_sd))
コード例 #4
0
    if args.output is None:
        basename, ext = os.path.splitext(args.file)
        output = basename + '_fsc'
    else:
        output = args.output

    rho, side = saxs.read_mrc(args.file)
    refrho, refside = saxs.read_mrc(args.ref)
    if rho.shape[0] != refrho.shape[0]:
        print "Shape of rho and ref are not equal."
        sys.exit()
    if side != refside:
        print "Side length of rho and ref are not equal."
        sys.exit()

    fsc = saxs.calc_fsc(rho, refrho, side)

    np.savetxt(output + '.dat', fsc, delimiter=' ', fmt='% .5e')

    x = np.linspace(fsc[0, 0], fsc[-1, 0], 100)
    y = np.interp(x, fsc[:, 0], fsc[:, 1])
    resi = np.argmin(y >= 0.5)
    resx = np.interp(0.5, [y[resi + 1], y[resi]], [x[resi + 1], x[resi]])
    resn = round(float(1. / resx), 1)
    print "Resolution: %.1f" % resn, u'\u212B'.encode('utf-8')

    if args.plot:
        plt.plot(fsc[:, 0], fsc[:, 0] * 0 + 0.5, 'k--')
        plt.plot(fsc[:, 0], fsc[:, 1], 'o')
        plt.plot(x, y, 'k-')
        plt.plot([resx], [0.5],
コード例 #5
0
    superlogger.info('Number of aligned maps accepted: %i', aligned.shape[0])
    superlogger.info('Correlation score between average and reference: %.3f', -saxs.rho_overlap_score(average_rho, refrho))
    superlogger.info('Mean Density of Avg Map (all voxels): %3.5f', np.mean(average_rho))
    superlogger.info('Std. Dev. of Density (all voxels): %3.5f', np.std(average_rho))
    superlogger.info('RMSD of Density (all voxels): %3.5f', np.sqrt(np.mean(np.square(average_rho))))
    idx = np.where(np.abs(average_rho)>0.01*average_rho.max())
    superlogger.info('Modified Mean Density (voxels >0.01*max): %3.5f', np.mean(average_rho[idx]))
    superlogger.info('Modified Std. Dev. of Density (voxels >0.01*max): %3.5f', np.std(average_rho[idx]))
    superlogger.info('Modified RMSD of Density (voxels >0.01*max): %3.5f', np.sqrt(np.mean(np.square(average_rho[idx]))))
    saxs.write_mrc(average_rho, sides[0], output+'_avg.mrc')

    #rather than compare two halves, average all fsc's to the reference
    fscs = []
    resns = []
    for calc_map in range(len(aligned)):
        fsc_map = saxs.calc_fsc(aligned[calc_map],refrho,sides[0])
        fscs.append(fsc_map)
        resn_map = saxs.fsc2res(fsc_map)
        resns.append(resn_map)

    fscs = np.array(fscs)

    #save a file containing all fsc curves
    fscs_header = ['res(1/A)']
    for i in kept_ids:
        ioutput = output+"_"+str(i)+"_aligned"
        fscs_header.append(ioutput)
    #add the resolution as the first column
    fscs_for_file = np.vstack((fscs[0,:,0],fscs[:,:,1])).T
    np.savetxt(output+'_allfscs.dat',fscs_for_file,delimiter=" ",fmt="%.5e",header=",".join(fscs_header))