Created
July 13, 2018 19:37
-
-
Save sminot/39c3b52d97279c6016f327a48381eca2 to your computer and use it in GitHub Desktop.
Read a gzipped fasta from s3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def read_fasta_from_s3(bucket_name, key_name, sep="\t"): | |
| s3 = boto3.client('s3') | |
| retr = s3.get_object(Bucket=bucket_name, Key=key_name) | |
| bytestream = io.BytesIO(retr['Body'].read()) | |
| got_text = gzip.GzipFile(None, 'rb', fileobj=bytestream).read().decode('utf-8') | |
| for header, seq in SimpleFastaParser(io.StringIO(got_text)): | |
| yield header, seq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment