Skip to content

Commit

Permalink
Corrected template creation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dancelestini committed Mar 17, 2023
1 parent 7bc1cab commit 45a1161
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Conditions_info.csv
Exp_info.csv
Trials_info.csv
Exp_info.csv
Template_184s.osf
4 changes: 2 additions & 2 deletions Exp_info.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,Trial 1,Trial 2,Trial 3,Trial 4,Trial 5,Trial 6,Trial 7,Trial 8,Remarks Cond 1,Remarks Cond 2,Remarks Cond 3
1_03172023,3,DmOR1_OR22ab_Boosted Gal4_Knockin_GCaMP7f_F_M_3,DmOR1_OR42b_Gal4_Knockin_GCaMP7f_F_M_3,DmOR1_OR42b_Gal4_Knockin_GCaMP7f_F_M_3,NA,6,4,water 1,"(4R,5R)-5-(1,2-dihydroxyethyl)-3,4-dihydroxy-2-oxolanone_e3",water 2,"(4R,5R)-5-(1,2-dihydroxyethyl)-3,4-dihydroxy-2-oxolanone_e3_2",water 3,"(4R,5R)-5-(1,2-dihydroxyethyl)-3,4-dihydroxy-2-oxolanone_e3_3",water 4,"(4R,5R)-5-(1,2-dihydroxyethyl)-3,4-dihydroxy-2-oxolanone_e3_4",,,
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_/
79 changes: 26 additions & 53 deletions Lumar_GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ def create_CSV(self):
transgene_name += "_"
else:
### special get for textinput ###
toappend = globals()[f"{self.widgetsName[(((i-1)*self.NumColCondFrame)+col)]}"].get("1.0", "end-1c")
self.row.append(str(toappend))
remarks = globals()[f"{self.widgetsName[(((i-1)*self.NumColCondFrame)+col)]}"].get("1.0", "end-1c")
continue
### Others ###

toappend = globals()[f"{self.widgetsName[(((i-1)*self.NumColCondFrame)+col)]}"].get()
self.row.append(str(toappend))

self.row.append(str(transgene_name))
self.row.append(str(remarks))
self.rows.append(self.row)

### write the Trials_info.csv file ###
Expand All @@ -275,6 +275,7 @@ def create_CSV(self):
diff_odors = []
id_repeat = dict()
self.rows = []
list_vials = []

### if no water in between odors ###
if(self.OdorantIB.get() == "None"):
Expand Down Expand Up @@ -308,7 +309,13 @@ def create_CSV(self):
odor = odor + "_" + str(id_repeat[odor])

self.row.append(odor)
self.row.append(dilution)
self.row.append(dilution)

### List_vials for the template ###
vial_number = int(globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+5)]}"].get())
list_vials.append(vial_number)

### append the complete line ###
self.rows.append(self.row)

### if water in between odors ###
Expand Down Expand Up @@ -341,11 +348,18 @@ def create_CSV(self):

self.row.append(odor)
self.row.append(dilution)

### List_vials for the template ###
vial_number = int(globals()[f"{self.widgetsNameOD[int(((id-1)*self.NumColODFrame)+5)]}"].get())
list_vials.append(vial_number)
else:
water_name = "Water "+ str((int(i/2)+1))
self.row.append(water_name)
self.row.append(0)



### append the complete line ###
self.rows.append(self.row)

### write the Trials_info.csv file ###
Expand All @@ -355,10 +369,10 @@ def create_CSV(self):
for i in self.rows:
writer.writerow(i)


### Exp_info.csv creation ###
### Create the header ###
self.header = ["Exp_id", "Conditions", "Condition 1", "Condition 2",
"Condition 3", "Condition4", "Antennas", "Odorant Trials"]
"Condition 3", "Condition4", "Antennas", "Odorant Trials","Remarks"]

if(self.OdorantIB.get() == "None"):
for i in range(int(self.OdorantNum.get())+1):
Expand Down Expand Up @@ -401,62 +415,21 @@ def create_CSV(self):
### Odorants ###
self.row.append(self.OdorantNum.get())

### EachTrial ###
IBOD_name = ["%s %d" % (self.OdorantIB.get(), id)
for id in range(1, (int(self.OdorantNum.get())+1))]
list_vials = []
id_repeat = dict()

if(self.OdorantIB.get() == "None"):
# if we don't have in between selected we put first odor as water then nothing
self.row.append("Water 1")
for i in range(1, (int(self.OdorantNum.get())+1)):
text = str(globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+1)]}"].get()) + "_e" + \
str(globals()[
f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+3)]}"].get())
if text in self.row:
if text not in id_repeat.keys():
id_repeat[text] = 2
else:
id_repeat[text] = id_repeat[text]+1

text = text + "_" + str(id_repeat[text])
self.row.append(text)
vial_number = int(
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
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" + \
str(globals()[
f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+3)]}"].get())

if text in self.row:
if text not in id_repeat.keys():
id_repeat[text] = 2
else:
id_repeat[text] = id_repeat[text]+1

text = text + "_" + str(id_repeat[text])
self.row.append(textASDAS)
vial_number = int(
globals()[f"{self.widgetsNameOD[int(((i-1)*self.NumColODFrame)+5)]}"].get())
list_vials.append(vial_number)
list_vials.append(1)

### Remarks ###
remark = ""
for i in range(1, (int(self.CondNum.get())+1)):
remark = globals()[
remark += "cond_"+str(i)+"_"
remark += globals()[
f"{self.widgetsName[((i*self.NumColCondFrame)-1)]}"].get("1.0", "end-1c")
self.row.append(remark)
remark += "/"
self.row.append(remark)

with open("C:/Users/irlab/gh-repos/Lumar_GUI/Lumar_GUI/Exp_info.csv", "w", encoding='UTF8', newline='') as self.f:
writer = csv.writer(self.f, dialect='excel', delimiter=',')
writer.writerow(self.header)
writer.writerow(self.row)

### Vial numbers for creating the template ###
self.createTemplate(list_vials)

self.close(self.master)
Expand Down
8 changes: 0 additions & 8 deletions Template_184s.osf
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@ No Vial 30 1000
2 60 1000
2 60 1000
No Vial 30 1000
1 30 1000
1 60 1000
1 60 1000
No Vial 30 1000
3 30 1000
3 60 1000
3 60 1000
No Vial 30 1000
1 30 1000
1 60 1000
1 60 1000
No Vial 30 1000

0 comments on commit 45a1161

Please sign in to comment.