def fasta_to_plot_group(fasta_file, output_dir): lengths = [] with FastaReader(fasta_file) as f: for record in f: lengths.append(len(record.sequence)) from pbreports.plot.helper import get_fig_axes from pbreports.model.model import PlotGroup, Plot fig, ax = get_fig_axes() if len(lengths) == 1: v = lengths[0] hrange = (v -1, v + 1) ax.hist(lengths, range=hrange) else: ax.hist(lengths) ax.set_title("Sequence Length Histogram") ax.set_xlabel("Sequence Length") name = "sequence_length_hist.png" png_path = os.path.join(output_dir, name) fig.savefig(png_path) plots = [Plot("sequence_lengths", name)] pg = PlotGroup("reference_hist", "Sequence Lengths", plots=plots) return pg
def fasta_to_plot_group(fasta_file, output_dir): lengths = [] with FastaReader(fasta_file) as f: for record in f: lengths.append(len(record.sequence)) from pbreports.plot.helper import get_fig_axes #pylint: disable=import-error from pbcommand.models.report import PlotGroup, Plot fig, ax = get_fig_axes() if len(lengths) == 1: v = lengths[0] hrange = (v - 1, v + 1) ax.hist(lengths, range=hrange) else: ax.hist(lengths) ax.set_title("Sequence Length Histogram") ax.set_xlabel("Sequence Length") name = "sequence_length_hist.png" png_path = os.path.join(output_dir, name) fig.savefig(png_path) plots = [Plot("sequence_lengths", name)] pg = PlotGroup("reference_hist", "Sequence Lengths", plots=plots) return pg
def fasta_to_plot_group(fasta_file, output_dir): lengths = [] with FastaReader(fasta_file) as f: for record in f: lengths.append(len(record.sequence)) from pbreports.plot.helper import get_fig_axes from pbreports.model.model import PlotGroup, Plot fig, ax = get_fig_axes() ax.hist(lengths) ax.set_title("Sequence Length Histogram") ax.set_xlabel("Sequence Length") name = "sequence_length_hist.png" png_path = os.path.join(output_dir, name) fig.savefig(png_path) plots = [Plot("sequence_lengths", name)] pg = PlotGroup("reference_hist", "Sequence Lengths", plots=plots) return pg