Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'table_title': 'General Statistics',
'save_file': True,
'raw_data_fn':'multiqc_general_stats'
}
report.general_stats_html = table.plot(report.general_stats_data, report.general_stats_headers, pconfig)
else:
config.skip_generalstats = True
# Write the report sources to disk
if config.data_dir is not None:
report.data_sources_tofile()
# Compress the report plot JSON data
logger.info("Compressing plot data")
report.plot_compressed_json = report.compress_json(report.plot_data)
plugin_hooks.mqc_trigger('before_report_generation')
# Data Export / MegaQC integration - save report data to file or send report data to an API endpoint
if (config.data_dump_file or config.megaqc_url) and config.megaqc_upload:
multiqc_json_dump = megaqc.multiqc_dump_json(report)
if config.data_dump_file:
util_functions.write_data_file(multiqc_json_dump, 'multiqc_data', False, 'json')
if config.megaqc_url:
megaqc.multiqc_api_post(multiqc_json_dump)
# Make the final report path & data directories
if filename != 'stdout':
config.output_fn = os.path.join(config.output_dir, config.output_fn_name)
config.data_dir = os.path.join(config.output_dir, config.data_dir_name)
# Check for existing reports and remove if -f was specified
if os.path.exists(config.output_fn) or (config.make_data_dir and os.path.exists(config.data_dir)):
if config.force:
if config.pandoc_template is not None:
pandoc_call.append('--template={}'.format(config.pandoc_template))
logger.debug("Attempting Pandoc conversion to PDF with following command:\n{}".format(' '.join(pandoc_call)))
pdf_exit_code = subprocess.call(pandoc_call)
if pdf_exit_code != 0:
logger.error("Error creating PDF! Pandoc returned a non-zero exit code.")
else:
logger.info("PDF Report : {}".format(pdf_fn_name))
except OSError as e:
if e.errno == os.errno.ENOENT:
logger.error('Error creating PDF - pandoc not found. Is it installed? http://pandoc.org/')
else:
logger.error("Error creating PDF! Something went wrong when creating the PDF\n"+
('='*60)+"\n{}\n".format(traceback.format_exc()) + ('='*60))
plugin_hooks.mqc_trigger('execution_finish')
logger.info("MultiQC complete")
if lint and len(report.lint_errors) > 0:
logger.error("Found {} linting errors!\n{}".format(len(report.lint_errors), "\n".join(report.lint_errors)))
sys_exit_code = 1
# Move the log file into the data directory
log.move_tmp_log(logger)
# Return the appropriate error code (eg. 1 if a module broke, 0 on success)
return sys_exit_code
if ss == 'remove':
section_id_order[anchor] = False
continue
if ss.get('order') is not None:
section_id_order[anchor] = ss['order']
if ss.get('after') in section_id_order.keys():
section_id_order[anchor] = section_id_order[ss['after']] + 1
if ss.get('before') in section_id_order.keys():
section_id_order[anchor] = section_id_order[ss['before']] - 1
# Remove module sections
section_id_order = { s:o for s,o in section_id_order.items() if o is not False }
# Sort the module sections
sorted_ids = sorted(section_id_order, key=section_id_order.get)
report.modules_output[midx].sections = [ s for i in sorted_ids for s in mod.sections if s['anchor'] == i ]
plugin_hooks.mqc_trigger('after_modules')
# Remove empty data sections from the General Stats table
empty_keys = [i for i, d in enumerate(report.general_stats_data[:]) if len(d) == 0]
empty_keys.sort(reverse=True)
for i in empty_keys:
del report.general_stats_data[i]
del report.general_stats_headers[i]
# Add general-stats IDs to table row headers
for idx, h in enumerate(report.general_stats_headers):
for k in h.keys():
if 'rid' not in h[k]:
h[k]['rid'] = re.sub(r'\W+', '_', k).strip().strip('_')
ns_html = re.sub(r'\W+', '_', h[k]['namespace']).strip().strip('_').lower()
report.general_stats_headers[idx][k]['rid'] = report.save_htmlid('mqc-generalstats-{}-{}'.format(ns_html, h[k]['rid']))
# Generate the General Statistics HTML & write to file
if len(report.general_stats_data) > 0:
To run, supply with one or more directory to scan for analysis results.
To run here, use 'multiqc .'
See http://multiqc.info for more details.
Author: Phil Ewels (http://phil.ewels.co.uk)
"""
# Set up logging level
loglevel = log.LEVELS.get(min(verbose,1), "INFO")
if quiet:
loglevel = 'WARNING'
log.init_log(logger, loglevel=loglevel, no_ansi=no_ansi)
# Load config files
plugin_hooks.mqc_trigger('before_config')
config.mqc_load_userconfig(config_file)
plugin_hooks.mqc_trigger('config_loaded')
# Command-line config YAML
if len(cl_config) > 0:
config.mqc_cl_config(cl_config)
# Log the command used to launch MultiQC
report.multiqc_command = " ".join(sys.argv)
logger.debug("Command used: {}".format(report.multiqc_command))
# Check that we're running the latest version of MultiQC
if config.no_version_check is not True:
try:
response = urlopen('http://multiqc.info/version.php?v={}'.format(config.short_version), timeout=5)
remote_version = response.read().decode('utf-8').strip()
See http://multiqc.info for more details.
Author: Phil Ewels (http://phil.ewels.co.uk)
"""
# Set up logging level
loglevel = log.LEVELS.get(min(verbose,1), "INFO")
if quiet:
loglevel = 'WARNING'
log.init_log(logger, loglevel=loglevel, no_ansi=no_ansi)
# Load config files
plugin_hooks.mqc_trigger('before_config')
config.mqc_load_userconfig(config_file)
plugin_hooks.mqc_trigger('config_loaded')
# Command-line config YAML
if len(cl_config) > 0:
config.mqc_cl_config(cl_config)
# Log the command used to launch MultiQC
report.multiqc_command = " ".join(sys.argv)
logger.debug("Command used: {}".format(report.multiqc_command))
# Check that we're running the latest version of MultiQC
if config.no_version_check is not True:
try:
response = urlopen('http://multiqc.info/version.php?v={}'.format(config.short_version), timeout=5)
remote_version = response.read().decode('utf-8').strip()
if version.StrictVersion(re.sub('[^0-9\.]','', remote_version)) > version.StrictVersion(re.sub('[^0-9\.]','', config.short_version)):
logger.warn('MultiQC Version {} now available!'.format(remote_version))
except AttributeError:
pass # No subdirectory variable given
# Add custom content section names
try:
if 'custom_content' in run_module_names:
run_module_names.extend(config.custom_data.keys())
except AttributeError:
pass # custom_data not in config
# Get the list of files to search
report.get_filelist(run_module_names)
# Run the modules!
plugin_hooks.mqc_trigger('before_modules')
report.modules_output = list()
sys_exit_code = 0
for mod_dict in run_modules:
try:
this_module = list(mod_dict.keys())[0]
mod_cust_config = list(mod_dict.values())[0]
mod = config.avail_modules[this_module].load()
mod.mod_cust_config = mod_cust_config # feels bad doing this, but seems to work
output = mod()
if type(output) != list:
output = [output]
for m in output:
report.modules_output.append(m)
# Copy over css & js files if requested by the theme
try:
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
# Clean up analysis_dir if a string (interactive environment only)
if isinstance(config.analysis_dir, str):
config.analysis_dir = [ config.analysis_dir ]
plugin_hooks.mqc_trigger('execution_start')
logger.info("This is MultiQC v{}".format(config.version))
logger.debug("Command : {}".format(' '.join(sys.argv)))
logger.debug("Working dir : {}".format(os.getcwd()))
if make_pdf:
logger.info('--pdf specified. Using non-interactive HTML template.')
logger.info("Template : {}".format(config.template))
if lint:
logger.info('--lint specified. Being strict with validation.')
# Throw a warning if we are running on Python 2
if sys.version_info[0] < 3:
logger.warn("You are running MultiQC with Python {}.{}.{}".format(sys.version_info[0], sys.version_info[1], sys.version_info[2]))
logger.warn("Please upgrade! MultiQC will soon drop support for Python < 3.6")
else:
logger.debug("Running Python {}".format(sys.version.replace("\n", ' ')))