How to use the multiqc.utils.config function in multiqc

To help you get started, we’ve selected a few multiqc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ewels / MultiQC / multiqc / modules / base_module.py View on Github external
def clean_s_name(self, s_name, root):
        """ Helper function to take a long file name and strip it
        back to a clean sample name. Somewhat arbitrary.
        :param s_name: The sample name to clean
        :param root: The directory path that this file is within
        :param prepend_dirs: boolean, whether to prepend dir name to s_name
        :param trimmed: boolean, remove common trimming suffixes from name?
        :return: The cleaned sample name, ready to be used
        """
        if root is None:
            root = ''
        # Split then take first section to remove everything after these matches
        for ext in config.fn_clean_exts:
            s_name = s_name.split(ext ,1)[0]
        if config.prepend_dirs:
            s_name = "{} | {}".format(root.replace(os.sep, ' | '), s_name).lstrip('. | ')
        return s_name
github ewels / MultiQC / multiqc / multiqc.py View on Github external
config.analysis_dir = [os.path.realpath(d) for d in config.analysis_dir]
    report_output = j_template.render(report=report, config=config)
    if filename == 'stdout':
        print(report_output.encode('utf-8'), file = sys.stdout)
    else:
        try:
            with io.open (config.output_fn, "w", encoding='utf-8') as f:
                print(report_output, file=f)
        except IOError as e:
            raise IOError ("Could not print report to '{}' - {}".format(config.output_fn, IOError(e)))

        # Copy over files if requested by the theme
        try:
            for f in template_mod.copy_files:
                fn = os.path.join(tmp_dir, f)
                dest_dir = os.path.join( os.path.dirname(config.output_fn), f)
                copy_tree(fn, dest_dir)
        except AttributeError:
            pass # No files to copy

    # Clean up temporary directory
    shutil.rmtree(tmp_dir)

    # Zip the data directory if requested
    if config.zip_data_dir and config.data_dir is not None:
        shutil.make_archive(config.data_dir, 'zip', config.data_dir)
        shutil.rmtree(config.data_dir)

    # Try to create a PDF if requested
    if make_pdf:
        try:
            pdf_fn_name = config.output_fn.replace('.html', '.pdf')
github ewels / MultiQC / multiqc / multiqc.py View on Github external
config.analysis_dir = analysis_dir
    if outdir is not None:
        config.output_dir = outdir
    if no_clean_sname:
        config.fn_clean_sample_names = False
        logger.info("Not cleaning sample names")
    if make_data_dir:
        config.make_data_dir = True
    if no_data_dir:
        config.make_data_dir = False
    if force:
        config.force = True
    if ignore_symlinks:
        config.ignore_symlinks = True
    if zip_data_dir:
        config.zip_data_dir = True
    if data_format is not None:
        config.data_format = data_format
    if export_plots:
        config.export_plots = True
    if plots_flat:
        config.plots_force_flat = True
    if plots_interactive:
        config.plots_force_interactive = True
    if lint:
        config.lint = True
        lint_helpers.run_tests()
    if make_pdf:
        config.template = 'simple'
    if no_megaqc_upload:
        config.megaqc_upload = False
    else:
github ewels / MultiQC / multiqc / templates / default_dev / __init__.py View on Github external
template_parent = 'default'

base64_plots = False

template_dir = os.path.dirname(__file__)
base_fn = 'base.html'

output_subdir = 'multiqc_report'
copy_files = ['assets']

# This has already been done in the main script, do now if it was false
if not config.export_plots:
    tmp_dir = config.data_tmp_dir.rstrip('multiqc_data')
    config.plots_tmp_dir = os.path.join(tmp_dir, 'multiqc_plots')
    config.plots_dir = config.plots_tmp_dir
    if not os.path.exists(config.plots_dir):
        os.makedirs(config.plots_dir)
config.export_plots = True
github ewels / MultiQC / multiqc / plots / bargraph.py View on Github external
def get_template_mod():
    global _template_mod
    if not _template_mod:
        _template_mod = config.avail_templates[config.template].load()
    return _template_mod
