# Path: modules/pepdata/common.py
# def _prepare_memoization_key(args, kwargs):
# def memoize(fn):
#     def wrapped_fn(*args, **kwargs):
# def int_or_seq(x):
# def dataframe_from_counts(counts):


import cPickle
import re
import Bio.SeqIO
import pandas as pd
from gzip import GzipFile
from datacache import fetch_and_transform
from progressbar import ProgressBar
from .common import int_or_seq, dataframe_from_counts, cache
                    peptides.add(seq[i:i + size])
            pbar.update(seq_num + 1)
        pbar.finish()
    return peptides


def load_peptide_counts(peptide_length=[8, 9, 10, 11], nrows=None):
    """
    List of all reference peptides encoded in a reference human exome
    """
    peptide_lengths = int_or_seq(peptide_length)
    lens = "_".join(str(n) for n in peptide_lengths)
    cache_filename = \
        "reference_peptide_counts_" + lens + "_nrows_" + str(nrows) + ".csv"

    def save_counts(src_path, dst_path):
        counts = _generate_counts(src_path, peptide_lengths, nrows)
        print("Saving %s" % dst_path)
        counts.to_csv(dst_path)
        return counts

    return fetch_and_transform(
        transformed_filename=cache_filename,
        transformer=save_counts,
        loader=pd.read_csv,
        source_filename=FASTA_FILENAME,
        source_url=FULL_URL,
        subdir=cache.subdir)

def load_peptide_set(peptide_length=[8, 9, 10, 11], nrows=None):

# Path: modules/pepdata/common.py
# def _prepare_memoization_key(args, kwargs):
# def memoize(fn):
#     def wrapped_fn(*args, **kwargs):
# def int_or_seq(x):
# def dataframe_from_counts(counts):


# Path: modules/pepdata/reference.py
import cPickle
import re
import Bio.SeqIO
import pandas as pd
from gzip import GzipFile
from datacache import fetch_and_transform
from progressbar import ProgressBar
from .common import int_or_seq, dataframe_from_counts, cache

                    peptides.add(seq[i:i + size])
            pbar.update(seq_num + 1)
        pbar.finish()
    return peptides


def load_peptide_counts(peptide_length=[8, 9, 10, 11], nrows=None):
    """
    List of all reference peptides encoded in a reference human exome
    """
    peptide_lengths = int_or_seq(peptide_length)
    lens = "_".join(str(n) for n in peptide_lengths)
    cache_filename = \
        "reference_peptide_counts_" + lens + "_nrows_" + str(nrows) + ".csv"

    def save_counts(src_path, dst_path):
        counts = _generate_counts(src_path, peptide_lengths, nrows)
        print("Saving %s" % dst_path)
        counts.to_csv(dst_path)
        return counts

    return fetch_and_transform(
        transformed_filename=cache_filename,
        transformer=save_counts,
        loader=pd.read_csv,
        source_filename=FASTA_FILENAME,
        source_url=FULL_URL,
        subdir=cache.subdir)

def load_peptide_set(peptide_length=[8, 9, 10, 11], nrows=None):

    peptide_lengths = int_or_seq(peptide_length)