termcolor.cprint(f"Gene:","green",end=" ") print(G) termcolor.cprint(f"Description:","green",end=" ") print(Description) # Introduce the sequence s = Seq(response["seq"]) s_length = s.len() termcolor.cprint(f"Total length: ","green",end="") print(s_length) for b in all_bases: count_b = s.count_base(b) p =round(count_b *( 100 / s_length),1)#percentage calculation with just 1 decimal termcolor.cprint(f"{b}", "blue", end=" ") print(f"{count_b} {p} %") dict = s.count() # method from P1 to find the most repeated base list_dict = list(dict.values()) maximum = max(list_dict) freq_base = all_bases[list_dict.index(maximum)] termcolor.cprint("Most frequent base : ","green",end="") print(freq_base)
from P1.Seq1 import Seq folder = "../Session-04/" filenames = ["U5", "ADA", "FRAT1", "FXN", "RNU6_269P"] all_bases = ["A", "C", "G", "T"] print("-----|Practice 1 , Exercise 10 |------") for filename in filenames: s0 = Seq() s0.read_fasta(folder + filename) dictionary = s0.count() list_values = list(dictionary.values()) maximum = max(list_values) print( f"Gene {filename}: Most frequent Base: {all_bases[list_values.index(maximum)]}" )