KeXing
commited on
Upload app.py
Browse files
app.py
CHANGED
@@ -37,9 +37,9 @@ def func(name):
|
|
37 |
|
38 |
|
39 |
def func_mult(name):
|
40 |
-
sequence_list = name
|
41 |
-
sequence_list = [s.strip() for s in sequence_list]
|
42 |
-
sequence_list = [x for x in sequence_list if x] # 列表推导式
|
43 |
output=[]
|
44 |
for i in range(0, len(sequence_list), 1):
|
45 |
output.append(func(sequence_list[i]))
|
@@ -47,6 +47,14 @@ def func_mult(name):
|
|
47 |
return result
|
48 |
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
def read_fasta_file(file_path):
|
51 |
sequences = []
|
52 |
for seq_record in SeqIO.parse(file_path, "fasta"):
|
@@ -109,7 +117,7 @@ with gr.Blocks(css=css, title="GH29 Prediction", theme=gr.themes.Soft()) as demo
|
|
109 |
upload_button = gr.UploadButton("Click to Upload a File", file_types=["fasta"], scale=2, size="sm", file_count="multiple")
|
110 |
upload_button.upload(upload_file, upload_button, file_upload)
|
111 |
file_button = gr.Button("Predict", scale=3, size="lg", elem_classes="button")
|
112 |
-
file_button_GenerateFile = gr.Button("Save to
|
113 |
|
114 |
single_button.click(func, inputs=single_input, outputs=single_output)
|
115 |
multiple_button.click(func_mult, inputs=multiple_input, outputs=multiple_output)
|
|
|
37 |
|
38 |
|
39 |
def func_mult(name):
|
40 |
+
sequence_list = process_fasta(name)
|
41 |
+
#sequence_list = [s.strip() for s in sequence_list]
|
42 |
+
#sequence_list = [x for x in sequence_list if x] # 列表推导式
|
43 |
output=[]
|
44 |
for i in range(0, len(sequence_list), 1):
|
45 |
output.append(func(sequence_list[i]))
|
|
|
47 |
return result
|
48 |
|
49 |
|
50 |
+
def process_fasta(fasta_content):
|
51 |
+
sequences = []
|
52 |
+
fasta_file = io.StringIO(fasta_content)
|
53 |
+
for record in SeqIO.parse(fasta_file, "fasta"):
|
54 |
+
sequences.append(str(record.seq))
|
55 |
+
return sequences
|
56 |
+
|
57 |
+
|
58 |
def read_fasta_file(file_path):
|
59 |
sequences = []
|
60 |
for seq_record in SeqIO.parse(file_path, "fasta"):
|
|
|
117 |
upload_button = gr.UploadButton("Click to Upload a File", file_types=["fasta"], scale=2, size="sm", file_count="multiple")
|
118 |
upload_button.upload(upload_file, upload_button, file_upload)
|
119 |
file_button = gr.Button("Predict", scale=3, size="lg", elem_classes="button")
|
120 |
+
file_button_GenerateFile = gr.Button("Save to File", scale=2, size="sm")
|
121 |
|
122 |
single_button.click(func, inputs=single_input, outputs=single_output)
|
123 |
multiple_button.click(func_mult, inputs=multiple_input, outputs=multiple_output)
|