# 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.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/summary_cluster_variant.py
# class Error (Exception): pass
# class SummaryClusterVariant:
#     def __init__(self, data_dict):
#     def __eq__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def _has_nonsynonymous(cls, data_dict):
#     def _filter_depths(cls, ref_base, depths):
#     def _get_is_het_and_percent(cls, data_dict):
#     def _get_nonsynon_variant_data(self, data_dict):


from ariba import flag, report, summary_cluster_variant
    def _to_cluster_summary_has_nonsynonymous(self, assembled_summary):
        '''assembled_summary should be output of _to_cluster_summary_assembled'''
        if assembled_summary == 'no':
            return 'NA'
        else:
            return self._has_any_nonsynonymous()


    @staticmethod
    def _get_known_noncoding_het_snp(data_dict):
        '''If ref is coding, return None. If the data dict has a known snp, and
           samtools made a call, then return the string ref_name_change and the
           % of reads supporting the variant type. If noncoding, but no
           samtools call, then return None'''
        if data_dict['gene'] == '1':
            return None

        if data_dict['known_var'] == '1' and data_dict['ref_ctg_effect'] == 'SNP' \
          and data_dict['smtls_nts'] != '.' and ';' not in data_dict['smtls_nts']:
            nucleotides = data_dict['smtls_nts'].split(',')
            depths = data_dict['smtls_nts_depth'].split(',')

            if len(nucleotides) != len(depths):
                raise Error('Mismatch in number of inferred nucleotides from ctg_nt, smtls_nts, smtls_nts_depth columns. Cannot continue\n' + str(data_dict))

            try:
                var_nucleotide = data_dict['known_var_change'][-1]
                depths = [int(x) for x in depths]
                nuc_to_depth = dict(zip(nucleotides, depths))
                total_depth = sum(depths)

# 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.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/summary_cluster_variant.py
# class Error (Exception): pass
# class SummaryClusterVariant:
#     def __init__(self, data_dict):
#     def __eq__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def _has_nonsynonymous(cls, data_dict):
#     def _filter_depths(cls, ref_base, depths):
#     def _get_is_het_and_percent(cls, data_dict):
#     def _get_nonsynon_variant_data(self, data_dict):


# Path: ariba/summary_cluster.py
from ariba import flag, report, summary_cluster_variant

    def _to_cluster_summary_has_nonsynonymous(self, assembled_summary):
        '''assembled_summary should be output of _to_cluster_summary_assembled'''
        if assembled_summary == 'no':
            return 'NA'
        else:
            return self._has_any_nonsynonymous()


    @staticmethod
    def _get_known_noncoding_het_snp(data_dict):
        '''If ref is coding, return None. If the data dict has a known snp, and
           samtools made a call, then return the string ref_name_change and the
           % of reads supporting the variant type. If noncoding, but no
           samtools call, then return None'''
        if data_dict['gene'] == '1':
            return None

        if data_dict['known_var'] == '1' and data_dict['ref_ctg_effect'] == 'SNP' \
          and data_dict['smtls_nts'] != '.' and ';' not in data_dict['smtls_nts']:
            nucleotides = data_dict['smtls_nts'].split(',')
            depths = data_dict['smtls_nts_depth'].split(',')

            if len(nucleotides) != len(depths):
                raise Error('Mismatch in number of inferred nucleotides from ctg_nt, smtls_nts, smtls_nts_depth columns. Cannot continue\n' + str(data_dict))

            try:
                var_nucleotide = data_dict['known_var_change'][-1]
                depths = [int(x) for x in depths]
                nuc_to_depth = dict(zip(nucleotides, depths))
                total_depth = sum(depths)

                var_depth = nuc_to_depth.get(var_nucleotide, 0)