Skip to content

Instantly share code, notes, and snippets.

@skaae
Created October 21, 2015 18:28
Show Gist options
  • Save skaae/a2a8e85581982d55c288 to your computer and use it in GitHub Desktop.
Save skaae/a2a8e85581982d55c288 to your computer and use it in GitHub Desktop.
def fasta_names_to_dict(fasta_filename):
handin6.py
"""Extract FASTA IDs from file to dictionary"""
names_dict = {}
fasta_file = open(fasta_filename)
for line in fasta_file:
# Add to dictionary if line starts with '>'
# Call to fasta_label_to_id to extract id from line
if line.startswith('>'):
# We don't need the values in the dictionary - just using ""
names_dict[fasta_label_to_id(line)] = ""
return names_dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment