Created
July 28, 2015 17:01
-
-
Save avalind/097c744c5b4d6e2e2eff to your computer and use it in GitHub Desktop.
Simple no-bullshit Fasta reader
This file contains 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
import fileinput | |
def fastaparse(): | |
fasta = {} | |
current_id = None | |
buf="" | |
for line in fileinput.input(): | |
if line[0] == ">": | |
if current_id is None: | |
current_id = line[1:].strip() | |
else: | |
fasta[current_id] = buf | |
current_id = line[1:].strip() | |
buf = "" | |
else: | |
buf += line.strip() | |
return fasta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment