Exemplo n.º 1
0
def main():
    """
    basically it verifies the options and conf_dict first, then loop_xvgs,
    passing whatever should be parsed, ugly code!!! aaaaaahhh....
    """
    args = parse_cmd()

    # Verify the iterms in args
    conf = args.conf
    if not os.path.exists(conf):
        raise IOError("{0} cannot found".format(conf))

    conf_dict = ConfigObj(conf)
    SEQS, CDTS, TMPS, NUMS = argparse_action.get_sctn(args, conf_dict['system'])

    h5filename = conf_dict['data']['h5filename']
    title      = conf_dict['data']['title']

    # About the property
    ppty = args.ppty
    p_conf = conf_dict['properties'][ppty]         # property configuration
    property_obj = h5t.Property(ppty)              # including table desc & schema

    try:
        ogd = p_conf['ogd']                    # contains xvg_name and table_name patterns
    except KeyError:
        print "#" * 20
        print '"ogd" not specified in {0} in {1}'.format(ppty, conf)
        print "#" * 20
        sys.exit(1)

    if not args.nobk:
        backup_file(h5filename) # later when this script matures, this step may not be necessary

    # Start dealing with the h5 file now
    h5file = tables.openFile(h5filename, mode="a", title=title)
    filters = tables.Filters(complevel=8, complib='zlib')

    # zx_create_group is redundant and ugly code, I amd looking for a way to
    # overwrite creatGroup in table.file.File 2012-03-16
    ppty_group = zx_create_group(h5file, '/', ppty, filters=filters, title=property_obj.desc)   # property group
    ogd_group = zx_create_group(h5file, ppty_group._v_pathname, 'ogd', filters)
    ogd_path = ogd_group._v_pathname # should == ogd_path = os.path.join('/', ppty, 'ogd')

    # loop through xvg files and create a table for each one
    # ugly code!!! aaaaaahhh Should I learn loop? and make it more clear!
    # parsing so many args are really confusing
    loop_xvgs(SEQS, CDTS, TMPS, NUMS,
              ppty, h5file, property_obj, ogd, ogd_path
              )
Exemplo n.º 2
0
def main():
    args = parse_cmd()

    # initialization YOU DIAN LUANG!

    conf = args.conf
    if not os.path.exists(conf):
        raise IOError("{0} cannot found".format(conf))

    conf_dict = ConfigObj(conf)
    SEQS, CDTS, TMPS, NUMS = get_sctn(args, conf_dict['systems'])

    h5filename = conf_dict['data']['h5filename']
    if not os.path.exists(h5filename):
        raise IOError("{0} cannot found".format(h5filename))

    ppty = args.ppty
    tpostproc = args.tpostproc                               # type of postprocess. i.e. ave, alx

    tpostproc_kwargs = conf_dict['postprocess'][tpostproc]

    rootUEP = os.path.join('/', ppty)

    # start dealing with the h5 file
    h5file = tables.openFile(h5filename, 'a', rootUEP=rootUEP)

    tpostproc_group_path = os.path.join('/', tpostproc)

    if h5file.__contains__(tpostproc_group_path):
        tpostproc_group = h5file.getNode(h5file.root, tpostproc)
    else:
        # meaning it's the first time to run tpostproc postprocess for this ppty
        tpostproc_group = h5file.createGroup(h5file.root, tpostproc)

    if args.tpostproc in ['ave', 'ave10']:
        loop_h5_ave(SEQS, CDTS, TMPS, NUMS, h5file, ppty, tpostproc_group, tpostproc_kwargs)
    if args.tpostproc == 'alx':
        loop_h5_alx(SEQS, CDTS, TMPS, NUMS, h5file, ppty, tpostproc_group, tpostproc_kwargs)
Exemplo n.º 3
0
def main():
    # determine which function to call
    g_tool, args = gai.target_the_type_of_analysis()
    g_tool_name =  g_tool.func_name   # directory will be named after func_name

    config_file = args.config_file
    if not os.path.exists(config_file):
        raise ValueError('configuration file: {0} may not exist!'.format(config_file))
    config_dict = ConfigObj(config_file)

    SEQS, CDTS, TMPS, NUMS = aa.get_sctn(args, config_dict['system'])
    
    dirchy_dict = config_dict['dirchy']
    directory_hierarchy = dirchy(SEQS, CDTS, TMPS, NUMS, dirchy_dict)

    # confirm outpudir path, if not specified either in cmd or in the
    # configuration file, 'R_OUTPUT" will be used in the current directory
    # to avoid scinet crash.
    if args.outputdir:
        outputdir = args.outputdir
    elif config_dict['data'].has_key('outputdir'):
        v = config_dict['data']['outputdir']
        if len(v) > 0 and v:                     # make sure v is not '' or None
            outputdir = v
        else:
            outputdir = 'R_OUTPUT'
    else:
        outputdir = 'R_OUTPUT'

    if not os.path.exists(outputdir):
        os.mkdir(outputdir)

    # parent_logd holds all the logs which keep the output of analysis tools
    parent_logd = os.path.join(outputdir, 'LOGS') 
    # just mkdir parent_logd no matter testing or not
    if not os.path.exists(parent_logd):
        os.mkdir(parent_logd)
                           
    logd = os.path.join(
        outputdir, 'LOGS', '{0}_log'.format(g_tool_name)
        ) if not args.nolog else None

    if logd and not os.path.exists(logd):
        os.mkdir(logd)

    # now you have g_tool, g_tool_name, outputdir, logd, directory_hierarchy
    x = gen_input_args(g_tool, g_tool_name, outputdir, logd, directory_hierarchy,
                       args.test, args.cdb, args.toa, args.btime, args.etime, args.dt, 
                       config_dict)
    gai.runit(x, args.numthread, args.test)

    separator =  "#" * 79
    print separator
    dd = args.__dict__
    # update variables that are read from the config file
    dd['SEQS'] = SEQS
    dd['CDTS'] = CDTS
    dd['TMPS'] = TMPS
    dd['NUMS'] = NUMS
    for k in sorted(dd):
        print "{0:>20s}:{1}".format(k, dd[k])
    print separator