# Path: alfpy/word_pattern.py
# class Pattern:
#     def __init__(self, pat_list, occr_list, pos_list=None):
#     def _alfree_format(self):
#     def _teiresias_format(self):
#     def format(self, formattype=None):
#     def reduce_alphabet(self, alphabet_dict):
#     def merge_revcomp(self):
#         def revcomp(s):
#     def __repr__(self):
#     def __str__(self):
# def _create_wordpattern(seq_list, k):
# def _create_wordpattern_positions(seq_list, k):
# def create(seq_list, word_size=1, wordpos=False):
# def create_from_fasta(handle, word_size=1, wordpos=False):
# def create_from_bigfasta(filename, k=1):
# def run_teiresias(input_filename, w=2, l=2, k=2, output_filename=None):
# def read(handle):
# def main():
# 
# Path: alfpy/word_rtd.py
# def calc_rtd(word_positions):
# def create_vector(seqcount, pattern):
# def main():
# class Distance(distance.Distance):
# 
# Path: alfpy/utils/distmatrix.py
# def create(id_list, distance):
# def read_highcharts_matrix(id_list, data):
#     def __init__(self, id_list, data):
#     def normalize(self):
#     def __iter__(self):
#     def writer(self, handle, f, decimal_places):
#     def display(self, f="phylip", decimal_places=7):
#     def write_to_file(self, handle, f="phylip", decimal_places=7):
#     def highcharts(self):
#     def format(self, decimal_places=7):
#     def min(self):
#     def max(self):
#     def is_zero(self):
#     def __repr__(self):
# class Matrix():


import unittest
from alfpy import word_pattern
from alfpy import word_rtd
from alfpy.utils import distmatrix
from . import utils




class Test(unittest.TestCase, utils.ModulesCommonTest):

    def __init__(self, *args, **kwargs):
        super(Test, self).__init__(*args, **kwargs)
        utils.ModulesCommonTest.set_test_data()
        self.pep_2mer_pos = word_pattern.create(
            self.pep_records.seq_list, 2, True)

    def test_calc_rtd(self):
        seq = 'CTACACAACTTTGCGGGTAGCCGGAAACATTGTGAATGCGGTGAACA'
        apos = [i for i, nt in enumerate(seq) if nt == 'A']
        val = word_rtd.calc_rtd(apos)
        exp = (3.3846153846153846, 3.1510306381944679)
        self.assertEqual(val, exp)

    def test_create_vector(self):
        vec = word_rtd.create_vector(self.pep_records.count, self.pep_2mer_pos)
        exp = (self.pep_records.count, len(self.pep_2mer_pos.pat_list)*2)
        self.assertEqual(vec.shape, exp)

    def test_distance(self):

# Path: alfpy/word_pattern.py
# class Pattern:
#     def __init__(self, pat_list, occr_list, pos_list=None):
#     def _alfree_format(self):
#     def _teiresias_format(self):
#     def format(self, formattype=None):
#     def reduce_alphabet(self, alphabet_dict):
#     def merge_revcomp(self):
#         def revcomp(s):
#     def __repr__(self):
#     def __str__(self):
# def _create_wordpattern(seq_list, k):
# def _create_wordpattern_positions(seq_list, k):
# def create(seq_list, word_size=1, wordpos=False):
# def create_from_fasta(handle, word_size=1, wordpos=False):
# def create_from_bigfasta(filename, k=1):
# def run_teiresias(input_filename, w=2, l=2, k=2, output_filename=None):
# def read(handle):
# def main():
# 
# Path: alfpy/word_rtd.py
# def calc_rtd(word_positions):
# def create_vector(seqcount, pattern):
# def main():
# class Distance(distance.Distance):
# 
# Path: alfpy/utils/distmatrix.py
# def create(id_list, distance):
# def read_highcharts_matrix(id_list, data):
#     def __init__(self, id_list, data):
#     def normalize(self):
#     def __iter__(self):
#     def writer(self, handle, f, decimal_places):
#     def display(self, f="phylip", decimal_places=7):
#     def write_to_file(self, handle, f="phylip", decimal_places=7):
#     def highcharts(self):
#     def format(self, decimal_places=7):
#     def min(self):
#     def max(self):
#     def is_zero(self):
#     def __repr__(self):
# class Matrix():


# Path: tests/test_word_rtd.py
import unittest
from alfpy import word_pattern
from alfpy import word_rtd
from alfpy.utils import distmatrix
from . import utils





class Test(unittest.TestCase, utils.ModulesCommonTest):

    def __init__(self, *args, **kwargs):
        super(Test, self).__init__(*args, **kwargs)
        utils.ModulesCommonTest.set_test_data()
        self.pep_2mer_pos = word_pattern.create(
            self.pep_records.seq_list, 2, True)

    def test_calc_rtd(self):
        seq = 'CTACACAACTTTGCGGGTAGCCGGAAACATTGTGAATGCGGTGAACA'
        apos = [i for i, nt in enumerate(seq) if nt == 'A']
        val = word_rtd.calc_rtd(apos)
        exp = (3.3846153846153846, 3.1510306381944679)
        self.assertEqual(val, exp)

    def test_create_vector(self):
        vec = word_rtd.create_vector(self.pep_records.count, self.pep_2mer_pos)
        exp = (self.pep_records.count, len(self.pep_2mer_pos.pat_list)*2)
        self.assertEqual(vec.shape, exp)

    def test_distance(self):

        vec = word_rtd.create_vector(self.pep_records.count, self.pep_2mer_pos)