Esempio n. 1
0
def main():
    args = parse_cmd()
    infile = args.infile
    if args.outputfile is None:
        outputfile = infile[:-4] + '_with_cid.pdb'
    else:
        outputfile = args.outputfile
    cf.backup_file(outputfile)
    natoms = int(args.natoms)
    exresname = args.exresname
    doit(infile, outputfile, natoms, exresname)
Esempio n. 2
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
              )
Esempio n. 3
0
#!/usr/bin/env python

import shutil
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-f", dest="inf", required=True)
args = parser.parse_args()

from common_func import backup_file
# The script will cause error if comment comtains "="
# But I won't debug now since it's enough for now for personal use

old_file = backup_file(args.inf)                                      # the returned backuped file

lines = []
with open(old_file) as inf:
    for line in inf:
        if not line.startswith(';') and line.strip():
            k, tropov = [i.strip() for i in line.split('=')]  # key, tropo_value
            if ';' in tropov:
                v, comv = tropov.split(';')         # comv: comment in the value
                v = v.split()
                comv = '; ' + comv.strip()
            else:
                comv = ' '
                v = tropov.split()
            v = ''.join(i.strip().ljust(15) for i in v)
            lines.append("{0:30s} = {1:30s}{2}\n".format(k, v, comv))
        else:
            lines.append(line)