How to use the pyfaidx.UnsupportedCompressionFormat function in pyfaidx

To help you get started, we’ve selected a few pyfaidx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mdshw5 / pyfaidx / tests / test_Fasta_bgzip.py View on Github external
    @raises(UnsupportedCompressionFormat)
    def test_mutable_bgzf(self):
        fasta = Fasta('data/genes.fasta.gz', mutable=True)
github databio / refgenie / refgenie / refget.py View on Github external
def parse_fasta(fa_file):
    try:
        fa_object = pyfaidx.Fasta(fa_file)
    except pyfaidx.UnsupportedCompressionFormat:
        # pyfaidx can handle bgzip but not gzip; so we just hack it here and
        # unzip the file for checksumming, then rezip it for the rest of the
        # asset build.
        # TODO: streamline this to avoid repeated compress/decompress
        # in refgenie we feed this function with uncompressed, newly built
        # FASTA file, so compression issues are not relevant
        os.system("gunzip {}".format(fa_file))
        fa_file_unzipped = fa_file.replace(".gz", "")
        fa_object = pyfaidx.Fasta(fa_file_unzipped)
        os.system("gzip {}".format(fa_file_unzipped))
    return fa_object