Skip to content

Instantly share code, notes, and snippets.

@avalind
Created July 28, 2015 17:01
Show Gist options
  • Save avalind/097c744c5b4d6e2e2eff to your computer and use it in GitHub Desktop.
Save avalind/097c744c5b4d6e2e2eff to your computer and use it in GitHub Desktop.
Simple no-bullshit Fasta reader
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