Spaces:
Sleeping
Sleeping
Commit
•
4dad5f5
1
Parent(s):
911a3ef
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def find_complimentary_dna(dna_to_compliemnt):
|
4 |
+
_complement_seq = ''
|
5 |
+
|
6 |
+
for pos in range(0,len(dna_to_compliemnt)):
|
7 |
+
_last_char = dna_to_compliemnt[len(dna_to_compliemnt)-pos-1]
|
8 |
+
|
9 |
+
if _last_char == 'A':
|
10 |
+
_complement_seq = _complement_seq + 'A'
|
11 |
+
elif _last_char == 'T':
|
12 |
+
_complement_seq = _complement_seq + 'U'
|
13 |
+
elif _last_char == 'G':
|
14 |
+
_complement_seq = _complement_seq + 'G'
|
15 |
+
elif _last_char == 'C':
|
16 |
+
_complement_seq = _complement_seq + 'C'
|
17 |
+
|
18 |
+
return _complement_seq
|
19 |
+
|
20 |
+
def get_protein_from_DNA(DNA):
|
21 |
+
reading_frames =transcribe(DNA)
|
22 |
+
orf_list = []
|
23 |
+
|
24 |
+
for i in range(len(reading_frames)):
|
25 |
+
mRNA = reading_frames[i]
|
26 |
+
one_letter=''
|
27 |
+
found_start = False
|
28 |
+
for codon in mRNA:
|
29 |
+
if codon =='AUG' and not found_start:
|
30 |
+
one_letter += '<'
|
31 |
+
found_start = True
|
32 |
+
if codon =='UAA' or codon=='UGA'or codon =='UAG':
|
33 |
+
if found_start:
|
34 |
+
one_letter += '>'
|
35 |
+
found_start = False
|
36 |
+
continue
|
37 |
+
one_letter += AA_mapping[translate[codon]]
|
38 |
+
|
39 |
+
# mark the valid orf found
|
40 |
+
if one_letter.find('M') != -1:
|
41 |
+
one_letter = '*' + one_letter + '>'
|
42 |
+
orf_list.append(one_letter)
|
43 |
+
|
44 |
+
r = " * means the ORF sequence exists and highlighted in as <>; \n5'to 3' Frame 1:"+ orf_list[0] +"\n5'to 3' Frame 2:" + orf_list[1] + "\n5'to 3' Frame 3:" + orf_list[2] + "\n3'to 5' Frame 1:" + orf_list[3] + "\n3'to 5' Frame 2:" + orf_list[4] + "\n3'to 5' Frame 3:"+orf_list[5]
|
45 |
+
return DNA, find_complimentary_dna(DNA), r
|
46 |
+
|
47 |
+
input1 = gr.inputs.Textbox(label = 'DNA sequence')
|
48 |
+
output1 = gr.outputs.Textbox(label = 'Primary Sequence')
|
49 |
+
output2 = gr.outputs.Textbox(label = 'Complimentary Sequence')
|
50 |
+
output3 = gr.outputs.Textbox(label = 'Open Reading Frames')
|
51 |
+
|
52 |
+
interface = gr.Interface(fn=get_protein_from_DNA,
|
53 |
+
inputs=input1,
|
54 |
+
outputs=[output1,output2,output3],
|
55 |
+
title="CSCI1020: Web Application for Transcription/Translation",
|
56 |
+
description= "A quick tool for translating a DNA sequence into a protein sequence",
|
57 |
+
theme = 'huggingface',
|
58 |
+
layout = 'vertical'
|
59 |
+
)
|
60 |
+
interface.launch()
|