Esempio n. 1
0
def compress_miso(output_filename, input_dirs,
                  comp_ext=".misozip"):
    """
    Compress a directory containing MISO files.

    Traverse directories, one by one, and look for directories
    that contain
    """
    output_filename = utils.pathify(output_filename)
    for input_dir in input_dirs:
        if not os.path.isdir(input_dir):
            print "Error: Cannot find directory %s" %(input_dir)
            sys.exit(1)
    if not os.path.basename(output_filename).endswith(comp_ext):
        print "Error: Compressed output filename must end in %s" \
              %(comp_ext)
        sys.exit(1)
    if os.path.isfile(output_filename):
        print "Error: Output filename exists. Please delete %s to overwrite." \
              %(output_filename)
        sys.exit(1)
    t1 = time.time()
    miso_comp = MISOCompressor()
    miso_comp.compress(output_filename, input_dirs)
    t2 = time.time()
    print "Compression took %.2f minutes." %((t2 - t1)/60.)
Esempio n. 2
0
def compress_miso(output_filename, input_dirs,
                  comp_ext=".misozip"):
    """
    Compress a directory containing MISO files.

    Traverse directories, one by one, and look for directories
    that contain
    """
    output_filename = utils.pathify(output_filename)
    for input_dir in input_dirs:
        if not os.path.isdir(input_dir):
            print "Error: Cannot find directory %s" %(input_dir)
            sys.exit(1)
    if not os.path.basename(output_filename).endswith(comp_ext):
        print "Error: Compressed output filename must end in %s" \
              %(comp_ext)
        sys.exit(1)
    if os.path.isfile(output_filename):
        print "Error: Output filename exists. Please delete %s to overwrite." \
              %(output_filename)
        sys.exit(1)
    t1 = time.time()
    miso_comp = MISOCompressor()
    miso_comp.compress(output_filename, input_dirs)
    t2 = time.time()
    print "Compression took %.2f minutes." %((t2 - t1)/60.)
Esempio n. 3
0
def main():
    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("--compress",
                      dest="compress",
                      nargs=2,
                      default=None,
                      help="Compress a directory containing MISO output. "
                      "Takes as arguments: (1) the output filename of the "
                      "compressed file, (2) a comma-separated list of "
                      "directory names to be compressed. "
                      "Example: --compress output.misozip dirname1,dirname2")
    parser.add_option("--uncompress",
                      dest="uncompress",
                      nargs=2,
                      default=None,
                      help="Uncompress a file generated by compress_miso. "
                      "Takes as arguments: (1) the filename to be "
                      "uncompressed, and (2) the directory to place the "
                      "uncompressed representation into. "
                      "Example: --uncompress output.misozip outputdir")
    (options, args) = parser.parse_args()

    if (options.compress is None) and (options.uncompress is None):
        greeting()
        sys.exit(1)
    elif (options.compress is not None) and (options.uncompress is not None):
        # Can't be given both.
        greeting()
        print "Error: Cannot process --compress and --uncompress at same time."
        sys.exit(1)

    if options.compress is not None:
        output_filename = utils.pathify(options.compress[0])
        input_dirs = [utils.pathify(d) \
                      for d in options.compress[1].split(",")]
        compress_miso(output_filename, input_dirs)

    if options.uncompress is not None:
        compressed_filename = utils.pathify(options.uncompress[0])
        output_dir = utils.pathify(options.uncompress[1])
        uncompress_miso(compressed_filename, output_dir)
Esempio n. 4
0
def view_miso_db(db_fname):
    db_fname = misc_utils.pathify(db_fname)
    if not os.path.isfile(db_fname):
        print "Error: %s does not exist." %(db_fname)
        sys.exit(1)
    curr_db = miso_db.MISODatabase(db_fname)
    event_names = curr_db.get_all_event_names()
    num_events = len(event_names)
    print "Database contains %d events" %(num_events)
    for event in event_names:
        print event
Esempio n. 5
0
def view_miso_db(db_fname):
    db_fname = misc_utils.pathify(db_fname)
    if not os.path.isfile(db_fname):
        print "Error: %s does not exist." % (db_fname)
        sys.exit(1)
    curr_db = miso_db.MISODatabase(db_fname)
    event_names = curr_db.get_all_event_names()
    num_events = len(event_names)
    print "Database contains %d events" % (num_events)
    for event in event_names:
        print event
Esempio n. 6
0
def main():
    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("--compress", dest="compress", nargs=2, default=None,
                      help="Compress a directory containing MISO output. "
                      "Takes as arguments: (1) the output filename of the "
                      "compressed file, (2) a comma-separated list of "
                      "directory names to be compressed. "
                      "Example: --compress output.misozip dirname1,dirname2")
    parser.add_option("--uncompress", dest="uncompress", nargs=2, default=None,
                      help="Uncompress a file generated by compress_miso. "
                      "Takes as arguments: (1) the filename to be "
                      "uncompressed, and (2) the directory to place the "
                      "uncompressed representation into. "
                      "Example: --uncompress output.misozip outputdir")
    (options, args) = parser.parse_args()

    if (options.compress is None) and (options.uncompress is None):
        greeting()
        sys.exit(1)
    elif (options.compress is not None) and (options.uncompress is not None):
        # Can't be given both.
        greeting()
        print "Error: Cannot process --compress and --uncompress at same time."
        sys.exit(1)

    if options.compress is not None:
        output_filename = utils.pathify(options.compress[0])
        input_dirs = [utils.pathify(d) \
                      for d in options.compress[1].split(",")]
        compress_miso(output_filename, input_dirs)

    if options.uncompress is not None:
        compressed_filename = utils.pathify(options.uncompress[0])
        output_dir = utils.pathify(options.uncompress[1])
        uncompress_miso(compressed_filename, output_dir)
Esempio n. 7
0
def is_miso_rawdir(dirname, miso_ext=".miso"):
    """
    Return true if the given directory is one which contains
    raw MISO output (i.e. if it contains MISO chromosome directories.)
    """
    dirname = utils.pathify(dirname)
    if not os.path.isdir(dirname):
        return False
    filenames = glob.glob(os.path.join(dirname, "*.miso"))
    # If all of the subdirectories of the current directory
    # contain raw MISO (*.miso) files, consider it a raw MISO
    # output directory.
    if len(filenames) == 0:
        return False
    for fname in filenames:
        if not fname.endswith(miso_ext):
            return False
    return True
Esempio n. 8
0
def is_miso_rawdir(dirname, miso_ext=".miso"):
    """
    Return true if the given directory is one which contains
    raw MISO output (i.e. if it contains MISO chromosome directories.)
    """
    dirname = utils.pathify(dirname)
    if not os.path.isdir(dirname):
        return False
    filenames = glob.glob(os.path.join(dirname, "*.miso"))
    # If all of the subdirectories of the current directory
    # contain raw MISO (*.miso) files, consider it a raw MISO
    # output directory.
    if len(filenames) == 0:
        return False
    for fname in filenames:
        if not fname.endswith(miso_ext):
            return False
    return True