Esempio n. 1
0
def _bzip_gzip(in_file):
    """
    convert from bz2 to gz
    """
    base, first_ext = os.path.splitext(in_file)
    gzipped_file = base + ".gz"
    if not file_exists(gzipped_file):
        return gzipped_file
    if (fastq.is_fastq(base) and utils.is_bzipped(in_file)
          and not objectstore.is_remote(in_file)):
        if file_exists(gzipped_file):
            return gzipped_file
        message = "gzipping {in_file}.".format(in_file=in_file)
        do.run("bunzip2 -c {in_file} | gzip > {gzipped_file}".format(**locals()), message)
        return gzipped_file
    return in_file
Esempio n. 2
0
def _gzip_fastq(in_file):
    """
    gzip a fastq file if it is not already gzipped, handling conversion
    from bzip to gzipped files
    """
    if fastq.is_fastq(in_file) and not objectstore.is_remote(in_file):
        if utils.is_bzipped(in_file):
            return _bzip_gzip(in_file)
        elif not utils.is_gzipped(in_file):
            gzipped_file = in_file + ".gz"
            if file_exists(gzipped_file):
                return gzipped_file
            message = "gzipping {in_file}.".format(in_file=in_file)
            with file_transaction(gzipped_file) as tx_gzipped_file:
                do.run("gzip -c {in_file} > {tx_gzipped_file}".format(**locals()),
                       message)
            return gzipped_file
    return in_file
Esempio n. 3
0
def _bzip_gzip(in_file):
    """
    convert from bz2 to gz
    """
    if not utils.is_bzipped(in_file):
        return in_file
    base, first_ext = os.path.splitext(in_file)
    gzipped_file = base + ".gz"
    if (fastq.is_fastq(base) and
        not objectstore.is_remote(in_file)):

        if file_exists(gzipped_file):
            return gzipped_file
        message = "gzipping {in_file}.".format(in_file=in_file)
        with file_transaction(gzipped_file) as tx_gzipped_file:
            do.run("bunzip2 -c {in_file} | gzip > {tx_gzipped_file}".format(**locals()), message)
        return gzipped_file
    return in_file
Esempio n. 4
0
def _gzip_fastq(in_file):
    """
    gzip a fastq file if it is not already gzipped, handling conversion
    from bzip to gzipped files
    """
    if fastq.is_fastq(in_file) and not objectstore.is_remote(in_file):
        if utils.is_bzipped(in_file):
            return _bzip_gzip(in_file)
        elif not utils.is_gzipped(in_file):
            gzipped_file = in_file + ".gz"
            if file_exists(gzipped_file):
                return gzipped_file
            message = "gzipping {in_file}.".format(in_file=in_file)
            with file_transaction(gzipped_file) as tx_gzipped_file:
                do.run("gzip -c {in_file} > {tx_gzipped_file}".format(**locals()),
                       message)
            return gzipped_file
    return in_file
Esempio n. 5
0
def _bzip_gzip(in_file, out_dir=None):
    """
    convert from bz2 to gz
    """
    if not utils.is_bzipped(in_file):
        return in_file
    base, _ = os.path.splitext(in_file)
    if out_dir:
        gzipped_file = os.path.join(out_dir, os.path.basename(base) + ".gz")
    else:
        gzipped_file = base + ".gz"
    if (fastq.is_fastq(base) and not objectstore.is_remote(in_file)):
        if file_exists(gzipped_file):
            return gzipped_file
        message = "gzipping {in_file} to {gzipped_file}.".format(
            in_file=in_file, gzipped_file=gzipped_file)
        with file_transaction(gzipped_file) as tx_gzipped_file:
            do.run("bunzip2 -c {in_file} | gzip > {tx_gzipped_file}".format(**locals()), message)
        return gzipped_file
    return in_file
Esempio n. 6
0
def _bzip_gzip(in_file, out_dir=None):
    """
    convert from bz2 to gz
    """
    if not utils.is_bzipped(in_file):
        return in_file
    base, _ = os.path.splitext(in_file)
    if out_dir:
        gzipped_file = os.path.join(out_dir, os.path.basename(base) + ".gz")
    else:
        gzipped_file = base + ".gz"
    if (fastq.is_fastq(base) and not objectstore.is_remote(in_file)):
        if file_exists(gzipped_file):
            return gzipped_file
        message = "gzipping {in_file} to {gzipped_file}.".format(
            in_file=in_file, gzipped_file=gzipped_file)
        with file_transaction(gzipped_file) as tx_gzipped_file:
            do.run("bunzip2 -c {in_file} | gzip > {tx_gzipped_file}".format(**locals()), message)
        return gzipped_file
    return in_file