Skip to content

Instantly share code, notes, and snippets.

@skaae
Created October 21, 2015 18:25
Show Gist options
  • Save skaae/495ee88bf8581d96add8 to your computer and use it in GitHub Desktop.
Save skaae/495ee88bf8581d96add8 to your computer and use it in GitHub Desktop.
def fasta_names_to_list(fasta_filename):
'''Extract FASTA IDs from file to list'''
names = []
# Open fasta file
fasta_file = open(fasta_filename)
# Iterate over lines
for line in fasta_file:
# Add to list if line starts with '>'
# Call to fasta_label_to_id to extract id from line
if line.startswith('>'):
names.append(fasta_label_to_id(line))
return names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment