WhyLIM commited on
Commit
0a5c103
1 Parent(s): 083b280

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -49
app.py CHANGED
@@ -10,8 +10,6 @@ def get_SNP():
10
  library(dplyr)
11
  library(data.table)
12
 
13
- setwd("D:/Mli/Project/GWASDB/")
14
-
15
  rm(list = ls())
16
 
17
  AD <- fread("Lambert/IGAP_summary_statistics/IGAP_stage_1.txt", header = TRUE, stringsAsFactors = F)
@@ -71,15 +69,16 @@ def get_SNP_gene(rsidlist):
71
 
72
  return rsid_gene
73
 
74
- def todf():
75
- rsidlist = get_SNP()
76
- rsid_gene = get_SNP_gene(rsidlist)
 
77
 
78
- for key, value in rsid_gene.items():
79
- if value == []:
80
- rsid_gene[key] = ["None"]
81
- df = pd.DataFrame(list(rsid_gene.items()), columns=['rsid', 'genes'])
82
- df['genes'] = df['genes'].apply(lambda x: x[0] if isinstance(x, list) and len(x) > 0 else x)
83
 
84
  return df
85
 
@@ -92,40 +91,6 @@ def visible(identifiers):
92
  visible=True), button_download.update(visible=True)
93
 
94
 
95
- # def download_all(identifiers, species, required_score, network_type):
96
- # # 网络图像
97
- # url1 = f"https://string-db.org/api/image/network?identifiers={identifiers}&species={species}"
98
- # # 相互作用网络文件
99
- # url2 = f"https://string-db.org/api/tsv/network?identifiers={identifiers}&species={species}&required_score={required_score}&network_type={network_type}"
100
- # # 富集分析
101
- # url3 = f"https://string-db.org/api/tsv/enrichment?identifiers={identifiers}&species={species}"
102
-
103
- # # url 列表
104
- # urls = [url1, url2, url3]
105
- # # 定义文件名
106
- # filenames = [
107
- # "network.png", "network_interactions.tsv", "network_enrichment.tsv"
108
- # ]
109
-
110
- # # 创建一个空的zip文件对象
111
- # z = zipfile.ZipFile("cbd_string_analysis.zip", "w")
112
- # for url, filename in zip(urls, filenames):
113
- # r = requests.get(url)
114
- # # 创建一个类似于文件的对象,用于存储内容
115
- # file_obj = io.BytesIO(r.content)
116
- # # 将内容写入zip文件
117
- # z.writestr(filename, file_obj.read())
118
- # # 关闭zip文件对象
119
- # z.close()
120
- # return "cbd_string_analysis.zip"
121
-
122
-
123
- # def download_visible(identifiers, species, required_score, network_type):
124
- # file = download_all(identifiers, species, required_score, network_type)
125
- # if file != None:
126
- # return file_download.update(visible=True)
127
-
128
-
129
  # 使用gr.Blocks()创建和组合组件
130
  with gr.Blocks() as demo:
131
  with gr.Row():
@@ -147,11 +112,6 @@ with gr.Blocks() as demo:
147
 
148
  # 按钮监听
149
  button_input.click(fn=todf, inputs=[disease1, disease2], outputs=rsid_gene_df)
150
- # 显示列表
151
- # button_input.click(
152
- # fn=visible,
153
- # inputs=protein_input,
154
- # outputs=[topo_para, network_stats, enrichment, button_download])
155
 
156
  # 在本地运行demo对象
157
  demo.launch(share=False)
 
10
  library(dplyr)
11
  library(data.table)
12
 
 
 
13
  rm(list = ls())
14
 
15
  AD <- fread("Lambert/IGAP_summary_statistics/IGAP_stage_1.txt", header = TRUE, stringsAsFactors = F)
 
69
 
70
  return rsid_gene
71
 
72
+ def todf(disease1, disease2):
73
+ if disease1 != "" and disease2 != "":
74
+ rsidlist = get_SNP()
75
+ rsid_gene = get_SNP_gene(rsidlist)
76
 
77
+ for key, value in rsid_gene.items():
78
+ if value == []:
79
+ rsid_gene[key] = ["None"]
80
+ df = pd.DataFrame(list(rsid_gene.items()), columns=['rsid', 'genes'])
81
+ df['genes'] = df['genes'].apply(lambda x: x[0] if isinstance(x, list) and len(x) > 0 else x)
82
 
83
  return df
84
 
 
91
  visible=True), button_download.update(visible=True)
92
 
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  # 使用gr.Blocks()创建和组合组件
95
  with gr.Blocks() as demo:
96
  with gr.Row():
 
112
 
113
  # 按钮监听
114
  button_input.click(fn=todf, inputs=[disease1, disease2], outputs=rsid_gene_df)
 
 
 
 
 
115
 
116
  # 在本地运行demo对象
117
  demo.launch(share=False)