예제 #1
0
def main(args):
    if args.debug:
        main_load()

    # check the validity of output file name, do backup
    output = args.optf
    if output is None:
        outputfile = '{0:s}.output.xvg'.format(args.grof)
    else:
        outputfile = output
    backup_old_output(outputfile)

    # Do some logging at the beginning
    outputf = open(outputfile, 'w')
    beginning_time = write_header(outputf)

    # do calculation
    result = calc_bond_length(args.grof, args.xtcf, args.btime, args.etime,
                              args.debug)

    # write results to the outputfile
    for r in result:
        outputf.write(r)

    # Do some logging at the end
    write_footer(outputf, beginning_time)

    outputf.close()
예제 #2
0
파일: unvp.py 프로젝트: zyxue/pymyg_tools
def main(ARGS):
    if ARGS.debug:
        main_load()

    # check the validity of output file name, do backup
    output = ARGS.optf
    if output is None:
        outputfile = '{0:s}.output.xvg'.format(ARGS.grof)
    else:
        outputfile = output
    backup_old_output(outputfile)

    # Do some logging at the beginning
    outputf = open(outputfile, 'w')
    beginning_time = write_header(outputf)

    # do calculation
    result = count_interactions(
        ARGS.grof, 
        ARGS.xtcf, 
        ARGS.btime,
        ARGS.cutoff * 10,                          # convert to angstrom from nm
        ARGS.debug)

    # write results to the outputfile
    outputf.write('# {0:>10s}{1:>8s}\n'.format('time', 'num'))
    for r in result:
        outputf.write(r)

    # Do some logging at the end
    write_footer(outputf, beginning_time)

    outputf.close()
예제 #3
0
def main(args):
    utils.main_load()

    # check the validity of output file name, do backup
    output = args.optf
    if output is None:
        outputfile = '{0:s}.output.xvg'.format(args.grof)
    else:
        outputfile = output

    utils.backup(outputfile)

    # Do some logging at the beginning
    outputf = open(outputfile, 'w')
    beginning_time = utils.write_header(outputf)

    # do calculation
    result = calc_dihedral(args.grof, args.xtcf, args.btime, args.etime)

    # write results to the outputfile
    for r in result:
        outputf.write(r)

    # Do some logging at the end
    utils.write_footer(outputf, beginning_time)

    outputf.close()
예제 #4
0
def main(args):
    utils.main_load()

    # check the validity of output file name, do backup
    output = args.optf
    if output is None:
        outputfile = '{0:s}.output.xvg'.format(args.grof)
    else:
        outputfile = output

    utils.backup(outputfile)

    # Do some logging at the beginning
    outputf = open(outputfile, 'w')
    beginning_time = utils.write_header(outputf)

    # do calculation
    result = calc_dihedral(args.grof, args.xtcf, args.btime, args.etime)

    # write results to the outputfile
    for r in result:
        outputf.write(r)

    # Do some logging at the end
    utils.write_footer(outputf, beginning_time)

    outputf.close()
예제 #5
0
def main(ARGS):
    if ARGS.debug:
        main_load()

    # check the validity of output file name, do backup
    output = ARGS.optf
    if output is None:
        outputfile = '{0:s}.output.xvg'.format(ARGS.grof)
    else:
        outputfile = output
    backup_old_output(outputfile)

    # Do some logging at the beginning
    outputf = open(outputfile, 'w')
    beginning_time = write_header(outputf)

    # do calculation
    result = count_interactions(
        ARGS.grof,
        ARGS.xtcf,
        ARGS.btime,
        ARGS.cutoff * 10,  # convert to angstrom from nm
        ARGS.debug)

    # write results to the outputfile
    outputf.write('# {0:>10s}{1:>8s}\n'.format('time', 'num'))
    for r in result:
        outputf.write(r)

    # Do some logging at the end
    write_footer(outputf, beginning_time)

    outputf.close()
