예제 #1
0
파일: html_saver.py 프로젝트: ablab/quast
def create_meta_report(results_dirpath, json_texts):
    html_fpath = os.path.join(results_dirpath, report_fname)
    if not os.path.isfile(html_fpath):
        init(html_fpath, is_meta=True)

    from quast_libs import search_references_meta
    taxons_for_krona = search_references_meta.taxons_for_krona
    meta_log = get_logger(qconfig.LOGGER_META_NAME)
    if taxons_for_krona:
        create_krona_charts(taxons_for_krona, meta_log, results_dirpath, json_texts)

    # reading html template file
    with open(html_fpath) as f_html:
        html_text = f_html.read()
    keyword = 'totalReport'
    html_text = re.sub('{{ ' + keyword + ' }}', '[' + ','.join(json_texts) + ']', html_text)
    html_text = re.sub(r'{{(\s+\S+\s+)}}', '{}', html_text)
    with open(html_fpath, 'w') as f_html:
        f_html.write(html_text)
    meta_log.main_info('  Extended version of HTML-report (for all references and assemblies) is saved to ' + html_fpath)
예제 #2
0
def create_meta_report(results_dirpath, json_texts):
    html_fpath = os.path.join(results_dirpath, report_fname)
    if not os.path.isfile(html_fpath):
        init(html_fpath, is_meta=True)

    from quast_libs import search_references_meta
    taxons_for_krona = search_references_meta.taxons_for_krona
    meta_log = get_logger(qconfig.LOGGER_META_NAME)
    if taxons_for_krona:
        create_krona_charts(taxons_for_krona, meta_log, results_dirpath,
                            json_texts)

    # reading html template file
    with open(html_fpath) as f_html:
        html_text = f_html.read()
    keyword = 'totalReport'
    html_text = re.sub('{{ ' + keyword + ' }}',
                       '[' + ','.join(json_texts) + ']', html_text)
    html_text = re.sub(r'{{(\s+\S+\s+)}}', '{}', html_text)
    with open(html_fpath, 'w') as f_html:
        f_html.write(html_text)
    meta_log.main_info(
        '  Extended version of HTML-report (for all references and assemblies) is saved to '
        + html_fpath)
예제 #3
0
############################################################################
# Copyright (c) 2015-2020 Saint Petersburg State University
# Copyright (c) 2011-2015 Saint Petersburg Academic University
# All Rights Reserved
# See file LICENSE for details.
############################################################################

from __future__ import with_statement
from __future__ import division

from quast_libs import qconfig
from quast_libs.ca_utils.misc import is_same_reference, get_ref_by_chromosome, parse_cs_tag

from quast_libs.log import get_logger
logger = get_logger(qconfig.LOGGER_DEFAULT_NAME)
from quast_libs.qutils import correct_name


class Misassembly:
    LOCAL = 0
    INVERSION = 1
    RELOCATION = 2
    TRANSLOCATION = 3
    INTERSPECTRANSLOCATION = 4  # for metaquast, if translocation occurs between chromosomes of different references
    SCAFFOLD_GAP = 5
    LOCAL_SCAFFOLD_GAP = 6
    FRAGMENTED = 7
    POTENTIALLY_MIS_CONTIGS = 8
    POSSIBLE_MISASSEMBLIES = 9
    MATCHED_SV = 10
    POTENTIAL_MGE = 11
예제 #4
0
   from quast_libs.site_packages.ordered_dict import OrderedDict

from quast_libs import qconfig
qconfig.check_python_version()

from site import addsitedir
addsitedir(os.path.join(qconfig.LIBS_LOCATION, 'site_packages'))
from quast_libs.metautils import Assembly, correct_meta_references, correct_assemblies, \
    get_downloaded_refs_with_alignments, partition_contigs, calculate_ave_read_support
from quast_libs.options_parser import parse_options, remove_from_quast_py_args, prepare_regular_quast_args

from quast_libs import contigs_analyzer, search_references_meta, plotter_data, qutils
from quast_libs.qutils import cleanup, check_dirpath, is_python2, run_parallel

from quast_libs.log import get_logger
logger = get_logger(qconfig.LOGGER_META_NAME)
logger.set_up_console_handler()


def _start_quast_main(args, assemblies, reference_fpath=None, output_dirpath=None, num_notifications_tuple=None,
                      labels=None, run_regular_quast=False, is_combined_ref=False, is_parallel_run=False):
    args = args[:]

    args.extend([asm.fpath for asm in assemblies])

    if reference_fpath:
        args.append('-R')
        args.append(reference_fpath)

    if output_dirpath:
        args.append('-o')
