def main(options): infs = options.fs len_infs = len(infs) if options.mysys: from Mysys import read_mysys_dat mysys = read_mysys_dat() else: mysys = None if options.overlap: overlap = options.overlap assert len_infs % overlap== 0, "the num of infiles ({0}) are not even to do overlap ({1})".format( len_infs, overlap) row, col = q_acc.det_row_col(len_infs / overlap, options.morer) else: overlap = 1 row, col = q_acc.det_row_col(len_infs, options.morer) fig = plt.figure(figsize=(24, 11)) xs, ys, keys, axes = {}, {}, [], [] for k, inf in enumerate(infs): logger.info("working on {0}".format(inf)) if k % overlap == 0: ax = fig.add_subplot(row, col, k / overlap + 1) if options.template_for_legend: legend = re.compile(options.template_for_legend).search(inf).group() else: legend = inf if mysys: # need further modification to choose color in terms of solute or solvent group = re.compile('sq[1-9][wmepov]\d{3,4}s[0-9][0-9]').search(inf).group() seq = group[:3] color = mysys[seq].color marker = mysys[seq].marker legend = mysys[seq].seq else: color = None # specified by matplotlib automatically marker = None key = inf # use the file name as a key # collection of x & y will be used to determine the xlim & ylim x, y = ax_plot(inf, ax, legend, color, marker, options.eb) axes.append(ax) keys.append(key) xs[key], ys[key] = x, y blegend, xlb, ylb, xb, yb, xe, ye = (options.blegend, options.xlb, options.ylb, options.xb, options.yb, options.xe, options.ye) q_acc.decorate(keys, xs, ys, axes, blegend, xlb, ylb, xb, yb, xe, ye) q_acc.show_or_save(options.of)
#!/usr/bin/env python import glob import numpy as np from q_acc import parse_cmd from Mysys import read_mysys_dat mysys = read_mysys_dat() """ it's slow, could be improved a lot 2011-04-04""" def outline(infile): with open(infile, 'r') as inf: calc_secondary_structures(inf) def get_data(inf): for line in inf: if (not line.startswith('#') and not line.startswith('@') and line.strip()): yield line.strip().split()[:2] def calc_secondary_structures(inf): lines = np.array(list(get_data(inf))) # lines = np.array(get_data(inf)) phi = lines[:,0] psi = lines[:,1] h, phip, psip = np.histogram2d(phi, psi, bins=10) return h, phip, psip