Last active
August 24, 2023 19:59
-
-
Save chasemc/28ef621b985f2cc342903dd43789d145 to your computer and use it in GitHub Desktop.
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 parse_fasta(filepath: str) -> Generator[str, str]: | |
seq_id = "" | |
with open(filepath, "r") as h: | |
seq_id = "" | |
seq = "" | |
for i in h: | |
if i[0] == ">": | |
if seq_id: | |
yield (seq_id, seq) | |
seq_id = i[1:].strip() | |
seq = "" | |
else: | |
seq += i.strip() | |
yield (seq_id, seq) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment