Skip to content

Instantly share code, notes, and snippets.

@StephenFordham
Created May 3, 2019 09:22
Show Gist options
  • Save StephenFordham/8376fc1162d610bcf8f61d9a501fb92c to your computer and use it in GitHub Desktop.
Save StephenFordham/8376fc1162d610bcf8f61d9a501fb92c to your computer and use it in GitHub Desktop.
seq_comparison
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()
@sgordon15
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment