import common import itertools alphabet, n = common.multi_line_reader('LEXF.txt') alphabet = alphabet.split() kmers = sorted(list(itertools.product(alphabet, repeat=int(n)))) with open('LEXF_result.txt', 'w') as output_file: [print(''.join(elem), file=output_file) for elem in kmers]
import common import numpy input_lines = common.multi_line_reader('RSTR.txt') number, gc_cont = int(input_lines[0].split()[0]), float( input_lines[0].split()[1]) sequence = input_lines[1] prob_single_letter = [ gc_cont / 2 if letter in ['G', 'C'] else (1 - gc_cont) / 2 for letter in sequence ] prob_single_sequence = numpy.prod(prob_single_letter) prob_multiple_sequence = 1 - (1 - prob_single_sequence)**number print(round(prob_multiple_sequence, 3))
import common #Just using the fact that N(edges) = N(nodes) - 1 lines = common.multi_line_reader('TREE.txt') nodes_num = int(lines[0]) print(nodes_num - len(lines))
import common input_lines = common.multi_line_reader('SETO.txt') A, B, complete_set = eval(input_lines[1]), eval(input_lines[2]), set(range(1, int(input_lines[0]) + 1)) print('\n'.join(map(str, [A | B, A & B, A - B, B - A, complete_set - A, complete_set - B])))
import common import numpy as np strand, gc_cont = common.multi_line_reader('PROB.txt') gc_cont_list = list(map(float, gc_cont.split())) prob_list = [] for gc_cont in gc_cont_list: prob = [ gc_cont / 2 if letter in ['G', 'C'] else (1 - gc_cont) / 2 for letter in strand ] prob_list.append(str(round(np.log10(np.prod(prob)), 3))) print(' '.join(prob_list))