def gen_input_args(g_tool, g_tool_name, outputdir, logd, directory_hierarchy, ftest, fcdb, toa, btime, etime, dt, CONFIG_DICT): """ generate "input_args", which in a dictionary that holds all the varaibles needed for your commands """ for inputdir, pf, seq, cdt, tmp, num in directory_hierarchy: input_args = dict(inputdir=inputdir, pf=pf, seq=seq, cdt=cdt, num=num) # gen paths for input files: # (when organizing, input files could also be outputfiles) # xtcf, grof, proxtcf, progrof, tprf, edrf, ndxf input_args.update(gen_input_files(inputdir, pf)) # if g_tool is from organize module, no new dir needs to be created # to compare string, is doesn't work (confirmed) if not g_tool.__module__ == 'g_analyze.organize': # anadir should be a subfolder under outputdir anadir = os.path.join(outputdir, 'r_' + g_tool_name) input_args['anadir'] = anadir if not os.path.exists(anadir) and not ftest: os.mkdir(anadir) # this part will be improved later, particular when using a database if fcdb: import connect_db as cdb ss = cdb.connect_db(CONFIG_DICT['database']) query = ss.query(cdb.Cutoff_rg_alltrj).filter_by(sqid=seq) time_for_b = query.value(cdt) input_args['b'] = time_for_b else: input_args['b'] = 0 # default # particular to make_ndx if toa == 'g_make_ndx': ndx_id = CONFIG_DICT['ndx_input'] # ndx_input_dict ndx_fd = CONFIG_DICT['ndx_format'] # ndx_format_dict # from pprint import pprint as pp input_args['ndx_input'] = ' '.join( [ndx_id[ndx_fd[f].format(**locals())] for f in ndx_fd] ) if toa == 'g_select': input_args['g_select_select'] = ("'" + CONFIG_DICT['g_select']["seq"] + CONFIG_DICT['g_select'][ cdt ] + "'") # particular to sequence_spacing, maybe later toa need also to be # checked for other analysis, as well. if toa == 'sequence_spacing': from mysys import read_mysys mysys = read_mysys.read() # input_args['peptide_length'] = mysys[seq].len input_args['peptide_length'] = mysys[seq].len # when analyzing ff_comparison if toa == 'trjorder': from mysys import read_mysys mysys = read_mysys.read() try: input_args['NA'] = mysys[cdt].natom # when analyzing ff_comparison except KeyError: print "ASSUME NUMBER OF ATOMS PER SOLVENT MOLECULE IS THAT OF WATER: {0}".format(mysys['w'].natom) input_args['NA'] = mysys['w'].natom # input_args['bin'] = os.path.join(os.environ['HOME'], "exec/gromacs-4.0.5/exec/bin/") # dirty, fix later! input_args['bin'] = os.path.join(os.environ['HOME'], "exec/gromacs-4.5.5/exec/bin/") if cdt in ['h', 'f']: # Heptanol input_args['bin'] = os.path.join(os.environ['HOME'], "exec/gromacs-4.5.5/exec/bin/") # if cdt in ['h', 'f']: # Heptanol # os.environ['PATH'] = (os.path.join(os.environ['HOME'], # "exec/gromacs-4.5.5/exec/bin/") # + os.environ['PATH']) input_args['pwd'] = os.getenv('PWD') input_args['b'] = btime # beginning time input_args['e'] = etime # endding time input_args['dt'] = dt # endding time # generate the command that is gonna be executed cmd = g_tool(input_args) logf = os.path.join(logd, '{0}.log'.format(pf)) if logd else None yield (cmd, logf)
#!/usr/bin/env from mysys import read_mysys MYSYS = read_mysys.read() def calc_ave_dd(seq, cdt): dd = { 'rg_c_alpha': [1., 'rg'], 'rg_whole_length': [1., 'rg'], 'rg_backbone': [1., 'rg'], 'e2ed': [1., 'e2ed'], } # ppty_name: [denominator, interested_col] if seq in MYSYS: dd.update( { 'dssp_E': [float(MYSYS[seq].len), 'structure'], 'dssp_H': [float(MYSYS[seq].len), 'structure'], 'dssp_T': [float(MYSYS[seq].len), 'structure'], 'dssp_G': [float(MYSYS[seq].len), 'structure'], 'dssp_I': [float(MYSYS[seq].len), 'structure'], 'dssp_B': [float(MYSYS[seq].len), 'structure'], 'dssp_C': [float(MYSYS[seq].len), 'structure'], 'dssp_S': [float(MYSYS[seq].len), 'structure'], 'dssp_X': [float(MYSYS[seq].len), 'structure'], 'upup' : [float(MYSYS[seq].hbg), 'upup' ], # g_mindist_excl1 double counts the contact, so divided by 2 'unun' : [float(MYSYS[seq].scnpg * 2),'unun'],