# 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_vector.py
# class Counts:
# class Bools(Counts):
# class Freqs(Counts):
# class FreqsStd(Freqs):
# class WeightModel:
# class CountsWeight(Counts):
# class FreqsWeight(Freqs):
# class WordModel:
# class EqualFreqs(WordModel):
# class EquilibriumFreqs(WordModel):
# class Composition(Counts):
#     def __init__(self, seq_lengths, patterns):
#     def _get_counts_occurrence(seq_count, patterns):
#     def __getitem__(self, seqidx):
#     def __str__(self):
#     def format(self, decimal_places=3):
#     def __init__(self, seq_lengths, patterns):
#     def __init__(self, seq_lengths, patterns):
#     def __relative_freqs(self):
#     def __init__(self, seq_lengths, patterns, freqmodel):
#     def __overlaps(self, freqmodel):
#     def __standardize_freqs(self, freqmodel):
#     def __init__(self, char_weights, wtype='content'):
#     def content(self, vector, patterns):
#     def __init__(self, seq_lengths, patterns, weightmodel):
#     def __init__(self, seq_lengths, patterns, weightmodel):
#     def probabilities(self, word):
#     def overlap_capability(self, word):
#     def var(self, word, seq_len, word_len=None, overlap_capability=None,
#             word_probs=None):
#     def __init__(self, alphabet_size):
#     def probabilities(self, word):
#     def __init__(self, equilibrium_frequencies):
#     def probabilities(self, word):
#     def __init__(self, seq_lengths, patterns, patterns1, patterns2):
#     def __check_patlen(self):
#     def __markov_chain_freqs(self, seqnum, seqlen, patnum, patlen, pattern):
#     def __composition(self, seqnum, seqlen):
# def _read_charval_file(handle):
# def main():


import unittest
from alfpy import word_pattern
from alfpy import word_vector
from . import utils
class WordVectorTest(unittest.TestCase, utils.ModulesCommonTest):

    def __init__(self, *args, **kwargs):
        super(WordVectorTest, self).__init__(*args, **kwargs)
        utils.ModulesCommonTest.set_test_data()
        self.pattern1 = word_pattern.create(self.dna_records.seq_list, 1)
        self.pattern2 = word_pattern.create(self.dna_records.seq_list, 2)
        self.pattern3 = word_pattern.create(self.dna_records.seq_list, 3)

    def test_counts_pattern1(self):
        counts = word_vector.Counts(self.dna_records.length_list,
                                    self.pattern1)
        exp = ["A\t8 4 6",
               "G\t6 6 3",
               "C\t6 3 4",
               "T\t5 5 2"]
        lengths = [25, 18, 15]
        self.assertEqual(counts.format(decimal_places=0), "\n".join(exp))
        # Counts in a sequence should sum to sequence length.
        for i in range(len(counts.data)):
            self.assertEqual(sum(counts.data[i]), lengths[i])

    def test_counts_pattern2(self):
        counts = word_vector.Counts(self.dna_records.length_list,
                                    self.pattern2)
        exp = [
            "TA\t3 3 2",
            "AC\t4 1 2",
            "GG\t1 4 2",
            "AG\t1 2 1",

# 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_vector.py
# class Counts:
# class Bools(Counts):
# class Freqs(Counts):
# class FreqsStd(Freqs):
# class WeightModel:
# class CountsWeight(Counts):
# class FreqsWeight(Freqs):
# class WordModel:
# class EqualFreqs(WordModel):
# class EquilibriumFreqs(WordModel):
# class Composition(Counts):
#     def __init__(self, seq_lengths, patterns):
#     def _get_counts_occurrence(seq_count, patterns):
#     def __getitem__(self, seqidx):
#     def __str__(self):
#     def format(self, decimal_places=3):
#     def __init__(self, seq_lengths, patterns):
#     def __init__(self, seq_lengths, patterns):
#     def __relative_freqs(self):
#     def __init__(self, seq_lengths, patterns, freqmodel):
#     def __overlaps(self, freqmodel):
#     def __standardize_freqs(self, freqmodel):
#     def __init__(self, char_weights, wtype='content'):
#     def content(self, vector, patterns):
#     def __init__(self, seq_lengths, patterns, weightmodel):
#     def __init__(self, seq_lengths, patterns, weightmodel):
#     def probabilities(self, word):
#     def overlap_capability(self, word):
#     def var(self, word, seq_len, word_len=None, overlap_capability=None,
#             word_probs=None):
#     def __init__(self, alphabet_size):
#     def probabilities(self, word):
#     def __init__(self, equilibrium_frequencies):
#     def probabilities(self, word):
#     def __init__(self, seq_lengths, patterns, patterns1, patterns2):
#     def __check_patlen(self):
#     def __markov_chain_freqs(self, seqnum, seqlen, patnum, patlen, pattern):
#     def __composition(self, seqnum, seqlen):
# def _read_charval_file(handle):
# def main():


# Path: tests/test_word_vector.py
import unittest
from alfpy import word_pattern
from alfpy import word_vector
from . import utils

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

    def __init__(self, *args, **kwargs):
        super(WordVectorTest, self).__init__(*args, **kwargs)
        utils.ModulesCommonTest.set_test_data()
        self.pattern1 = word_pattern.create(self.dna_records.seq_list, 1)
        self.pattern2 = word_pattern.create(self.dna_records.seq_list, 2)
        self.pattern3 = word_pattern.create(self.dna_records.seq_list, 3)

    def test_counts_pattern1(self):
        counts = word_vector.Counts(self.dna_records.length_list,
                                    self.pattern1)
        exp = ["A\t8 4 6",
               "G\t6 6 3",
               "C\t6 3 4",
               "T\t5 5 2"]
        lengths = [25, 18, 15]
        self.assertEqual(counts.format(decimal_places=0), "\n".join(exp))
        # Counts in a sequence should sum to sequence length.
        for i in range(len(counts.data)):
            self.assertEqual(sum(counts.data[i]), lengths[i])

    def test_counts_pattern2(self):
        counts = word_vector.Counts(self.dna_records.length_list,
                                    self.pattern2)
        exp = [
            "TA\t3 3 2",
            "AC\t4 1 2",
            "GG\t1 4 2",
            "AG\t1 2 1",

            "CT\t0 3 1",