Created
May 3, 2019 09:22
-
-
Save StephenFordham/8376fc1162d610bcf8f61d9a501fb92c to your computer and use it in GitHub Desktop.
seq_comparison
This file contains hidden or 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 re | |
filename = 'seq_match_compare.csv' | |
f = open(filename, 'w') | |
headers = 'Query_ID, Query_Seq, Ref_species, Ref_seq, Match, Match start Position\n' | |
f.write(headers) | |
for ID, seq in Unknown_dict.items(): | |
for species, seq1 in Ref_dict.items(): | |
m = re.search(seq, seq1) | |
if m: | |
match = m.group() | |
pos = m.start() + 1 | |
f.write(str(ID) + ',' + seq + ',' + species + ',' + seq1 + ',' + match + ',' + str(pos) + '\n') | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you explain exactly how the for loop works and also show me how I could compare ID and species as well like compare two columns of each file at the same time