github ewels / MultiQC / multiqc / multiqc.py View on Github external
                    type = click.Choice(config.data_format_extensions.keys()),
                    help = "Output parsed data in a different format. Default: {}".format(config.data_format)
)
@click.option('-z', '--zip-data-dir', 'zip_data_dir',
                    is_flag = True,
                    help = "Compress the data directory."
)
@click.option('-p', '--export', 'export_plots',
                    is_flag = True,
                    help = "Export plots as static images in addition to the report"
)
@click.option('-fp', '--flat', 'plots_flat',
                    is_flag = True,
                    help = "Use only flat plots (static images)"
)
@click.option('-ip', '--interactive', 'plots_interactive',
                    is_flag = True,
github ewels / MultiQC / multiqc / __init__.py View on Github external
import logging
from multiqc.utils import config

config.logger = logging.getLogger(__name__)

__version__ = config.version
github ewels / MultiQC / multiqc / multiqc.py View on Github external
if force:
        config.force = True
    if ignore_symlinks:
        config.ignore_symlinks = True
    if zip_data_dir:
        config.zip_data_dir = True
    if data_format is not None:
        config.data_format = data_format
    if export_plots:
        config.export_plots = True
    if plots_flat:
        config.plots_force_flat = True
    if plots_interactive:
        config.plots_force_interactive = True
    if lint:
        config.lint = True
        lint_helpers.run_tests()
    if make_pdf:
        config.template = 'simple'
    if no_megaqc_upload:
        config.megaqc_upload = False
    else:
        config.megaqc_upload = True
    if sample_names:
        config.load_sample_names(sample_names)
    if module_tag is not None:
        config.module_tag = module_tag
    if len(module) > 0:
        config.run_modules = module
    if len(exclude) > 0:
        config.exclude_modules = exclude
    config.kwargs = kwargs # Plugin command line options
github ewels / MultiQC / multiqc / plots / bargraph.py View on Github external
del hc_samples[idx]
                for j, d in enumerate(hc_data):
                    del hc_data[j]['data'][idx]
        if len(hc_data) > 0:
            plotsamples.append(hc_samples)
            plotdata.append(hc_data)

    if len(plotdata) == 0:
        logger.warning('Tried to make bar plot, but had no data')
        return '<p class="text-danger">Error - was not able to plot data.</p>'

    # Make a plot - custom, interactive or flat
    try:
        return get_template_mod().bargraph(plotdata, plotsamples, pconfig)
    except (AttributeError, TypeError):
        if config.plots_force_flat or (not config.plots_force_interactive and len(plotsamples[0]) &gt; config.plots_flat_numseries):
            try:
                return matplotlib_bargraph(plotdata, plotsamples, pconfig)
            except Exception as e:
                logger.error("############### Error making MatPlotLib figure! Falling back to HighCharts.")
                logger.debug(e, exc_info=True)
                return highcharts_bargraph(plotdata, plotsamples, pconfig)
        else:
            # Use MatPlotLib to generate static plots if requested
            if config.export_plots:
                matplotlib_bargraph(plotdata, plotsamples, pconfig)
            # Return HTML for HighCharts dynamic plot
            return highcharts_bargraph(plotdata, plotsamples, pconfig)
github ewels / MultiQC / multiqc / multiqc.py View on Github external
config.prepend_dirs = True
        config.prepend_dirs_depth = dirs_depth
    config.analysis_dir = analysis_dir
    if outdir is not None:
        config.output_dir = outdir
    if no_clean_sname:
        config.fn_clean_sample_names = False
        logger.info("Not cleaning sample names")
    if make_data_dir:
        config.make_data_dir = True
    if no_data_dir:
        config.make_data_dir = False
    if force:
        config.force = True
    if ignore_symlinks:
        config.ignore_symlinks = True
    if zip_data_dir:
        config.zip_data_dir = True
    if data_format is not None:
        config.data_format = data_format
    if export_plots:
        config.export_plots = True
    if plots_flat:
        config.plots_force_flat = True
    if plots_interactive:
        config.plots_force_interactive = True
    if lint:
        config.lint = True
        lint_helpers.run_tests()
    if make_pdf:
        config.template = 'simple'
    if no_megaqc_upload: