Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sample = ['GTA','GGG','CAC']
- def read_dna(dna_file):
- dna_data = ""
- with open(dna_file, "r") as f:
- for line in f:
- dna_data += line
- return dna_data
- def dna_codons(dna):
- codons = []
- for item in range(0, len(dna) + 1, 3):
- if item + 3 < len(dna):
- codons.append(dna[item:item+3])
- return codons
- def match_dna(dna):
- matches = 0
- for codon in dna:
- if codon in sample:
- matches += 1
- return matches
- def is_criminal(dna_sample):
- dna_data = read_dna(dna_sample)
- codons = dna_codons(dna_data)
- num_matches = match_dna(codons)
- if num_matches >= 3:
- print("Matches: %d" % num_matches)
- print("Investigation should continue")
- else:
- print("Matches: %d" % num_matches)
- print("Suspect can be freed")
- for num in range(1,4):
- is_criminal("suspect%d.txt" % num)
Advertisement
Add Comment
Please, Sign In to add comment