Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #9 from JacksonBurns/dev
Browse files Browse the repository at this point in the history
Added option to keep retention times when peak picking
  • Loading branch information
JacksonBurns authored Jul 31, 2020
2 parents 87ce741 + 9f33693 commit 791f28e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions Crow_GC/Pull_GC.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def pulldatacallback():
# after passing all validation, continue to remainder of method.
# iterate through each and pull relevant data
self.datalist = C.np.empty( # empty array the size of len(datafile) x number of products
[len(C.globals_GC.datafiles), len(self.rettimes)], dtype=object
[len(C.globals_GC.datafiles)-1, len(self.rettimes)], dtype=object
)
# iterate through each data test
for file in C.globals_GC.datafiles:
Expand Down Expand Up @@ -102,23 +102,44 @@ def pulldatacallback():
for suspect in peaksinwindow:
if suspect[2] == i:
poss.append(suspect[0:2])
if len(poss) == 1: # only one possible peak was found
keep = poss[0][1]
if len(poss) == 0:
keep = "Not found"
elif len(poss) == 1: # only one possible peak was found
if self.retinclude.get():
keep = poss[0]
else:
keep = poss[0][1]
elif (
self.pickingmethod.get() == 1
): # pick peak closest to the center of the window
possrettimes = [j[0] for j in poss]
possareas = [j[1] for j in poss]
keep = possareas[possrettimes.index(min(possrettimes, key=lambda x: abs(x-self.rettimes[i])))]
if self.retinclude.get():
keep = poss[possrettimes.index(min(possrettimes, key=lambda x: abs(x-self.rettimes[i])))]
else:
keep = possareas[possrettimes.index(min(possrettimes, key=lambda x: abs(x-self.rettimes[i])))]
elif (
self.pickingmethod.get() == 2
): # keep max, just pick max area
keep = max([j[1] for j in poss])
if self.retinclude.get():
keep = max(poss, key=lambda x: x[1])
else:
keep = max([j[1] for j in poss])
elif self.pickingmethod.get() == 3: # keep all areas
keep = [j[1] for j in poss]
if self.retinclude.get():
keep = poss
else:
keep = [j[1] for j in poss]
else:
keep = "Not found"
keep = "Error"
self.datalist[int(temp[C.globals_GC.welltarg[0]][C.globals_GC.welltarg[1]].text)-1, i] = str(keep).replace("\"", "").replace("]", "").replace("[", "")
except IndexError as ie:
if C.globals_GC.debug:
C.globals_GC.mylog(e)
warningmessage = (
"Please select files in order starting from 1 to end"
)
C.messagebox.showwarning(title="Warning", message=warningmessage)
except Exception as e:
if C.globals_GC.debug:
C.globals_GC.mylog(e)
Expand All @@ -129,6 +150,11 @@ def pulldatacallback():
)
C.messagebox.showwarning(title="Warning", message=warningmessage)
with open(C.globals_GC.exportdatapath + self.expname.get() + ".csv", "w") as file:
# write header
for i in range(len(self.rettimes)):
file.write("eluate "+str(i+1)+"\t")
file.write("\n")
# write all lines to a file in a tab separated value format
for row in self.datalist:
for entry in row:
file.write(entry+"\t")
Expand Down Expand Up @@ -156,6 +182,17 @@ def pulldatacallback():
yiterator += 30
# set max as default selection
self.pickingmethod.set(2)
# set up chechbox for whether or not to include retention times
self.retinclude = C.tk.IntVar()
C.tk.Checkbutton(
self,
text='Include retention times?',
variable=self.retinclude,
onvalue=1,
offvalue=0).place(
x=280,
y=415)

# clear entries button
C.tk.Button(self, text="Clear Entries", command=clearentriescallback).place(
x=167, y=245
Expand Down
Binary file removed helper_functions/__pycache__/ParseXML.cpython-38.pyc
Binary file not shown.
Binary file not shown.

0 comments on commit 791f28e

Please sign in to comment.