# Path: deepcpg/data/feature_extractor.py
# class KnnCpgFeatureExtractor(object):
# class IntervalFeatureExtractor(object):
# class KmersFeatureExtractor(object):
#     def __init__(self, k=1):
#     def extract(self, x, y, ys):
#     def __larger_equal(self, x, y):
#     def join_intervals(s, e):
#     def index_intervals(x, ys, ye):
#     def extract(self, x, ys, ye):
#     def __init__(self, kmer_len, nb_char=4):
#     def __call__(self, seqs):
# 
# Path: deepcpg/data/dna.py
# CHAR_TO_INT = OrderedDict([('A', 0), ('T', 1), ('G', 2), ('C', 3), ('N', 4)])
# INT_TO_CHAR = {v: k for k, v in CHAR_TO_INT.items()}
# def get_alphabet(special=False, reverse=False):
# def char_to_int(seq):
# def int_to_char(seq, join=True):
# def int_to_onehot(seqs, dim=4):
# def onehot_to_int(seqs, axis=-1):


import numpy as np
import numpy.testing as npt
import six
from deepcpg.data import feature_extractor as fe
from deepcpg.data import dna
    def test_extract_k2(self):
        y = np.array([1, 3, 5, 8, 15])
        ys = np.array([0, 0, 1, 1, 0])
        x = np.array([2, 6, 10])
        expect = np.array([[np.nan, 0, 0, 1, np.nan, 1, 1, 3],
                           [0, 1, 1, 0, 3, 1, 2, 9],
                           [1, 1, 0, np.nan, 5, 2, 5, np.nan]])
        result = fe.KnnCpgFeatureExtractor(2).extract(x, y, ys)
        self._compare(result, expect)

        x = np.array([0, 1, 3, 8, 11, 15, 20])
        expect = np.array([[np.nan, np.nan, 0, 0, np.nan, np.nan, 1, 3],
                           [np.nan, np.nan, 0, 1, np.nan, np.nan, 2, 4],
                           [np.nan, 0, 1, 1, np.nan, 2, 2, 5],
                           [0, 1, 0, np.nan, 5, 3, 7, np.nan],
                           [1, 1, 0, np.nan, 6, 3, 4, np.nan],
                           [1, 1, np.nan, np.nan, 10, 7, np.nan, np.nan],
                           [1, 0, np.nan, np.nan, 12, 5, np.nan, np.nan]])
        result = fe.KnnCpgFeatureExtractor(2).extract(x, y, ys)
        self._compare(result, expect)

    def test_extract_k3(self):
        y = np.array([1, 3, 5, 8, 15])
        ys = np.array([0, 0, 1, 1, 0])
        x = np.array([2, 3, 6, 10, 15])
        expect = np.array([[np.nan, np.nan, 0, 0, 1, 1, np.nan, np.nan, 1, 1, 3, 6],
                           [np.nan, np.nan, 0, 1, 1, 0, np.nan, np.nan, 2, 2, 5, 12],
                           [0, 0, 1, 1, 0, np.nan, 5, 3, 1, 2, 9, np.nan],
                           [0, 1, 1, 0, np.nan, np.nan, 7, 5, 2, 5, np.nan, np.nan],
                           [0, 1, 1, np.nan, np.nan, np.nan, 12, 10, 7, np.nan, np.nan, np.nan]])

# Path: deepcpg/data/feature_extractor.py
# class KnnCpgFeatureExtractor(object):
# class IntervalFeatureExtractor(object):
# class KmersFeatureExtractor(object):
#     def __init__(self, k=1):
#     def extract(self, x, y, ys):
#     def __larger_equal(self, x, y):
#     def join_intervals(s, e):
#     def index_intervals(x, ys, ye):
#     def extract(self, x, ys, ye):
#     def __init__(self, kmer_len, nb_char=4):
#     def __call__(self, seqs):
# 
# Path: deepcpg/data/dna.py
# CHAR_TO_INT = OrderedDict([('A', 0), ('T', 1), ('G', 2), ('C', 3), ('N', 4)])
# INT_TO_CHAR = {v: k for k, v in CHAR_TO_INT.items()}
# def get_alphabet(special=False, reverse=False):
# def char_to_int(seq):
# def int_to_char(seq, join=True):
# def int_to_onehot(seqs, dim=4):
# def onehot_to_int(seqs, axis=-1):


# Path: tests/deepcpg/data/test_feature_extractor.py
import numpy as np
import numpy.testing as npt
import six
from deepcpg.data import feature_extractor as fe
from deepcpg.data import dna

    def test_extract_k2(self):
        y = np.array([1, 3, 5, 8, 15])
        ys = np.array([0, 0, 1, 1, 0])
        x = np.array([2, 6, 10])
        expect = np.array([[np.nan, 0, 0, 1, np.nan, 1, 1, 3],
                           [0, 1, 1, 0, 3, 1, 2, 9],
                           [1, 1, 0, np.nan, 5, 2, 5, np.nan]])
        result = fe.KnnCpgFeatureExtractor(2).extract(x, y, ys)
        self._compare(result, expect)

        x = np.array([0, 1, 3, 8, 11, 15, 20])
        expect = np.array([[np.nan, np.nan, 0, 0, np.nan, np.nan, 1, 3],
                           [np.nan, np.nan, 0, 1, np.nan, np.nan, 2, 4],
                           [np.nan, 0, 1, 1, np.nan, 2, 2, 5],
                           [0, 1, 0, np.nan, 5, 3, 7, np.nan],
                           [1, 1, 0, np.nan, 6, 3, 4, np.nan],
                           [1, 1, np.nan, np.nan, 10, 7, np.nan, np.nan],
                           [1, 0, np.nan, np.nan, 12, 5, np.nan, np.nan]])
        result = fe.KnnCpgFeatureExtractor(2).extract(x, y, ys)
        self._compare(result, expect)

    def test_extract_k3(self):
        y = np.array([1, 3, 5, 8, 15])
        ys = np.array([0, 0, 1, 1, 0])
        x = np.array([2, 3, 6, 10, 15])
        expect = np.array([[np.nan, np.nan, 0, 0, 1, 1, np.nan, np.nan, 1, 1, 3, 6],
                           [np.nan, np.nan, 0, 1, 1, 0, np.nan, np.nan, 2, 2, 5, 12],
                           [0, 0, 1, 1, 0, np.nan, 5, 3, 1, 2, 9, np.nan],
                           [0, 1, 1, 0, np.nan, np.nan, 7, 5, 2, 5, np.nan, np.nan],
                           [0, 1, 1, np.nan, np.nan, np.nan, 12, 10, 7, np.nan, np.nan, np.nan]])

        result = fe.KnnCpgFeatureExtractor(3).extract(x, y, ys)