from P1.Seq1 import Seq FOLDER = "../Session-04/" Filename = ["U5", "ADA", "FRAT1", "FXN", "RNU6_269P"] TypeDOC = '.txt' bases = ['A', 'C', 'G', 'T'] print('----| Practice 1, Exercise 10| ----') i = 0 for element in Filename: seq = Seq() seq.read_fasta(FOLDER + element + TypeDOC) Dictionary_bases = seq.seq_count() Amount_bases = list(Dictionary_bases.values()) Most_freq = max(Amount_bases) print('Gene ', element, ': Most frequent base: ', bases[Amount_bases.index(Most_freq)])
counter_A = seq.count_base(all_bases[0]) counter_C = seq.count_base(all_bases[1]) counter_G = seq.count_base(all_bases[2]) counter_T = seq.count_base(all_bases[3]) per_A = "{:.1f}".format(100 * counter_A / s_length) per_C = "{:.1f}".format(100 * counter_C / s_length) per_G = "{:.1f}".format(100 * counter_G / s_length) per_T = "{:.1f}".format(100 * counter_T / s_length) # Print the length termcolor.cprint(f"Total length:", "green", end=" ") print(s_length) termcolor.cprint(f"A", "blue", end=" ") print(f"{counter_A} {per_A}%") termcolor.cprint(f"C", "blue", end=" ") print(f"{counter_C} {per_C}%") termcolor.cprint(f"G", "blue", end=" ") print(f"{counter_G} {per_G}%") termcolor.cprint(f"T", "blue", end=" ") print(f"{counter_T} {per_T}%") # For printing the most frequent base dictionary = seq.seq_count() list_values = list(dictionary.values()) max_base = max(list_values) ci = dictionary.items() termcolor.cprint("Most frequent Base", 'green', end="") print(f": {all_bases[list_values.index(max_base)]}")
from P1.Seq1 import Seq print("-----| Practice 1, Exercise 9 |------") FOLDER = "../Session-04/" TypeDoc = '.txt' seq = Seq(FOLDER + 'U5' + TypeDoc) seq.read_fasta(FOLDER + 'U5' + TypeDoc) print("Sequence ", seq, ':', "(Length: ", seq.len(), ')', seq) print(" Bases:", seq.seq_count()) print(' Rev: ', seq.reverse(), '\n Comp: ', seq.complement())