@@ -18980,87 +18980,100 @@ ps <- function(dispPane='co'){
18980
18980
# }
18981
18981
# displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
18982
18982
18983
- onDisplayGene <- function()
18984
- {
18985
- # Existing modal dialog for gene name entry
18986
- geneName <- modalDialog(dlg, ' Gene Name Entry', 'Enter the name of the gene you wish to view in detail:', '' )
18983
+ onDisplayGene <- function() {
18984
+ # Generate a temporary dialog window
18985
+ geneDialog <- tktoplevel()
18986
+ tkwm.title(geneDialog, " Gene Name Entry" )
18987
18987
18988
- if(geneName == 'ID_CANCEL') {
18989
- return()
18990
- } else {
18991
- if(nchar(geneName) == 0) {
18992
- analyze_genes('')
18993
- }
18994
- else if(geneName %in% species$genes$name) {
18995
- analyze_genes(geneName)
18996
- } else {
18997
- log_message(paste0(geneName, ' is not a valid gene of ', species$name))
18998
- }
18999
- }
18988
+ # Instruction label
18989
+ geneLabel <- ttklabel(geneDialog, text = 'Enter the name of the gene you wish to view in detail:')
18990
+ tkgrid(geneLabel, padx = 10, pady = 5)
19000
18991
19001
- # Add the Listbox for Genes Above Threshold
19002
- addGeneListboxAboveThreshold()
19003
- }
19004
-
19005
- # Function to add listbox for genes above threshold
19006
- addGeneListboxAboveThreshold <- function() {
19007
- # Create a new window for displaying the filtered gene list
19008
- geneDialog <- tktoplevel()
19009
- tkwm.title(geneDialog, "Filtered Genes Above Threshold")
18992
+ # Entry box for manual gene name input
18993
+ geneEntry <- tkentry(geneDialog, width = 30)
18994
+ tkgrid(geneEntry, padx = 10, pady = 5)
19010
18995
19011
- # Fetch the threshold value from the current spectrum
18996
+ # Dropdown (combobox) populated with available gene names from species$genes$name
18997
+ geneNamesList <- species$genes$name # Assuming this is a list of available gene names
18998
+
18999
+ ### Get Threshold from gene_labeling ###
19012
19000
if (fileFolder[[currentSpectrum]]$file.par$noise_override != -1) {
19013
19001
threshold <- fileFolder[[currentSpectrum]]$file.par$noise_override
19014
19002
} else {
19015
19003
threshold <- fileFolder[[currentSpectrum]]$file.par$noise_multiplier
19016
19004
}
19017
19005
19018
- # Assuming there is a corresponding scores vector in species$genes$scores
19019
- geneScores <- species$genes$scores
19020
- geneNamesList <- species$genes$name
19021
-
19022
- # Filter genes based on the threshold
19023
- filteredGenes <- geneNamesList[geneScores > threshold]
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
19024
19010
19025
- # Listbox to display the filtered genes
19011
+ ### Add a Listbox to Display Filtered Gene Names ###
19026
19012
geneListVar <- tclVar()
19027
- tclObj(geneListVar) <- filteredGenes
19013
+ tclObj(geneListVar) <- filteredGenes # Populate the listbox with filtered gene names
19028
19014
19029
19015
geneListbox <- tklistbox(geneDialog, listvariable = geneListVar, selectmode = "single", width = 30, height = 10)
19030
19016
tkgrid(geneListbox, padx = 10, pady = 5)
19031
19017
19032
- # Add scrollbar for listbox
19018
+ # Scrollbar for the listbox
19033
19019
listScrollbar <- ttkscrollbar(geneDialog, orient = "vertical", command = function(...) tkyview(geneListbox, ...))
19034
19020
tkconfigure(geneListbox, yscrollcommand = function(...) tkset(listScrollbar, ...))
19035
- tkgrid(listScrollbar, column = 2, row = 1, sticky = "ns")
19036
-
19037
- # OK button to confirm gene selection from listbox
19038
- onGeneSelectOK <- function() {
19039
- selectedIdx <- as.integer(tkcurselection(geneListbox))
19040
- if (length(selectedIdx) > 0) {
19041
- selectedGene <- filteredGenes[selectedIdx + 1] # Get selected gene name
19042
- analyze_genes(selectedGene)
19021
+ tkgrid(listScrollbar, column = 2, row = 4, sticky = "ns")
19022
+
19023
+ # Function to handle the 'OK' button click
19024
+ 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
19033
+ 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
+ }
19038
+ }
19039
+
19040
+ # Proceed with analysis
19041
+ if (nchar(geneName) == 0) {
19042
+ # No gene entered or selected, analyze full proteome
19043
+ analyze_genes('')
19044
+ } else if (geneName %in% species$genes$name) {
19045
+ # Valid gene name, analyze the selected gene
19046
+ analyze_genes(geneName)
19047
+ } else {
19048
+ # Invalid gene name, display error message
19049
+ log_message(paste0(geneName, ' is not a valid gene of ', species$name))
19043
19050
}
19044
- tkdestroy(geneDialog) # Close the listbox window
19051
+
19052
+ tkdestroy(geneDialog) # Close the dialog box
19045
19053
}
19046
19054
19047
- # OK and Cancel buttons
19048
- okButton <- ttkbutton(geneDialog, text = 'OK', command = onGeneSelectOK )
19055
+ # OK button
19056
+ okButton <- ttkbutton(geneDialog, text = 'OK', command = onOK )
19049
19057
tkgrid(okButton, padx = 10, pady = 10)
19050
19058
19051
- cancelButton <- ttkbutton(geneDialog, text = 'Cancel', command = function() tkdestroy(geneDialog))
19059
+ # Cancel button
19060
+ onCancel <- function() {
19061
+ tkdestroy(geneDialog) # Close the dialog box without action
19062
+ }
19063
+ cancelButton <- ttkbutton(geneDialog, text = 'Cancel', command = onCancel)
19052
19064
tkgrid(cancelButton, padx = 10, pady = 10)
19053
19065
19054
- # Set focus on the listbox window
19066
+ # Keep focus on the dialog
19055
19067
tkfocus(geneDialog)
19056
19068
}
19069
+
19057
19070
displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
19058
-
19059
- onDisplayProteome <- function()
19060
- {
19061
- analyze_genes('')
19062
- }
19063
- displayGenomeButton <- ttkbutton(genePlotTypeFrame, text='Display Full Proteome', width=21, command=onDisplayProteome)
19071
+
19072
+ onDisplayProteome <- function()
19073
+ {
19074
+ analyze_genes('')
19075
+ }
19076
+ displayGenomeButton <- ttkbutton(genePlotTypeFrame, text='Display Full Proteome', width=21, command=onDisplayProteome)
19064
19077
19065
19078
19066
19079
# onDisplayGene <- function() {
0 commit comments