# Path: deepcpg/data/hdf.py
# def _ls(item, recursive=False, groups=False, level=0):
# def ls(filename, group='/', recursive=False, groups=False,
#        regex=None, nb_key=None, must_exist=True):
# def write_data(data, filename):
# def hnames_to_names(hnames):
# def reader(data_files, names, batch_size=128, nb_sample=None, shuffle=False,
#            loop=False):
# def _to_dict(data):
# def read_from(reader, nb_sample=None):
# def read(data_files, names, nb_sample=None, batch_size=1024, *args, **kwargs):
# 
# Path: deepcpg/data/fasta.py
# def read_chromo(filenames, chromo):
#     """Read DNA sequence of chromosome `chromo`.
# 
#     Parameters
#     ----------
#     filenames: list
#         List of FASTA files.
#     chromo: str
#         Chromosome that is read.
# 
#     Returns
#     -------
#     str
#         DNA sequence of chromosome `chromo`.
#     """
#     filename = select_file_by_chromo(filenames, chromo)
#     if not filename:
#         raise ValueError('DNA file for chromosome "%s" not found!' % chromo)
# 
#     fasta_seqs = read_file(filename)
#     if len(fasta_seqs) != 1:
#         raise ValueError('Single sequence expected in file "%s"!' % filename)
#     return fasta_seqs[0].seq
# 
# Path: deepcpg/data/dna.py
# CHAR_TO_INT = OrderedDict([('A', 0), ('T', 1), ('G', 2), ('C', 3), ('N', 4)])


from glob import glob
from numpy import testing as npt
from deepcpg.data import hdf, CPG_NAN
from deepcpg.data.fasta import read_chromo
from deepcpg.data.dna import CHAR_TO_INT
import os
import numpy as np
                    ]
        self._test_outputs('cpg/BS27_4_SER', expected)

        expected = [('18', 3000092, 1.0),
                    ('18', 3010064, 0.0),
                    ('18', 3140338, 1.0),
                    ('18', 3143169, 0.0),
                    ('19', 4187854, 1.0),
                    ('19', 4190571, 0.0),
                    ('19', 4192788, 0.0),
                    ('19', 4202077, 0.0)
                    ]
        self._test_outputs('cpg/BS28_2_SER', expected)

    def _test_dna(self, chromo):
        pos = self.pos[self.chromo == chromo.encode()]
        dna = self.data['/inputs/dna'][self.chromo == chromo.encode()]
        dna_wlen = dna.shape[1]
        center = dna_wlen // 2

        dna_seq = read_chromo(os.path.join(self.data_path, '../dna_db'),
                              chromo)

        idxs = np.linspace(0, len(pos) - 1, 100).astype(np.int32)
        for idx in idxs:
            p = pos[idx] - 1
            assert dna_seq[p:(p + 2)] == 'CG'
            assert dna[idx, center] == 3
            assert dna[idx, center + 1] == 2
            assert dna[idx, center + 10] == CHAR_TO_INT[dna_seq[p + 10]]

# Path: deepcpg/data/hdf.py
# def _ls(item, recursive=False, groups=False, level=0):
# def ls(filename, group='/', recursive=False, groups=False,
#        regex=None, nb_key=None, must_exist=True):
# def write_data(data, filename):
# def hnames_to_names(hnames):
# def reader(data_files, names, batch_size=128, nb_sample=None, shuffle=False,
#            loop=False):
# def _to_dict(data):
# def read_from(reader, nb_sample=None):
# def read(data_files, names, nb_sample=None, batch_size=1024, *args, **kwargs):
# 
# Path: deepcpg/data/fasta.py
# def read_chromo(filenames, chromo):
#     """Read DNA sequence of chromosome `chromo`.
# 
#     Parameters
#     ----------
#     filenames: list
#         List of FASTA files.
#     chromo: str
#         Chromosome that is read.
# 
#     Returns
#     -------
#     str
#         DNA sequence of chromosome `chromo`.
#     """
#     filename = select_file_by_chromo(filenames, chromo)
#     if not filename:
#         raise ValueError('DNA file for chromosome "%s" not found!' % chromo)
# 
#     fasta_seqs = read_file(filename)
#     if len(fasta_seqs) != 1:
#         raise ValueError('Single sequence expected in file "%s"!' % filename)
#     return fasta_seqs[0].seq
# 
# Path: deepcpg/data/dna.py
# CHAR_TO_INT = OrderedDict([('A', 0), ('T', 1), ('G', 2), ('C', 3), ('N', 4)])


# Path: tests/integration_tests/data/test_data_values.py
from glob import glob
from numpy import testing as npt
from deepcpg.data import hdf, CPG_NAN
from deepcpg.data.fasta import read_chromo
from deepcpg.data.dna import CHAR_TO_INT
import os
import numpy as np

                    ]
        self._test_outputs('cpg/BS27_4_SER', expected)

        expected = [('18', 3000092, 1.0),
                    ('18', 3010064, 0.0),
                    ('18', 3140338, 1.0),
                    ('18', 3143169, 0.0),
                    ('19', 4187854, 1.0),
                    ('19', 4190571, 0.0),
                    ('19', 4192788, 0.0),
                    ('19', 4202077, 0.0)
                    ]
        self._test_outputs('cpg/BS28_2_SER', expected)

    def _test_dna(self, chromo):
        pos = self.pos[self.chromo == chromo.encode()]
        dna = self.data['/inputs/dna'][self.chromo == chromo.encode()]
        dna_wlen = dna.shape[1]
        center = dna_wlen // 2

        dna_seq = read_chromo(os.path.join(self.data_path, '../dna_db'),
                              chromo)

        idxs = np.linspace(0, len(pos) - 1, 100).astype(np.int32)
        for idx in idxs:
            p = pos[idx] - 1
            assert dna_seq[p:(p + 2)] == 'CG'
            assert dna[idx, center] == 3
            assert dna[idx, center + 1] == 2
            assert dna[idx, center + 10] == CHAR_TO_INT[dna_seq[p + 10]]

            assert dna[idx, center - 10] == CHAR_TO_INT[dna_seq[p - 10]]