Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@raises(UnsupportedCompressionFormat)
def test_mutable_bgzf(self):
fasta = Fasta('data/genes.fasta.gz', mutable=True)
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