Spaces:
Runtime error
Runtime error
File size: 1,363 Bytes
5260972 a0a14d0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# Solution
import gradio as gr
def calculate_GC(DNA):
n_G = DNA.count('G')
n_C = DNA.count('C')
n_A = DNA.count('A')
n_T = DNA.count('T')
GC_content = (n_G+n_C)/(n_G+n_C+n_A+n_T) * 100
total_count = n_G+n_C+n_A+n_T
return total_count,n_A, n_T, n_G, n_C, GC_content
## configure inputs/outputs
input_module = gr.inputs.Textbox(label = "Enter your DNA sequence in the box:")
set_out1 = gr.outputs.Textbox(label = "Total count, all bases:")
set_out2 = gr.outputs.Textbox(label = "Adenine (A) count:")
set_out3 = gr.outputs.Textbox(label = "Thymine (T) count:")
set_out4 = gr.outputs.Textbox(label = "Guanine (G) count:")
set_out5 = gr.outputs.Textbox(label = "Cytosine (C) count:")
set_out6 = gr.outputs.Textbox(label = "%G~C content:")
### configure gradio, detailed can be found at https://www.gradio.app/docs/#i_slider
interface = gr.Interface(fn=calculate_GC,
inputs=input_module,
outputs=[set_out1,set_out2,set_out3,set_out4,set_out5,set_out6],
title="CSCI1020 Demo 1: Web Application for Genomics %G~C Content Calculator",
description= "Click examples below for a quick demo",
theme = 'huggingface',
layout = 'vertical'
)
interface.launch() |