示例#1
0
def plot_single_matrix(args):

    cwd = os.getcwd()
    subdir = args.subdir

    os.chdir(subdir)

    FRETfile = args.trace
    FRETr = np.loadtxt(FRETfile)

    # Calculate transition matrix
    tmatrix = tmcalc.get_T_matrix(FRETr,
                                  spacing=args.spacing,
                                  framestep=args.fstep)

    # Unflatten matrix if necessary
    if tmcalc.check_matrix(tmatrix):
        tmatrix = tmcalc.unflatten_matrix(tmatrix)

    # Plot matrix
    if "color" in args.plot_type:
        diff = False
        ptm.plot_matrix(tmatrix, "Transition Matrix", 0, 0.5, diff)
    if "spy" in args.plot_type:
        ptm.spy_matrix(tmatrix, "Non-Zero Transitions")
示例#2
0
def calc_all(args):

    cwd = os.getcwd()

    if args.FRETdir != None:
        os.chdir(args.FRETdir)

    FRETfile = args.FRETfile
    FRET_trace = np.loadtxt(FRETfile)

    os.chdir(cwd)

    if not os.path.isdir(args.savedir):
        os.mkdir(args.savedir)

    os.chdir(args.savedir)

    fstep = args.fstep
    fstep = range(fstep[0], fstep[1] + fstep[2], fstep[2])

    if args.db:
        db = True
    else:
        db = False

    for i in range(len(fstep)):

        T_matrix = tmcalc.get_T_matrix(FRET_trace,
                                       spacing=args.spacing,
                                       framestep=fstep[i],
                                       flatten=False,
                                       db=db)
        np.savetxt("T_matrix_fstep_%s.dat" % fstep[i], T_matrix)

        lagtime = float(fstep[i]) * 0.5

        print "Calculating eigenvalues for frame step %d, lag time %1.1f ps" % (
            fstep[i], lagtime)
        eigs = compute_eigs(T_matrix)
        np.savetxt("Eigenvalues_fstep_%s.dat" % fstep[i],
                   eigs,
                   header="eigenvalues for lag time %1.1f ps" % lagtime)

        if args.ts:
            timescale = compute_time_scale(eigs, lagtime)
            np.savetxt("Calc_time_scales_fstep_%s.dat" % fstep[i], timescale)

    if args.tplot:
        plot_time_scale(fstep)
示例#3
0
def plot_compare(args):

    cwd = os.getcwd()
    subdir = args.subdir
    os.chdir(subdir)

    FRETfile = args.trace
    FRETr = np.loadtxt(FRETfile)

    # Load full experimental transition matrix
    TMfile = args.TMfile
    T_matrix = np.loadtxt(TMfile)

    # Calculate and unflatten transition matrix
    tmatrix = tmcalc.get_T_matrix(FRETr,
                                  spacing=args.spacing,
                                  framestep=args.fstep)
    if tmcalc.check_matrix(tmatrix):
        tmatrix = tmcalc.unflatten_matrix(tmatrix)

    # Calculate experimental matrix
    bin_size = np.size(tmatrix)**0.5
    spacing = 0.1
    lower_ran = spacing * (np.floor(10 * np.min(FRETr)))
    upper_ran = spacing * (np.ceil(10 * np.max(FRETr)))
    ran_size = (lower_ran, upper_ran)
    tmatrix_exp = xtm.tmatrix_exp_calc(T_matrix, bin_size, ran_size, spacing)
    if tmcalc.check_matrix(tmatrix_exp):
        tmatrix_exp = tmcalc.unflatten_matrix(tmatrix_exp)

    # Difference matrix
    diff_matrix = tmatrix - tmatrix_exp
    diff_squared = np.mean(np.abs(diff_matrix))
    print "Average absolute difference is: "
    print diff_squared

    # Generate plots
    if "color" in args.plot_type:
        ptm.plot_matrix(tmatrix, "Simulated Transition Matrix", 0, 0.5)
        ptm.plot_matrix(tmatrix_exp, "Experimental Transition Matrix", 0, 0.5)
        ptm.plot_matrix(diff_matrix,
                        "Transition Probability Differences",
                        -0.5,
                        0.5,
                        diff=True)
    if "spy" in args.plot_type:
        ptm.spy_matrix(tmatrix, "Non-zero entries, simulated")
        ptm.spy_matrix(tmatrix_exp, "Non-zero entries, experimental")
        ptm.spy_matrix(diff_matrix, "Non-zero entries, difference")
示例#4
0
def plot_compare(args):
    
    cwd = os.getcwd()
    subdir = args.subdir
    os.chdir(subdir)
    
    FRETfile = args.trace
    FRETr = np.loadtxt(FRETfile)
    
    # Load full experimental transition matrix
    TMfile = args.TMfile
    T_matrix = np.loadtxt(TMfile)
    
    # Calculate and unflatten transition matrix
    tmatrix = tmcalc.get_T_matrix(FRETr, spacing=args.spacing, framestep=args.fstep)
    if tmcalc.check_matrix(tmatrix):
        tmatrix = tmcalc.unflatten_matrix(tmatrix)
    
    # Calculate experimental matrix
    bin_size = np.size(tmatrix)**0.5
    spacing=0.1
    lower_ran = spacing*(np.floor(10*np.min(FRETr)))
    upper_ran = spacing*(np.ceil(10*np.max(FRETr)))
    ran_size = (lower_ran, upper_ran)
    tmatrix_exp = xtm.tmatrix_exp_calc(T_matrix, bin_size, ran_size, spacing)
    if tmcalc.check_matrix(tmatrix_exp):
        tmatrix_exp = tmcalc.unflatten_matrix(tmatrix_exp)
    
    # Difference matrix
    diff_matrix = tmatrix - tmatrix_exp
    diff_squared = np.mean(np.abs(diff_matrix))
    print "Average absolute difference is: "
    print diff_squared
    
    # Generate plots
    if "color" in args.plot_type:
        ptm.plot_matrix(tmatrix, "Simulated Transition Matrix", 0, 0.5)
        ptm.plot_matrix(tmatrix_exp, "Experimental Transition Matrix", 0, 0.5)
        ptm.plot_matrix(diff_matrix, "Transition Probability Differences", -0.5, 0.5, diff=True)
    if "spy" in args.plot_type:
        ptm.spy_matrix(tmatrix, "Non-zero entries, simulated")
        ptm.spy_matrix(tmatrix_exp, "Non-zero entries, experimental")
        ptm.spy_matrix(diff_matrix, "Non-zero entries, difference")
示例#5
0
def plot_single_matrix(args):
    
    cwd = os.getcwd()
    subdir = args.subdir

    os.chdir(subdir)
    
    FRETfile = args.trace
    FRETr = np.loadtxt(FRETfile)
    
    # Calculate transition matrix
    tmatrix = tmcalc.get_T_matrix(FRETr, spacing=args.spacing, framestep=args.fstep)
    
    # Unflatten matrix if necessary
    if tmcalc.check_matrix(tmatrix):
        tmatrix = tmcalc.unflatten_matrix(tmatrix)

    # Plot matrix
    if "color" in args.plot_type:
        diff = False
        ptm.plot_matrix(tmatrix, "Transition Matrix", 0, 0.5, diff)
    if "spy" in args.plot_type:
        ptm.spy_matrix(tmatrix, "Non-Zero Transitions")