Skip to content

Commit 7eceade

Browse files
authored
Update digestR.R
1 parent 75fea53 commit 7eceade

File tree

1 file changed

+15
-36
lines changed

1 file changed

+15
-36
lines changed

R/digestR.R

+15-36
Original file line numberDiff line numberDiff line change
@@ -18989,55 +18989,34 @@ onDisplayGene <- function() {
1898918989
geneLabel <- ttklabel(geneDialog, text = 'Enter the name of the gene you wish to view in detail:')
1899018990
tkgrid(geneLabel, padx = 10, pady = 5)
1899118991

18992+
# Create tclVars for both the entry and dropdown
18993+
geneEntryVar <- tclVar("")
18994+
geneDropdownVar <- tclVar("")
18995+
1899218996
# Entry box for manual gene name input
18993-
geneEntry <- tkentry(geneDialog, width = 30)
18997+
geneEntry <- tkentry(geneDialog, textvariable=geneEntryVar, width = 30)
1899418998
tkgrid(geneEntry, padx = 10, pady = 5)
1899518999

1899619000
# Dropdown (combobox) populated with available gene names from species$genes$name
1899719001
geneNamesList <- species$genes$name # Assuming this is a list of available gene names
1899819002

18999-
### Get Threshold from gene_labeling ###
19000-
if (fileFolder[[currentSpectrum]]$file.par$noise_override != -1) {
19001-
threshold <- fileFolder[[currentSpectrum]]$file.par$noise_override
19002-
} else {
19003-
threshold <- fileFolder[[currentSpectrum]]$file.par$noise_multiplier
19003+
if (length(geneNamesList) == 0) {
19004+
tkmessageBox(message = "No gene names available.", icon = "error")
19005+
tkdestroy(geneDialog)
19006+
return()
1900419007
}
1900519008

19006-
### Filter genes based on the threshold ###
19007-
# Assuming there's a corresponding `species$genes$scores` vector with gene scores
19008-
geneScores <- species$genes$scores # Make sure this vector exists
19009-
filteredGenes <- geneNamesList[geneScores > threshold] # Filter genes above the threshold
19009+
geneDropdown <- ttkcombobox(geneDialog, textvariable=geneDropdownVar, values = geneNamesList, width = 27)
19010+
tkgrid(geneDropdown, padx = 10, pady = 5)
1901019011

19011-
### Add a Listbox to Display Filtered Gene Names ###
19012-
geneListVar <- tclVar()
19013-
tclObj(geneListVar) <- filteredGenes # Populate the listbox with filtered gene names
19014-
19015-
geneListbox <- tklistbox(geneDialog, listvariable = geneListVar, selectmode = "single", width = 30, height = 10)
19016-
tkgrid(geneListbox, padx = 10, pady = 5)
19017-
19018-
# Scrollbar for the listbox
19019-
listScrollbar <- ttkscrollbar(geneDialog, orient = "vertical", command = function(...) tkyview(geneListbox, ...))
19020-
tkconfigure(geneListbox, yscrollcommand = function(...) tkset(listScrollbar, ...))
19021-
tkgrid(listScrollbar, column = 2, row = 4, sticky = "ns")
19022-
1902319012
# Function to handle the 'OK' button click
1902419013
onOK <- function() {
19025-
# Get the gene name from either the entry box, dropdown, or listbox
19026-
geneName <- tclvalue(geneEntry)
19027-
19028-
if (nchar(geneName) == 0) {
19029-
geneName <- tclvalue(geneDropdown) # Fall back to dropdown selection
19030-
}
19031-
19032-
# Get the selected item from the listbox if nothing else is selected
19014+
# Get the gene name from either the entry box or dropdown
19015+
geneName <- tclvalue(geneEntryVar)
1903319016
if (nchar(geneName) == 0) {
19034-
selectedIdx <- as.integer(tkcurselection(geneListbox))
19035-
if (length(selectedIdx) > 0) {
19036-
geneName <- filteredGenes[selectedIdx + 1] # Listbox is 0-indexed
19037-
}
19017+
geneName <- tclvalue(geneDropdownVar) # Fall back to dropdown selection
1903819018
}
1903919019

19040-
# Proceed with analysis
1904119020
if (nchar(geneName) == 0) {
1904219021
# No gene entered or selected, analyze full proteome
1904319022
analyze_genes('')
@@ -19065,8 +19044,8 @@ onDisplayGene <- function() {
1906519044

1906619045
# Keep focus on the dialog
1906719046
tkfocus(geneDialog)
19047+
tcl("update") # Ensure focus and window visibility is updated
1906819048
}
19069-
1907019049
displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
1907119050

1907219051
onDisplayProteome <- function()

0 commit comments

Comments
 (0)