Skip to content

Commit

Permalink
Corrected predefined selection
Browse files Browse the repository at this point in the history
  • Loading branch information
dancelestini committed May 16, 2023
1 parent c3714d5 commit 361e07b
Show file tree
Hide file tree
Showing 7 changed files with 1,089 additions and 23 deletions.
11 changes: 11 additions & 0 deletions Data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,14 @@ AgOR4,,,,
AgOR10,,,,
AgOR35,,,,
HarmOR12,,,,
DmOR59b,,,,
AmOR34,,,,
DmOR10a,,,,
HmOR42,,,,
HmOR42_125C,,,,
RnOR7,,,,
DmOR7a,,,,
DmOR43a,,,,
DmOR43b,,,,
AgOR2,,,,
DmOR9test,,,,
4 changes: 2 additions & 2 deletions Exp_Infos.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Exp_id,Conditions,Condition 1,Condition 2,Condition 3,Condition4,Antennas,Odorant Trials,Remarks,Trial 1,Trial 2,Trial 3,Trial 4,Remarks Cond 1
1_03172023,1,DmOR1_OR22ab_Boosted Gal4_Knockin_GCaMP7f_F_M_3,NA,NA,NA,6,2,cond_1_/
Exp_id,Conditions,Condition 1,Condition 2,Condition 3,Condition4,Antennas,Odorant Trials,Trial 1,Trial 2,Trial 3,Trial 4,Trial 5,Trial 6,Trial 7,Remarks
1_04032023,3,Endogenous_ORCO_Transgene_Gal4_GCaMP7f_F_M_3,DmOR7a_ORCO_Transgene_Gal4_GCaMP7f_F_M_3,DmOR43b_ORCO_Transgene_Gal4_GCaMP7f_F_M_3,NA,6,7,water 1,Benzaldehyde_e3,water 2,1-Octen-3-OL_e3,water 3, Apple Juice_e3,water 4,cond_1_/cond_2_/cond_3_/
34 changes: 18 additions & 16 deletions Lumar_GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def create_CSV(self):
self.rows.append(self.row)

### write the Trials_info.csv file ###
with open("C:/Users/irlab/gh-repos/Lumar_GUI/Lumar_GUI/Conditions_info.csv", "w", encoding='UTF8', newline='') as self.f:
with open("C:/Users/irlab/Desktop/Lumar_GUI/Conditions_info.csv", "w", encoding='UTF8', newline='') as self.f:
writer = csv.writer(self.f, dialect='excel', delimiter=',')
writer.writerow(self.header)
for i in self.rows:
Expand All @@ -289,7 +289,7 @@ def create_CSV(self):
### if no water in between odors ###
if(self.OdorantIB.get() == "None"):

for i in range(1, (int(self.OdorantNum.get())+2)):
for i in range(1, (int(self.OdorantNum.get())+1)):
self.row = []

### exp_id ###
Expand All @@ -306,18 +306,20 @@ def create_CSV(self):
self.row.append(0)
else:
odor = str(
globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+1)]}"].get())
globals()[f"{self.widgetsNameOD[int(((i-2)*self.NumColODFrame)+1)]}"].get())
dilution = str(
globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+3)]}"].get())
globals()[f"{self.widgetsNameOD[int(((i-2)*self.NumColODFrame)+3)]}"].get())
if odor in diff_odors:
if odor not in id_repeat.keys():
id_repeat[odor] = 2
else:
id_repeat[odor] = id_repeat[odor]+1

odor = odor + "_" + str(id_repeat[odor])
else:
diff_odors.append(odor)

odor = odor + "_" + str(id_repeat[odor])


self.row.append(odor)
self.row.append(dilution)
Expand Down Expand Up @@ -376,7 +378,7 @@ def create_CSV(self):
self.rows.append(self.row)

