def print_calc(gene, param_json): context = {} e = Ensembl('', gene) information = e.ensembl3() if param_json: return information else: if information != Ensembl.GENE_NOT_FOUND_ERROR and information != Ensembl.FAIL_CONNECTION_ERROR: information = information['seq'] s1 = Seq(information) a_percentage, c_percentage, g_percentage, t_percentage = s1.percentages() context['gene'] = gene context['a_perc'] = a_percentage context['c_perc'] = c_percentage context['g_perc'] = g_percentage context['t_perc'] = t_percentage context['length'] = s1.len() contents = read_template_htm_file('html/info/geneCalc.html').render(context=context) return contents else: context['error_msg'] = information context['type'] = 'gene' context['input'] = gene contents = read_template_htm_file('html/not_found_error.html').render(context=context) return contents
def info(cs, sequence): print_colored('INFO', 'red') s = Seq(sequence) response = 'Total length: ' + str(Seq.len(s)) + "\n" + str( Seq.percentages(s)) + '\n' print(response) cs.send(response.encode())
def gene_calculations(info_dict): s = Seq(info_dict['seq']) percentages = Seq.percentages(s) context = { 'id': info_dict['id'], "percentages": percentages, 'length': len(info_dict['seq']) } content = read_template_html_file("./html/gene_calculations.html").render( context=context) return content
def info(sequence): s = Seq(sequence) response = 'Total length: ' + str(Seq.len(s)) + "\r" + str( Seq.percentages(s)) + '\r' return response
'green') endpoint6 = "/geneCalc?gene=FXN" try: conn.request("GET", endpoint6 + PARAM) # send the request except ConnectionRefusedError: print("ERROR! Cannot connect to the Server") exit() calc_response = conn.getresponse() print(f"Response received!: {calc_response.status} {calc_response.reason}\n") calc_dict = json.loads(calc_response.read().decode()) gene3 = endpoint6.split('?')[1].split('=')[1].split('&')[0] gene3_object = Seq(calc_dict['seq']) a_perc, c_perc, g_perc, t_perc = gene3_object.percentages() termcolor.cprint('GENE ', 'magenta', end='') termcolor.cprint(gene3, 'blue') termcolor.cprint('The total length of the gene is: ', 'magenta', end='') termcolor.cprint(gene3_object.len(), 'blue') termcolor.cprint('The percentage of the base "A": ', 'magenta', end='') termcolor.cprint(str(a_perc) + '%', 'blue') termcolor.cprint('The percentage of the base "C": ', 'magenta', end='') termcolor.cprint(str(c_perc) + '%', 'blue') termcolor.cprint('The percentage of the base "G": ', 'magenta', end='') termcolor.cprint(str(g_perc) + '%', 'blue')