Created
October 7, 2015 16:01
-
-
Save skaae/b923722698ce13b0cc9f to your computer and use it in GitHub Desktop.
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
def find_prot2(fasta_dict, re_str): | |
'''Search through a dictionary of fasta entries using a regular expression''' | |
# Import re module | |
import re # typically imported at top of module file | |
# Create pattern object | |
pattern = re.compile(re_str) | |
# Create empty list to store results | |
result_list = [] | |
# Iterate over all keys in dictionary | |
for key in fasta_dict.keys(): | |
# If the pattern matches, append to result_list | |
if pattern.match(key): | |
result_list.append(key) | |
return result_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment