Initial commit of MutateX app
Browse files
app.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import random
|
4 |
+
|
5 |
+
# Simulate mutation detection
|
6 |
+
def detect_mutations(dna_sequence):
|
7 |
+
mutations = ["None", "SNV", "Insertion", "Deletion", "Duplication"]
|
8 |
+
return random.choice(mutations), round(random.uniform(0.7, 0.99), 2)
|
9 |
+
|
10 |
+
# Analyze uploaded CSV
|
11 |
+
def analyze_csv(file_path):
|
12 |
+
df = pd.read_csv(file_path.name)
|
13 |
+
results = []
|
14 |
+
|
15 |
+
for _, row in df.iterrows():
|
16 |
+
seq = row['DNA_Sequence']
|
17 |
+
mutation, confidence = detect_mutations(seq)
|
18 |
+
results.append({
|
19 |
+
"Sequence": seq,
|
20 |
+
"Predicted Mutation": mutation,
|
21 |
+
"Confidence Score": confidence
|
22 |
+
})
|
23 |
+
|
24 |
+
result_df = pd.DataFrame(results)
|
25 |
+
return result_df
|
26 |
+
|
27 |
+
# Load example data
|
28 |
+
def load_example():
|
29 |
+
df = pd.DataFrame({
|
30 |
+
"DNA_Sequence": [
|
31 |
+
"AGCTAGCTA",
|
32 |
+
"GATCGATCG",
|
33 |
+
"TTAGCTAGCT",
|
34 |
+
"ATGCGTAGC"
|
35 |
+
]
|
36 |
+
})
|
37 |
+
return df
|
38 |
+
|
39 |
+
# Gradio Interface
|
40 |
+
with gr.Blocks(theme="soft") as demo:
|
41 |
+
gr.Markdown("## 🧬 MutateX – Liquid Biopsy Mutation Detection Tool")
|
42 |
+
gr.Markdown("Upload a CSV file containing DNA sequences to simulate mutation detection.")
|
43 |
+
|
44 |
+
with gr.Row():
|
45 |
+
upload_btn = gr.File(label="Upload CSV File", file_types=[".csv"])
|
46 |
+
example_btn = gr.Button("Load Example Data")
|
47 |
+
|
48 |
+
output_table = gr.DataFrame(label="Analysis Results")
|
49 |
+
|
50 |
+
# Connect buttons to functions
|
51 |
+
upload_btn.upload(fn=analyze_csv, inputs=upload_btn, outputs=output_table)
|
52 |
+
example_btn.click(fn=load_example, outputs=output_table)
|
53 |
+
|
54 |
+
gr.Markdown("### Developed by [GradSyntax](https://www.gradsyntax.com )")
|
55 |
+
|
56 |
+
# Launch app
|
57 |
+
demo.launch()
|