# Path: alfpy/word_distance.py
# def geometric_mean(values):
#     def pwdist_euclid_squared(self, seq1idx, seq2idx):
#     def pwdist_euclid_norm(self, seq1idx, seq2idx):
#     def pwdist_euclid_seqlen1(self, seq1idx, seq2idx):
#     def pwdist_euclid_seqlen2(self, seq1idx, seq2idx):
#     def __angle_cos(self, seq1idx, seq2idx):
#     def pwdist_angle_cos_diss(self, seq1idx, seq2idx):
#     def pwdist_angle_cos_evol(self, seq1idx, seq2idx):
#     def pwdist_manhattan(self, seq1idx, seq2idx):
#     def pwdist_diff_abs_add(self, seq1idx, seq2idx):
#     def pwdist_chebyshev(self, seq1idx, seq2idx):
#     def pwdist_braycurtis(self, seq1idx, seq2idx):
#     def pwdist_diff_abs_mult(self, seq1idx, seq2idx):
#     def pwdist_diff_abs_mult1(self, seq1idx, seq2idx):
#     def pwdist_diff_abs_mult2(self, seq1idx, seq2idx):
#     def pwdist_kld(self, seq1idx, seq2idx):
#     def pwdist_jsd(self, seq1idx, seq2idx):
#         def entropy(p, q):
#     def pwdist_google(self, seq1idx, seq2idx):
#     def pwdist_lcc(self, seq1idx, seq2idx):
#     def pwdist_canberra(self, seq1idx, seq2idx):
#     def pwdist_minkowski(self, seq1idx, seq2idx, p=2):
# def main():
# class Distance(distance.Distance):
#         _P = x + 0.0000001
#         _Q = y + 0.0000001
#         _M = 0.5 * (_P + _Q)
# 
# 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: alfpy/utils/seqrecords.py
# class SeqRecords:
#     def __init__(self, id_list=None, seq_list=None):
#     def add(self, seqid, seq):
#     def fasta(self, wrap=70):
#     def length_list(self):
#     def __iter__(self):
#     def __len__(self):
#     def __repr__(self):
# def read_fasta(handle):
# def main():
# 
# Path: alfpy/version.py



import argparse
import sys
from alfpy import word_distance
from alfpy import word_pattern
from alfpy import word_rtd
from alfpy.utils import distmatrix
from alfpy.utils import seqrecords
from alfpy.version import __version__
def validate_args(parser):
    args = parser.parse_args()
    if args.word_size:
        if args.word_size < 1:
            parser.error('word size must be >= 1')
    elif args.word_pattern:
        p = word_pattern.read(args.word_pattern)
        if not p.pos_list:
            e = "{0} does not contain info on word positions.\n"
            e += "Please use: create_wordpattern.py with"
            e += " --word_position option."
            parser.error(e.format(args.word_pattern.name))
        else:
            args.word_pattern = p
    else:
        parser.error("Specify either: --word_size or --word_pattern.")
    return args


def main():
    parser = get_parser()
    args = validate_args(parser)

    seq_records = seqrecords.read_fasta(args.fasta)
    if args.word_size:
        p = word_pattern.create(seq_records.seq_list, args.word_size, True)
    else:
        p = args.word_pattern

    vector = word_rtd.create_vector(seq_records.count, p)

# Path: alfpy/word_distance.py
# def geometric_mean(values):
#     def pwdist_euclid_squared(self, seq1idx, seq2idx):
#     def pwdist_euclid_norm(self, seq1idx, seq2idx):
#     def pwdist_euclid_seqlen1(self, seq1idx, seq2idx):
#     def pwdist_euclid_seqlen2(self, seq1idx, seq2idx):
#     def __angle_cos(self, seq1idx, seq2idx):
#     def pwdist_angle_cos_diss(self, seq1idx, seq2idx):
#     def pwdist_angle_cos_evol(self, seq1idx, seq2idx):
#     def pwdist_manhattan(self, seq1idx, seq2idx):
#     def pwdist_diff_abs_add(self, seq1idx, seq2idx):
#     def pwdist_chebyshev(self, seq1idx, seq2idx):
#     def pwdist_braycurtis(self, seq1idx, seq2idx):
#     def pwdist_diff_abs_mult(self, seq1idx, seq2idx):
#     def pwdist_diff_abs_mult1(self, seq1idx, seq2idx):
#     def pwdist_diff_abs_mult2(self, seq1idx, seq2idx):
#     def pwdist_kld(self, seq1idx, seq2idx):
#     def pwdist_jsd(self, seq1idx, seq2idx):
#         def entropy(p, q):
#     def pwdist_google(self, seq1idx, seq2idx):
#     def pwdist_lcc(self, seq1idx, seq2idx):
#     def pwdist_canberra(self, seq1idx, seq2idx):
#     def pwdist_minkowski(self, seq1idx, seq2idx, p=2):
# def main():
# class Distance(distance.Distance):
#         _P = x + 0.0000001
#         _Q = y + 0.0000001
#         _M = 0.5 * (_P + _Q)
# 
# 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: alfpy/utils/seqrecords.py
# class SeqRecords:
#     def __init__(self, id_list=None, seq_list=None):
#     def add(self, seqid, seq):
#     def fasta(self, wrap=70):
#     def length_list(self):
#     def __iter__(self):
#     def __len__(self):
#     def __repr__(self):
# def read_fasta(handle):
# def main():
# 
# Path: alfpy/version.py



# Path: bin/calc_word_rtd.py
import argparse
import sys
from alfpy import word_distance
from alfpy import word_pattern
from alfpy import word_rtd
from alfpy.utils import distmatrix
from alfpy.utils import seqrecords
from alfpy.version import __version__

def validate_args(parser):
    args = parser.parse_args()
    if args.word_size:
        if args.word_size < 1:
            parser.error('word size must be >= 1')
    elif args.word_pattern:
        p = word_pattern.read(args.word_pattern)
        if not p.pos_list:
            e = "{0} does not contain info on word positions.\n"
            e += "Please use: create_wordpattern.py with"
            e += " --word_position option."
            parser.error(e.format(args.word_pattern.name))
        else:
            args.word_pattern = p
    else:
        parser.error("Specify either: --word_size or --word_pattern.")
    return args


def main():
    parser = get_parser()
    args = validate_args(parser)

    seq_records = seqrecords.read_fasta(args.fasta)
    if args.word_size:
        p = word_pattern.create(seq_records.seq_list, args.word_size, True)
    else:
        p = args.word_pattern

    vector = word_rtd.create_vector(seq_records.count, p)

    dist = word_rtd.Distance(vector, args.distance)