예제 #6
0
def main(args):
    utils.main_load()
    outputfile =  args.optf if args.optf else '{0:s}.sespacing.xvg'.format(args.grof)
    utils.backup(outputfile)
    outputf = open(outputfile, 'w')
    beginning_time = utils.write_header(outputf)

    # This line will be used when there is a better code design
    # if ARGS.atom_sel is None:
    #     raise ValueError("atom_selection must be specified, check --atom_selection option!")

    # do calculation
    ijdist_dict = sequence_spacing(args.grof, args.xtcf, args.btime, args.etime,
                                   args.peptide_length, args.atom_sel)

    # cannot yield from sequence_spacing function because the result cannot be
    # calculated until all frames have been looped through

    # write headers
    outputf.write('# {0:8s}{1:20s}{2:20s}{3:10s}\n'.format('i-j', 'average', 'std', 'num_of_data_points'))
    # write results to the outputfile
    for k in sorted(ijdist_dict.keys()):
        data = np.array(ijdist_dict[k])
        mean = data.mean()                      # mean of ijdist
        std = data.std()                        # standard deviation of ijdist
        num = len(data)                         # num of data in that ijdist
        outputf.write('{0:8d}{1:20.8f}{2:20.8f}{3:10d}\n'.format(k, mean, std, num))

    # Do some logging at the end
    utils.write_footer(outputf, beginning_time)
    outputf.close()
예제 #7
0
def main(args):
    utils.main_load()
    outputfile = args.optf if args.optf else '{0:s}.sespacing.xvg'.format(
        args.grof)
    utils.backup(outputfile)
    outputf = open(outputfile, 'w')
    beginning_time = utils.write_header(outputf)

    # This line will be used when there is a better code design
    # if ARGS.atom_sel is None:
    #     raise ValueError("atom_selection must be specified, check --atom_selection option!")

    # do calculation
    ijdist_dict = sequence_spacing(args.grof, args.xtcf, args.btime,
                                   args.etime, args.peptide_length,
                                   args.atom_sel)

    # cannot yield from sequence_spacing function because the result cannot be
    # calculated until all frames have been looped through

    # write headers
    outputf.write('# {0:8s}{1:20s}{2:20s}{3:10s}\n'.format(
        'i-j', 'average', 'std', 'num_of_data_points'))
    # write results to the outputfile
    for k in sorted(ijdist_dict.keys()):
        data = np.array(ijdist_dict[k])
        mean = data.mean()  # mean of ijdist
        std = data.std()  # standard deviation of ijdist
        num = len(data)  # num of data in that ijdist
        outputf.write('{0:8d}{1:20.8f}{2:20.8f}{3:10d}\n'.format(
            k, mean, std, num))

    # Do some logging at the end
    utils.write_footer(outputf, beginning_time)
    outputf.close()
예제 #8
0
def main(args):
    if args.debug:
        main_load()

    # check the validity of output file name, do backup
    output = args.optf
    if output is None:
        outputfile = '{0:s}.output.xvg'.format(args.grof)
    else:
        outputfile = output
    backup_old_output(outputfile)

    # Do some logging at the beginning
    outputf = open(outputfile, 'w')
    beginning_time = write_header(outputf)

    # do calculation
    result = calc_bond_length(
        args.grof,
        args.xtcf,
        args.btime,
        args.etime,
        args.debug)

    # write results to the outputfile
    for r in result:
        outputf.write(r)

    # Do some logging at the end
    write_footer(outputf, beginning_time)

    outputf.close()
예제 #9
0
def main(args):
    main_load()

    output = args.optf
    if output is None:
        outputfile = '{0:s}.output.xtc'.format(args.tprf)
    else:
        outputfile = output
    backup(outputfile)

    # do calculation
    trjcat_plus(args.xtcf, args.tprf, outputfile)
예제 #10
0
def main(args):
    U.main_load()
    outputfile = args.optf if args.optf else '{0:s}.rama.xvg'.format(args.grof)
    U.backup(outputfile)
    outputf = open(outputfile, 'w')
    beginning_time = U.write_header(outputf)

    result = calc_rama(args.grof, args.xtcf, args.btime, args.etime)

    # write headers
    outputf.write('# {0:>10s}{1:>8s}\n'.format('phi', 'psi', 'resname-resid'))
    # write results to the outputfile
    for r in result:
        outputf.write(r)

    # Do some logging at the end
    U.write_footer(outputf, beginning_time)
    outputf.close()
