<commit_before># Import -----------------------------------------------------------------------

import os
from reports import HTMLTable
from sequana.report_main import BaseReport

# Class ------------------------------------------------------------------------
class SubMappingReport(BaseReport):
    """
    """
    def __init__(self, start, stop, low_threshold=-3, high_threshold=3, 
            directory="report", output_filename="submapping.html", **kargs):
        super(SubMappingReport, self).__init__(
                jinja_filename="submapping/index.html",
                directory=directory,
                output_filename=output_filename, **kargs)
        self.jinja['title'] = "Mapping Report [{0},{1}]".format(start, stop)
        self.start = start
        self.stop = stop
        self.low_t = low_threshold
        self.high_t = high_threshold

    def set_data(self, data):
        self.mapping = data

    def parse(self):
        self.mapping.write_csv(self.directory + os.sep +
                "mapping_{0}_{1}.csv".format(self.start, self.stop), 
                start=self.start, stop=self.stop, header=False)
        self.jinja['input_df'] = "'mapping_{0}_{1}.csv'".format(self.start, 
                self.stop)

        low_cov_df = self.mapping.get_low_coverage(self.low_t, start=self.start, 
                stop=self.stop)
        merge_low_cov = self.mapping.merge_region(low_cov_df)
        html = HTMLTable(merge_low_cov)
        html.add_bgcolor("size")
        self.jinja['low_coverage'] = html.to_html(index=False)
        
        high_cov_df = self.mapping.get_high_coverage(self.high_t, 
                start=self.start, stop=self.stop)
        merge_high_cov = self.mapping.merge_region(high_cov_df)
        html = HTMLTable(merge_high_cov)
        html.add_bgcolor("size")
        self.jinja['high_coverage'] = html.to_html(index=False)<commit_msg>Update report_submapping.py<commit_after># Import -----------------------------------------------------------------------

import os
from reports import HTMLTable
from sequana.report_main import BaseReport

# Class ------------------------------------------------------------------------
class SubMappingReport(BaseReport):
    """
    """
    def __init__(self, start, stop, low_threshold=-3, high_threshold=3, 
            directory="report", output_filename="submapping.html", **kargs):
        super(SubMappingReport, self).__init__(
                jinja_filename="submapping/index.html",
                directory=directory,
                output_filename=output_filename, **kargs)
        self.jinja['title'] = "Mapping Report [{0},{1}]".format(start, stop)
        self.start = start
        self.stop = stop
        self.low_t = low_threshold
        self.high_t = high_threshold

    def set_data(self, data):
        self.mapping = data

    def parse(self):
        self.mapping.write_csv(self.directory + os.sep +
                "mapping_{0}_{1}.csv".format(self.start, self.stop), 
                start=self.start, stop=self.stop, header=False)
        self.jinja['input_df'] = "'mapping_{0}_{1}.csv'".format(self.start, 
                self.stop)

        low_cov_df = self.mapping.get_low_coverage(threshold=self.low_t, 
                start=self.start, stop=self.stop)
        merge_low_cov = self.mapping.merge_region(low_cov_df)
        html = HTMLTable(merge_low_cov)
        html.add_bgcolor("size")
        self.jinja['low_coverage'] = html.to_html(index=False)
        
        high_cov_df = self.mapping.get_high_coverage(threshold=self.high_t, 
                start=self.start, stop=self.stop)
        merge_high_cov = self.mapping.merge_region(high_cov_df)
        html = HTMLTable(merge_high_cov)
        html.add_bgcolor("size")
        self.jinja['high_coverage'] = html.to_html(index=False)
{'fraction_non_alphanumeric': 0.18622315348349922, 'fraction_numerical': 0.0041906757464641176, 'mean_word_length': 2.0478850758180367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2858035', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1083, 'n_words': 164}