Esempio n. 1
0
def DrawMutatedStats(options, mutated_freqs, mutation_pos, log, min_mult):
    hist_name1 = os.path.join(options.output_dir, "mutated_seq_freqs.png")
    freq_hist_settings = drawing_utils.GetGraphicalSettings(
        xlabel="Mutated sequence frequency (>" + str(min_mult) + ")",
        ylabel="# sequences",
        output_filename=hist_name1)
    drawing_utils.DrawHistogram(mutated_freqs, freq_hist_settings)
    if os.path.exists(hist_name1):
        log.info(
            "* Histogram of distribution of mutated sequence frequencies was written to "
            + hist_name1)
    else:
        log.info(
            "ERROR: Histogram of distribution of mutated sequence frequencies was not found"
        )
        sys.exit(1)

    hist_name2 = os.path.join(options.output_dir, "shm_positions.png")
    pos_hist_settings = drawing_utils.GetGraphicalSettings(
        xlabel="Relative SHM position",
        ylabel="# SHMs",
        output_filename=hist_name2)
    drawing_utils.DrawMutationHistogram(mutation_pos, pos_hist_settings,
                                        options.chain_type)
    if os.path.exists(hist_name2):
        log.info(
            "* Histogram of distribution of SHM positions was written to " +
            hist_name2)
    else:
        log.info(
            "ERROR: Histogram of distribution of SHM positions was not found")
        sys.exit(1)
Esempio n. 2
0
def DrawBaseStats(options, base_lens, base_freqs, log, min_mult):
    hist_name1 = os.path.join(options.output_dir, "base_seq_lens.png")
    len_hist_settings = drawing_utils.GetGraphicalSettings(
        xlabel="Sequence length",
        ylabel="# sequences",
        output_filename=hist_name1)
    drawing_utils.DrawHistogram(base_lens, len_hist_settings)
    if os.path.exists(hist_name1):
        log.info(
            "* Histogram of distribution of base sequence lengths was written to "
            + hist_name1)
    else:
        log.info(
            "ERROR: Histogram of distribution of base sequence lengths was not found"
        )
        sys.exit(1)

    hist_name2 = os.path.join(options.output_dir, "base_seq_freqs.png")
    freq_hist_settings = drawing_utils.GetGraphicalSettings(
        xlabel="Base sequence frequency (>" + str(min_mult) + ")",
        ylabel="# sequences",
        output_filename=hist_name2)
    drawing_utils.DrawHistogram(base_freqs, freq_hist_settings)
    if os.path.exists(hist_name2):
        log.info(
            "* Histogram of distribution of base sequence frequencies was written to "
            + hist_name2)
    else:
        log.info(
            "ERROR: Histogram of distribution of base sequence frequencies was not found"
        )
        sys.exit(1)
fname = sys.argv[1]  #'opt_kmers_tau_4_k_35.txt'
lines = open(fname, 'r').readlines()
rel_pos = list()
for l in lines:
    splits = l.strip().split()
    length = int(splits[1])
    for i in range(2, len(splits)):
        rel_pos.append(float(splits[i]) / length)
#print rel_pos
figure_fname = fname.split('.')[0] + '.pdf'
settings = drawing_utils.GetGraphicalSettings(
    xlabel="Representative k-mer positions",
    ylabel="# k-mers",
    title="",
    output_filename=figure_fname,
    bins=100,
    label="",
    histtype="bar",
    xlog_scale=False,
    ylog_scale=False,
    draw_legend=False,
    colors="",
    legend_loc='upper right',
    show_xaxis=True,
    show_yaxis=True,
    xmin_shift=0,
    xmax_shift=0,
    ymin_shift=0,
    ymax_shift=0)
drawing_utils.DrawMutationHistogram(rel_pos, settings)