Esempio n. 1
0
def ensure_pickle_goodness(pickle_filename, root_dir, fasta_files_to_add=None):
    """
    Old versions of IceIterative.write_pickle is missing some key/values.
    Add if needed.
    Return a good pickle object, and the pickle's filename
    """
    a = load(open(pickle_filename))
    if realpath(a['fasta_filename']) != current_fasta(root_dir):
        raise ValueError(
            "The pickle file %s indicates that " % pickle_filename +
            "current.fasta is not being used. ICE likely did not " +
            "finish to a point that could be picked up.")

    a['newids'] = check_n_fix_newids(a)

    if fasta_files_to_add is not None:
        for f in fasta_files_to_add.split(','):
            if not op.exists(f):
                raise IOError("%s is not a valid fasta file to add!" % f)
            if f in a['fasta_filenames_to_add']:
                log.warning("%s is already in to-add list. Ignore.", f)
            a['fasta_filenames_to_add'].append(f)
    if 'root_dir' not in a:
        log.warning("Pickle %s missing some key-values. Fixing it.",
                    pickle_filename)
        a['root_dir'] = root_dir
        a['all_fasta_filename'] = a['all_fasta_fiilename']
        a['qv_prob_threshold'] = 0.03
        fixed_pickle_filename = pickle_filename + ".fixed"
        with open(fixed_pickle_filename, 'w') as f:
            dump(a, f)
        log.info("Fixed pickle written to %s", fixed_pickle_filename)
        return a, fixed_pickle_filename
    else:
        # newid might have been fixed, STILL output pickle writing anyway
        with open(pickle_filename, 'w') as f:
            dump(a, f)
        return a, pickle_filename
Esempio n. 2
0
def current_fastq(root_dir):
    """Return filename of root_dir/current.fastq, which is used in
    the `current` ICE iteration."""
    return realpath(op.join(root_dir, "current.fastq"))