Lecture Notes 18 Oct 2017 def main(): # open input file in_file = open ("./input.txt", "r") # open output file out_file = open ("./output.txt", "w") # read line by line and write out for line in in_file: out_file.write (line) print ("Output file is written.") # close the files in_file.close() out_file.close() main() def main (): # open file for reading in_file = open ("./dna.txt", "r") # read the number of pairs num_pairs = in_file.readline () num_pairs = num_pairs.strip() num_pairs = int (num_pairs) # read each pair of dna strands for i in range (num_pairs): st1 = in_file.readline() st2 = in_file.readline() st1 = st1.strip() st2 = st2.strip() st1 = st1.upper () st2 = st2.upper () # order the strands by size if (len(st1) > len (st2)): dna1 = st1 dna2 = st2 else: dna1 = st2 dna2 = st1 # get all substrands of dna2 wnd = len (dna2) while (wnd > 1): start_idx = 0 while ((start_idx + wnd) <= len(dna2)): sub_strand = dna2[start_idx: start_idx + wnd] print (sub_strand) # move the window by one start_idx += 1 # decrease the window size wnd = wnd - 1 # close the file in_file.close() main()