예제 #5
0
from __future__ import with_statement
import os
import glob
import shutil
import tempfile

from quast_libs import reporting, qconfig, qutils
from quast_libs.ca_utils.misc import open_gzipsafe
from quast_libs.fastaparser import write_fasta
from quast_libs.genes_parser import Gene

from quast_libs.log import get_logger
from quast_libs.qutils import is_python2

logger = get_logger(qconfig.LOGGER_DEFAULT_NAME)

LICENSE_LIMITATIONS_MODE = False
OUTPUT_FASTA = False  # whether output only .gff or with corresponding .fasta files


def gc_content(sequence):
    GC_count = sequence.count('G') + sequence.count('C')
    ACGT_length = len(sequence) - sequence.count('N')
    if not ACGT_length:
        return 0
    return 100 * GC_count / ACGT_length


def gmhmm_p(tool_exec, fasta_fpath, heu_fpath, out_fpath, err_file, index):
    """ Run GeneMark.hmm with this heuristic model (heu_dirpath)
예제 #6
0
import os
import shutil

from quast_libs import qconfig
qconfig.check_python_version()

from quast_libs.metautils import Assembly, correct_meta_references, correct_assemblies, \
    get_downloaded_refs_with_alignments, partition_contigs, calculate_ave_read_support
from quast_libs.options_parser import parse_options, remove_from_quast_py_args

from quast_libs import contigs_analyzer, reads_analyzer, search_references_meta
from quast_libs import qutils
from quast_libs.qutils import cleanup, check_dirpath

from quast_libs.log import get_logger
logger = get_logger(qconfig.LOGGER_META_NAME)
logger.set_up_console_handler()

from site import addsitedir
addsitedir(os.path.join(qconfig.LIBS_LOCATION, 'site_packages'))


def _start_quast_main(args, assemblies, reference_fpath=None, output_dirpath=None,
                      num_notifications_tuple=None, is_first_run=None, run_regular_quast=False):
    args = args[:]

    args.extend([asm.fpath for asm in assemblies])

    if reference_fpath:
        args.append('-R')
        args.append(reference_fpath)
예제 #7
0
# axis params:
logarithmic_x_scale = False  # for cumulative plots only

####################################################################################
########################  END OF CONFIGURABLE PARAMETERS  ##########################
####################################################################################
import math
import sys

from quast_libs import fastaparser, qconfig, reporting
from quast_libs.log import get_logger, get_main_logger
from quast_libs.qutils import label_from_fpath, parse_str_to_num, run_parallel
from quast_libs.plotter_data import get_color_and_ls, colors

main_logger = get_main_logger()
logger = get_logger(qconfig.LOGGER_DEFAULT_NAME)
meta_logger = get_logger(qconfig.LOGGER_META_NAME)

# checking if matplotlib is installed
can_draw_plots = False
if qconfig.draw_plots:
    try:
        import matplotlib
        matplotlib.use('Agg')  # non-GUI backend
        if matplotlib.__version__.startswith(
                '0') or matplotlib.__version__.startswith('1.0'):
            main_logger.info('')
            main_logger.warning(
                'Can\'t draw plots: matplotlib version is old! Please use matplotlib version 1.1 or higher.'
            )
        else:
예제 #8
0
# axis params:
logarithmic_x_scale = False  # for cumulative plots only

####################################################################################
########################  END OF CONFIGURABLE PARAMETERS  ##########################
####################################################################################

import os
import itertools
from quast_libs import fastaparser, qutils
from quast_libs import qconfig

from quast_libs.log import get_logger, get_main_logger

main_logger = get_main_logger()
logger = get_logger(qconfig.LOGGER_DEFAULT_NAME)
meta_logger = get_logger(qconfig.LOGGER_META_NAME)

from . import reporting

# checking if matplotlib is installed
can_draw_plots = True
if qconfig.draw_plots:
    try:
        import matplotlib
        matplotlib.use('Agg')  # non-GUI backend
        if matplotlib.__version__.startswith('0') or matplotlib.__version__.startswith('1.0'):
            main_logger.info('')
            main_logger.warning('Can\'t draw plots: matplotlib version is old! Please use matplotlib version 1.1 or higher.')
            can_draw_plots = False
        # additionally check other imports