### write the Trials_info.csv file ###
with open("C:/Users/irlab/gh-repos/Lumar_GUI/Lumar_GUI/Trials_info.csv", "w", encoding='UTF8', newline='') as self.f:
with open("C:/Users/irlab/Desktop/Lumar_GUI/Trials_info.csv", "w", encoding='UTF8', newline='') as self.f:
writer = csv.writer(self.f, dialect='excel', delimiter=',')
writer.writerow(self.header)
for i in self.rows:
Expand Down Expand Up @@ -428,7 +430,7 @@ def create_CSV(self):

### Odorants ###
if self.OdorantIB.get() == "None":
self.row.append(int(self.OdorantNum.get()+1))
self.row.append(int(self.OdorantNum.get())+1)
else:
self.row.append((int(self.OdorantNum.get())*2+1))

Expand All @@ -455,7 +457,7 @@ def create_CSV(self):
globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+5)]}"].get())
list_vials.append(vial_number)
else:
# if we do have an ib between odorant just intercal it between testing odors
# if we do have an in between odorant just intercal it between testing odors
for i in range(1, (int(self.OdorantNum.get())+1)):
self.row.append(IBOD_name[(i-1)])
text = globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+1)]}"].get() + "_e" + \
Expand All @@ -473,8 +475,8 @@ def create_CSV(self):
list_vials.append(vial_number)
list_vials.append(1)

last_water = IBOD_name[(len(IBOD_name)-1)]
self.row.append(last_water)
last_water = IBOD_name[(len(IBOD_name)-1)]
self.row.append(last_water)

### Remarks ###
remark = ""
Expand All @@ -485,7 +487,7 @@ def create_CSV(self):
remark += "/"
self.row.append(remark)

with open("C:/Users/irlab/gh-repos/Lumar_GUI/Lumar_GUI/Exp_Infos.csv", "w", encoding='UTF8', newline='') as self.f:
with open("C:/Users/irlab/Desktop/Lumar_GUI/Exp_Infos.csv", "w", encoding='UTF8', newline='') as self.f:
writer = csv.writer(self.f, dialect='excel', delimiter=',')
writer.writerow(self.header)
writer.writerow(self.row)
Expand Down Expand Up @@ -791,7 +793,7 @@ def drawConditions(self):
self.FirstKIKO = StringVar()
self.widgetsName = ["self.widget_%d_%d" % (x, j) for x in range(
1, (int(self.CondNum.get())+1)) for j in range(self.NumColCondFrame)]

for i in range(int(self.CondNum.get())):
self.frames.append(
Frame(self.ScrollFrame, borderwidth=1, relief="solid", height=300))
Expand Down Expand Up @@ -871,27 +873,27 @@ def drawConditions(self):

id_widgets = 0
listtoappend = []
predefined_selections = [0,5,2,1]
for x in self.widgetsName[(i*self.NumColCondFrame):((i+1)*self.NumColCondFrame)]:
globals()[f"{x}"] = widgetsList[id_widgets]

print(globals()[f"{x}"])
if re.search("combobox", str(globals()[f"{x}"])):
if re.search("!combobox4", str(globals()[f"{x}"])):
# select day of emergence as 3
globals()[f"{x}"].current(2)
elif (x == self.widgetsName[2]) | (x == self.widgetsName[4]) | (x == self.widgetsName[6]) | (x == self.widgetsName[8]):
# If first condition we add this function to autofill
print(str(globals()[f"{x}"]))
globals()[f"{x}"].set_completion_list(
(globals()[f"{x}"]["values"]))
globals()[f"{x}"].focus_set()
globals()[f"{x}"].bind(
"<<ComboboxSelected>>", self.callback)
globals()[f"{x}"].current(0)
globals()[f"{x}"].current(predefined_selections[int((id_widgets/2)-1)])
elif re.search("autocomplete", str(globals()[f"{x}"])):
globals()[f"{x}"].set_completion_list(
(globals()[f"{x}"]["values"]))
globals()[f"{x}"].focus_set()
globals()[f"{x}"].current(0)
globals()[f"{x}"].current(predefined_selections[int((id_widgets/2)-1)])
else:
globals()[f"{x}"].current(0)

Expand Down
Loading

0 comments on commit 361e07b

Please sign in to comment.