KashyapiNagaHarshitha commited on
Commit
2fbc541
·
verified ·
1 Parent(s): dc81614

Delete Setup.py

Browse files
Files changed (1) hide show
  1. Setup.py +0 -196
Setup.py DELETED
@@ -1,196 +0,0 @@
1
- #!/usr/bin/env python
2
- # coding: utf-8
3
- import panel as pn
4
- import os
5
- import pandas as pd
6
- import json
7
- pn.extension()
8
-
9
- # Global variables to store the input values
10
- input_path = ""
11
- set_path = ""
12
- ls_samples = []
13
- metadata_files = []
14
- selected_metadata_files = []
15
-
16
- # Define a callback to store values when the button is clicked
17
- def store_values(event):
18
- global input_path, set_path, ls_samples, metadata_files
19
- input_path = file_input.value
20
- set_path = set_name.value
21
-
22
- # Update the global variables
23
- global base_dir, input_data_dir, output_data_dir, output_images_dir, metadata_dir, metadata_images_dir
24
- present_dir = os.path.dirname(os.path.realpath(__file__))
25
- input_path = os.path.join(present_dir, input_path)
26
- base_dir = input_path
27
- project_name = set_path
28
- step_suffix = 'qc_eda'
29
- previous_step_suffix_long = ""
30
-
31
- input_data_dir = os.path.join(base_dir, project_name + "_data")
32
- output_data_dir = os.path.join(base_dir, project_name + "_" + step_suffix)
33
- output_images_dir = os.path.join(output_data_dir, "images")
34
- metadata_dir = os.path.join(base_dir, project_name + "_metadata")
35
- metadata_images_dir = os.path.join(metadata_dir, "images")
36
-
37
- # Create directories if they don't already exist
38
- for d in [base_dir, input_data_dir, output_data_dir, output_images_dir, metadata_dir, metadata_images_dir]:
39
- if not os.path.exists(d):
40
- print(f"Creation of the {d} directory...")
41
- os.makedirs(d)
42
- else:
43
- print(f"The {d} directory already exists!")
44
-
45
- os.chdir(input_data_dir)
46
-
47
- # Create a DataFrame with the directory paths
48
- data = {
49
- 'Directory': ['Base Directory', 'Input Data Directory', 'Output Data Directory', 'Output Images Directory', 'Metadata Directory', 'Metadata Images Directory'],
50
- 'Path': [base_dir, input_data_dir, output_data_dir, output_images_dir, metadata_dir, metadata_images_dir]
51
- }
52
- df = pd.DataFrame(data)
53
-
54
- # List CSV files in the input_data_dir
55
- ls_samples = [sample for sample in os.listdir(input_data_dir) if sample.endswith(".csv")]
56
- print(f"The following CSV files were detected:\n\n{ls_samples}\n\nin {input_data_dir} directory.")
57
-
58
- # List CSV files in the metadata_dir
59
- metadata_files = [file for file in os.listdir(metadata_dir) if file.endswith(".tif.csv")]
60
- print(f"The following metadata CSV files were detected:\n\n{metadata_files}\n\nin {metadata_dir} directory.")
61
-
62
- # Update the CheckBoxGroup options
63
- checkbox_group.options = ls_samples
64
- metadata_checkbox_group.options = metadata_files
65
-
66
- # Create a DataFrame with the CSV files
67
- csv_files = pd.DataFrame({'CSV Files': ls_samples})
68
- metadata_files_df = pd.DataFrame({'Metadata Files': metadata_files})
69
-
70
- # Update the output panes
71
- output_pane_1.object = f"**File Path:** {input_path}\n\n**Set Name:** {set_path}"
72
- output_pane_2.object = df.to_html(index=False)
73
- output_pane_3.object = csv_files.to_html(index=False)
74
- output_pane_4.object = metadata_files_df.to_html(index=False)
75
-
76
- # Define a callback to save the selected CSV files when the button is clicked
77
- def save_selected_files(event):
78
- # Store the variables in a JSON file
79
- with open('stored_variables.json', 'w') as file:
80
- json.dump({'base_dir': base_dir, 'set_path': set_path}, file)
81
-
82
- # Define a callback to update the ls_samples list based on the selected options
83
- def update_ls_samples(event):
84
- global ls_samples
85
- ls_samples = event.new
86
-
87
- # Define a callback to update the metadata_files list based on the selected options
88
- def update_metadata_files(event):
89
- global metadata_files, selected_metadata_files
90
- metadata_files = event.new
91
- selected_metadata_files = event.new
92
-
93
- # Define a callback to save the selected metadata files when the button is clicked
94
- def save_selected_metadata_files(event):
95
- with open('stored_variables.json', 'w') as file:
96
- json.dump({'selected_metadata_files': selected_metadata_files}, file)
97
-
98
- # Define the widgets
99
- file_input = pn.widgets.TextInput(
100
- name="File Path",
101
- placeholder="Enter the path to your directory"
102
- )
103
-
104
- # Define the set name
105
- set_name = pn.widgets.TextInput(
106
- name="Set Name",
107
- placeholder="Enter the Set"
108
- )
109
-
110
- # Button to trigger storing values
111
- store_button = pn.widgets.Button(name='Store Values')
112
- store_button.on_click(store_values)
113
-
114
- # CheckBoxGroup to select CSV files
115
- checkbox_group = pn.widgets.CheckBoxGroup(name='Select CSV Files', options=[], value=[])
116
- checkbox_group.param.watch(update_ls_samples, 'value')
117
-
118
- # CheckBoxGroup to select metadata files
119
- metadata_checkbox_group = pn.widgets.CheckBoxGroup(name='Select Metadata Files', options=[], value=[])
120
- metadata_checkbox_group.param.watch(update_metadata_files, 'value')
121
-
122
- # Button to save selected CSV files
123
- save_button = pn.widgets.Button(name='Save Files')
124
- save_button.on_click(save_selected_files)
125
-
126
- # Button to save selected metadata files
127
- save_metadata_button = pn.widgets.Button(name='Save Metadata Files')
128
- save_metadata_button.on_click(save_selected_metadata_files)
129
-
130
- output_pane_1 = pn.pane.Markdown("")
131
- output_pane_2 = pn.pane.HTML("")
132
- output_pane_3 = pn.pane.HTML("")
133
- output_pane_4 = pn.pane.HTML("")
134
-
135
- # Create the cards
136
- card_1 = pn.Card(
137
- pn.Column(
138
- pn.pane.Markdown("### Input Form"),
139
- file_input,
140
- set_name,
141
- store_button,
142
- output_pane_1,
143
- sizing_mode="stretch_width"
144
- ),
145
- title="Input Form",
146
- sizing_mode="stretch_width"
147
- )
148
-
149
- card_2 = pn.Card(
150
- pn.Column(
151
- pn.pane.Markdown("### Directory Paths"),
152
- output_pane_2,
153
- sizing_mode="stretch_width"
154
- ),
155
- title="Directory Paths",
156
- sizing_mode="stretch_width"
157
- )
158
-
159
- card_3 = pn.Card(
160
- pn.Column(
161
- pn.pane.Markdown("### CSV Files"),
162
- output_pane_3,
163
- pn.pane.Markdown("### Selection of CSV files for the further analysis"),
164
- checkbox_group,
165
- save_button,
166
- sizing_mode="stretch_width"
167
- ),
168
- title="CSV Files",
169
- sizing_mode="stretch_width"
170
- )
171
-
172
- card_4 = pn.Card(
173
- pn.Column(
174
- pn.pane.Markdown("### Metadata Files"),
175
- output_pane_4,
176
- pn.pane.Markdown("### Selection of Metadata Files"),
177
- metadata_checkbox_group,
178
- save_metadata_button,
179
- sizing_mode="stretch_width"
180
- ),
181
- title="Metadata Files",
182
- sizing_mode="stretch_width"
183
- )
184
-
185
- # Create the main column with the cards
186
- main_column = pn.Column(card_1, card_2, card_3, card_4)
187
-
188
- # Create the GoldenTemplate with the main column
189
- app = pn.template.GoldenTemplate(
190
- site="Cyc-IF",
191
- title="Setup",
192
- main=[main_column],
193
- header_color="black",
194
- )
195
-
196
- app.servable()