예제 #11
0
파일: unun.py 프로젝트: zyxue/pymyg_tools
def main(args):
    utils.main_load()
    outputfile =  args.optf if args.optf else '{0:s}.unun.xvg'.format(args.grof)
    utils.backup(outputfile)
    outputf = open(outputfile, 'w')
    beginning_time = utils.write_header(outputf)

    result = count_interactions(args.grof, args.xtcf, args.btime, args.etime, args.cutoff)

    # write headers
    outputf.write('# {0:>10s}{1:>8s}\n'.format('time', 'num'))
    # write results to the outputfile
    for r in result:
        outputf.write(r)

    # Do some logging at the end
    utils.write_footer(outputf, beginning_time)
    outputf.close()
예제 #12
0
def main(args):
    U.main_load()
    outputfile =  args.optf if args.optf else '{0:s}.rama.xvg'.format(args.grof)
    U.backup(outputfile)
    outputf = open(outputfile, 'w')
    beginning_time = U.write_header(outputf)

    result = calc_rama(args.grof, args.xtcf, args.btime, args.etime)

    # write headers
    outputf.write('# {0:>10s}{1:>8s}\n'.format('phi', 'psi', 'resname-resid'))
    # write results to the outputfile
    for r in result:
        outputf.write(r)

    # Do some logging at the end
    U.write_footer(outputf, beginning_time)
    outputf.close()
예제 #13
0
파일: unun.py 프로젝트: zyxue/pymyg_tools
def main(args):
    utils.main_load()
    outputfile = args.optf if args.optf else '{0:s}.unun.xvg'.format(args.grof)
    utils.backup(outputfile)
    outputf = open(outputfile, 'w')
    beginning_time = utils.write_header(outputf)

    result = count_interactions(args.grof, args.xtcf, args.btime, args.etime,
                                args.cutoff)

    # write headers
    outputf.write('# {0:>10s}{1:>8s}\n'.format('time', 'num'))
    # write results to the outputfile
    for r in result:
        outputf.write(r)

    # Do some logging at the end
    utils.write_footer(outputf, beginning_time)
    outputf.close()
예제 #14
0
def main(cmd_args):
    args = get_args(cmd_args)

    utils.main_load()

    output = args.optf
    if output is None:
        # it's a log since the results are written to the h5 file directly
        outputfile = '{0:s}.output.log'.format(args.grof)
    else:
        outputfile = output

    utils.backup(outputfile)

    outputf = open(outputfile, 'w')
    beginning_time = utils.write_header(outputf)

    A = args
    if not os.path.exists(A.h5):
        raise IOError('{0} does not exist'.format(A.h5))

    # *10: convert to angstrom from nm
    result = count_interactions(A)
    path = os.path.join('/', os.path.dirname(A.xtcf))
    tb_name = os.path.join(path, 'unun_map')

    h5 = tables.openFile(A.h5, mode='a')
    if h5.__contains__(tb_name):
        logger.info(
            'found {0} already in {0}, replacing with new calculated values'.
            format(tb_name, A.h5))
        _ = h5.getNode(tb_name)
        _.remove()
    h5.createArray(where=path, name='unun_map', object=result)
    h5.close()

    utils.write_footer(outputf, beginning_time)
    outputf.close()
예제 #15
0
def main(cmd_args):
    args = get_args(cmd_args)

    utils.main_load()
    
    output = args.optf
    if output is None:
        # it's a log since the results are written to the h5 file directly
        outputfile = '{0:s}.output.log'.format(args.grof)
    else:
        outputfile = output

    utils.backup(outputfile)

    outputf = open(outputfile, 'w')
    beginning_time = utils.write_header(outputf)

    A = args
    if not os.path.exists(A.h5): 
        raise IOError('{0} does not exist'.format(A.h5))

    # *10: convert to angstrom from nm
    result = count_interactions(A)
    path = os.path.join('/', os.path.dirname(A.xtcf))
    tb_name = os.path.join(path, 'unun_map')

    h5 = tables.openFile(A.h5, mode='a')
    if h5.__contains__(tb_name):
        logger.info('found {0} already in {0}, replacing with new calculated values'.format(tb_name, A.h5))
        _ = h5.getNode(tb_name)
        _.remove()
    h5.createArray(where=path, name='unun_map', object=result)
    h5.close()

    utils.write_footer(outputf, beginning_time)
    outputf.close()