示例#1
0
def load_peptide_set(peptide_length=[8, 9, 10, 11], nrows=None):
    peptide_lengths = int_or_seq(peptide_length)
    lens = "_".join(str(n) for n in peptide_lengths)
    cache_filename = \
        "reference_peptide_set_" + lens + "_nrows_" + str(nrows) + ".pickle.gz"

    def save_set(src_path, dst_path):
        string_set = _generate_set(src_path, peptide_lengths, nrows)
        with GzipFile(dst_path, 'w') as out_file:
            out_file.write(pickle.dumps(string_set))
        return string_set

    def load_set(path):
        result = None
        with GzipFile(path, 'r') as in_file:
            result = pickle.loads(in_file.read())
        return result

    return fetch_and_transform(
        transformed_filename=cache_filename,
        transformer=save_set,
        loader=load_set,
        source_filename=FASTA_FILENAME,
        source_url=FULL_URL,
        subdir=cache.subdir)
示例#2
0
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)
示例#3
0
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)
示例#4
0
def load_peptide_set(peptide_length=[8, 9, 10, 11], nrows=None):
    peptide_lengths = int_or_seq(peptide_length)
    lens = "_".join(str(n) for n in peptide_lengths)
    cache_filename = \
        "reference_peptide_set_" + lens + "_nrows_" + str(nrows) + ".pickle.gz"

    def save_set(src_path, dst_path):
        string_set = _generate_set(src_path, peptide_lengths, nrows)
        with GzipFile(dst_path, 'w') as out_file:
            out_file.write(cPickle.dumps(string_set))
        return string_set

    def load_set(path):
        result = None
        with GzipFile(path, 'r') as in_file:
            result = cPickle.loads(in_file.read())
        return result

    return fetch_and_transform(transformed_filename=cache_filename,
                               transformer=save_set,
                               loader=load_set,
                               source_filename=FASTA_FILENAME,
                               source_url=FULL_URL,
                               subdir=cache.subdir)