# Path: ariba/report.py
# class Error (Exception): pass
# def header_line():
# def _samtools_depths_at_known_snps_all_wild(sequence_meta, contig_name, cluster, variant_list):
# def _report_lines_for_one_contig(cluster, contig_name, ref_cov_per_contig, pymummer_variants):
# def report_lines(cluster):
# 
# Path: ariba/flag.py
# class Error (Exception): pass
# class Flag:
#     def __init__(self, n=0):
#     def set_flag(self, n):
#     def add(self, f):
#     def to_number(self):
#     def __eq__(self, other):
#     def __str__(self):
#     def to_long_string(self):
#     def has(self, s):
#     def to_comma_separated_string(self):


import pyfastaq
from ariba import report, flag
        return [d for d in dicts_list if d['ref_start'] == '.' or d['ref_start'] <= first_start]


    def _filter_dicts(self):
        '''Filters out all the report_dicts that do not pass the cutoffs. If any ref sequence
           loses all of its report_dicts, then it is completely removed.'''
        keys_to_remove = set()

        for ref_name in self.report:
            for ctg_name in self.report[ref_name]:
                self.report[ref_name][ctg_name] = self._filter_list_of_dicts(self.report[ref_name][ctg_name])
                if len(self.report[ref_name][ctg_name]) == 0:
                    keys_to_remove.add((ref_name, ctg_name))

        refs_to_remove = set()

        for ref_name, ctg_name in keys_to_remove:
            del self.report[ref_name][ctg_name]
            if len(self.report[ref_name]) == 0:
                refs_to_remove.add(ref_name)

        for ref_name in refs_to_remove:
            del self.report[ref_name]


    def _write_report_tsv(self, outfile):
        f = pyfastaq.utils.open_file_write(outfile)
        print('#' + '\t'.join(report.columns), file=f)

        for ref_name in sorted(self.report):

# Path: ariba/report.py
# class Error (Exception): pass
# def header_line():
# def _samtools_depths_at_known_snps_all_wild(sequence_meta, contig_name, cluster, variant_list):
# def _report_lines_for_one_contig(cluster, contig_name, ref_cov_per_contig, pymummer_variants):
# def report_lines(cluster):
# 
# Path: ariba/flag.py
# class Error (Exception): pass
# class Flag:
#     def __init__(self, n=0):
#     def set_flag(self, n):
#     def add(self, f):
#     def to_number(self):
#     def __eq__(self, other):
#     def __str__(self):
#     def to_long_string(self):
#     def has(self, s):
#     def to_comma_separated_string(self):


# Path: ariba/report_filter.py
import pyfastaq
from ariba import report, flag

        return [d for d in dicts_list if d['ref_start'] == '.' or d['ref_start'] <= first_start]


    def _filter_dicts(self):
        '''Filters out all the report_dicts that do not pass the cutoffs. If any ref sequence
           loses all of its report_dicts, then it is completely removed.'''
        keys_to_remove = set()

        for ref_name in self.report:
            for ctg_name in self.report[ref_name]:
                self.report[ref_name][ctg_name] = self._filter_list_of_dicts(self.report[ref_name][ctg_name])
                if len(self.report[ref_name][ctg_name]) == 0:
                    keys_to_remove.add((ref_name, ctg_name))

        refs_to_remove = set()

        for ref_name, ctg_name in keys_to_remove:
            del self.report[ref_name][ctg_name]
            if len(self.report[ref_name]) == 0:
                refs_to_remove.add(ref_name)

        for ref_name in refs_to_remove:
            del self.report[ref_name]


    def _write_report_tsv(self, outfile):
        f = pyfastaq.utils.open_file_write(outfile)
        print('#' + '\t'.join(report.columns), file=f)

        for ref_name in sorted(self.report):

            for ctg_name, report_dicts in sorted(self.report[ref_name].items()):