# Path: seqcluster/libs/classes.py
# class sequence:
#     """
#     Object with information about sequences, counts, size, position, id and score
#     """
#     def __init__(self, seq_id, seq=None, freq=None):
#         # self.seq = seq
#         # self.freq = copy.deepcopy(freq)
#         # self.norm_freq = copy.deepcopy(freq)
#         self.pos = {}
#         self.id = seq_id
#         self.align = 0
#         self.score = 0
#         self.factor = {}
# 
#     def set_seq(self, seq):
#         self.seq = seq
#         self.len = len(seq)
# 
#     def set_freq(self, freq):
#         self.freq = copy.deepcopy(freq)
#         self.norm_freq = copy.deepcopy(freq)
# 
#     def add_pos(self, pos_id, pos):
#         self.pos[pos_id] = pos
# 
#     def total(self):
#         return sum(self.freq.values())
# 
# Path: seqcluster/libs/tool.py
# def _normalize_seqs(s, t):
#     """Normalize to DESeq2"""
#     for ids in s:
#         obj = s[ids]
#         [obj.norm_freq.update({sample: 1.0 * obj.freq[sample] / t[sample]}) for sample in obj.norm_freq]
#         s[ids] = obj
#     return s


from collections import defaultdict
from seqcluster.libs.classes import sequence
from seqcluster.libs.tool import _normalize_seqs
import pybedtools
import numpy as np
import pandas as pd
import seqcluster.libs.logger as mylog
    seq_obj = _normalize_seqs(seq_obj, size_factor)
    return seq_obj, total, index


def parse_ma_file_raw(in_file):
    """
    read seqs.ma file and create dict with
    sequence object
    """
    name = ""
    index = 1
    total = defaultdict(int)
    seq_obj = defaultdict(sequence)
    ratio = list()
    with open(in_file) as handle_in:
        line = handle_in.readline().strip()
        cols = line.split("\t")
        samples = cols[2:]
        for line in handle_in:
            line = line.strip()
            cols = line.split("\t")
            name = int(cols[0].replace("seq_", ""))
            seq = cols[1]
            exp = {}
            for i in range(len(samples)):
                exp[samples[i]] = int(cols[i+2])
                total[samples[i]] += int(cols[i+2])
            ratio.append(np.array(list(exp.values())) / np.mean(list(exp.values())))
            index = index+1
            if name not in seq_obj:

# Path: seqcluster/libs/classes.py
# class sequence:
#     """
#     Object with information about sequences, counts, size, position, id and score
#     """
#     def __init__(self, seq_id, seq=None, freq=None):
#         # self.seq = seq
#         # self.freq = copy.deepcopy(freq)
#         # self.norm_freq = copy.deepcopy(freq)
#         self.pos = {}
#         self.id = seq_id
#         self.align = 0
#         self.score = 0
#         self.factor = {}
# 
#     def set_seq(self, seq):
#         self.seq = seq
#         self.len = len(seq)
# 
#     def set_freq(self, freq):
#         self.freq = copy.deepcopy(freq)
#         self.norm_freq = copy.deepcopy(freq)
# 
#     def add_pos(self, pos_id, pos):
#         self.pos[pos_id] = pos
# 
#     def total(self):
#         return sum(self.freq.values())
# 
# Path: seqcluster/libs/tool.py
# def _normalize_seqs(s, t):
#     """Normalize to DESeq2"""
#     for ids in s:
#         obj = s[ids]
#         [obj.norm_freq.update({sample: 1.0 * obj.freq[sample] / t[sample]}) for sample in obj.norm_freq]
#         s[ids] = obj
#     return s


# Path: seqcluster/libs/inputs.py
from collections import defaultdict
from seqcluster.libs.classes import sequence
from seqcluster.libs.tool import _normalize_seqs
import pybedtools
import numpy as np
import pandas as pd
import seqcluster.libs.logger as mylog

    seq_obj = _normalize_seqs(seq_obj, size_factor)
    return seq_obj, total, index


def parse_ma_file_raw(in_file):
    """
    read seqs.ma file and create dict with
    sequence object
    """
    name = ""
    index = 1
    total = defaultdict(int)
    seq_obj = defaultdict(sequence)
    ratio = list()
    with open(in_file) as handle_in:
        line = handle_in.readline().strip()
        cols = line.split("\t")
        samples = cols[2:]
        for line in handle_in:
            line = line.strip()
            cols = line.split("\t")
            name = int(cols[0].replace("seq_", ""))
            seq = cols[1]
            exp = {}
            for i in range(len(samples)):
                exp[samples[i]] = int(cols[i+2])
                total[samples[i]] += int(cols[i+2])
            ratio.append(np.array(list(exp.values())) / np.mean(list(exp.values())))
            index = index+1
            if name not in seq_obj:

                seq_obj[name] = sequence(name)