Skip to content

Commit 75c3aa8

Browse files
authored
Update digestR.R
1 parent fc62ea1 commit 75c3aa8

File tree

1 file changed

+22
-101
lines changed

1 file changed

+22
-101
lines changed

R/digestR.R

+22-101
Original file line numberDiff line numberDiff line change
@@ -18956,29 +18956,29 @@ ps <- function(dispPane='co'){
1895618956
}
1895718957
applyButton <- ttkbutton(genePlotTypeFrame, text='Apply', width=11, command=onApply)
1895818958

18959-
# onDisplayGene <- function()
18960-
# {
18961-
# geneName <- modalDialog(dlg, 'Gene Name Entry', 'Enter the name of the gene you wish to view in detail:', '')
18962-
# if(geneName == 'ID_CANCEL')
18963-
# {
18964-
# return()
18965-
# }else
18966-
# {
18967-
# if(nchar(geneName) == 0)
18968-
# {
18969-
# analyze_genes('')
18970-
# }
18971-
# else if(geneName %in% species$genes$name)
18972-
# {
18973-
# analyze_genes(geneName)
18974-
# }else
18975-
# {
18976-
# log_message(paste0(geneName, ' is not a valid gene of ', species$name))
18977-
# }
18978-
# }
18959+
onDisplayGene <- function()
18960+
{
18961+
geneName <- modalDialog(dlg, 'Gene Name Entry', 'Enter the name of the gene you wish to view in detail:', '')
18962+
if(geneName == 'ID_CANCEL')
18963+
{
18964+
return()
18965+
}else
18966+
{
18967+
if(nchar(geneName) == 0)
18968+
{
18969+
analyze_genes('')
18970+
}
18971+
else if(geneName %in% species$genes$name)
18972+
{
18973+
analyze_genes(geneName)
18974+
}else
18975+
{
18976+
log_message(paste0(geneName, ' is not a valid gene of ', species$name))
18977+
}
18978+
}
1897918979

18980-
# }
18981-
# displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
18980+
}
18981+
displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
1898218982

1898318983
# onDisplayGene <- function() {
1898418984
# # Generate a temporary dialog window
@@ -19036,85 +19036,6 @@ ps <- function(dispPane='co'){
1903619036
# }
1903719037
# displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
1903819038

19039-
onDisplayGene <- function() {
19040-
# Generate a temporary dialog window
19041-
geneDialog <- tktoplevel()
19042-
tkwm.title(geneDialog, "Gene Name Entry")
19043-
19044-
# Instruction label
19045-
geneLabel <- ttklabel(geneDialog, text = 'Enter the name of the gene you wish to view in detail:')
19046-
tkgrid(geneLabel, padx = 10, pady = 5)
19047-
19048-
# Entry box for manual gene name input
19049-
geneEntry <- tkentry(geneDialog, width = 30)
19050-
tkgrid(geneEntry, padx = 10, pady = 5)
19051-
19052-
# Dropdown (combobox) populated with available gene names from species$genes$name
19053-
geneNamesList <- species$genes$name # Assuming this is a list of available gene names
19054-
geneDropdown <- ttkcombobox(geneDialog, values = geneNamesList, width = 27)
19055-
tkgrid(geneDropdown, padx = 10, pady = 5)
19056-
19057-
### Add a Listbox to Display Gene Names ###
19058-
geneListVar <- tclVar()
19059-
tclObj(geneListVar) <- geneNamesList # Populate the listbox with gene names
19060-
19061-
geneListbox <- tklistbox(geneDialog, listvariable = geneListVar, selectmode = "single", width = 30, height = 10)
19062-
tkgrid(geneListbox, padx = 10, pady = 5)
19063-
19064-
# Scrollbar for the listbox
19065-
listScrollbar <- ttkscrollbar(geneDialog, orient = "vertical", command = function(...) tkyview(geneListbox, ...))
19066-
tkconfigure(geneListbox, yscrollcommand = function(...) tkset(listScrollbar, ...))
19067-
tkgrid(listScrollbar, column = 2, row = 4, sticky = "ns")
19068-
19069-
# Function to handle the 'OK' button click
19070-
onOK <- function() {
19071-
# Get the gene name from either the entry box, dropdown, or listbox
19072-
geneName <- tclvalue(geneEntry)
19073-
19074-
if (nchar(geneName) == 0) {
19075-
geneName <- tclvalue(geneDropdown) # Fall back to dropdown selection
19076-
}
19077-
19078-
# Get the selected item from the listbox if nothing else is selected
19079-
if (nchar(geneName) == 0) {
19080-
selectedIdx <- as.integer(tkcurselection(geneListbox))
19081-
if (length(selectedIdx) > 0) {
19082-
geneName <- geneNamesList[selectedIdx + 1] # Listbox is 0-indexed
19083-
}
19084-
}
19085-
19086-
# Proceed with analysis
19087-
if (nchar(geneName) == 0) {
19088-
# No gene entered or selected, analyze full proteome
19089-
analyze_genes('')
19090-
} else if (geneName %in% species$genes$name) {
19091-
# Valid gene name, analyze the selected gene
19092-
analyze_genes(geneName)
19093-
} else {
19094-
# Invalid gene name, display error message
19095-
log_message(paste0(geneName, ' is not a valid gene of ', species$name))
19096-
}
19097-
19098-
tkdestroy(geneDialog) # Close the dialog box
19099-
}
19100-
19101-
# OK button
19102-
okButton <- ttkbutton(geneDialog, text = 'OK', command = onOK)
19103-
tkgrid(okButton, padx = 10, pady = 10)
19104-
19105-
# Cancel button
19106-
onCancel <- function() {
19107-
tkdestroy(geneDialog) # Close the dialog box without action
19108-
}
19109-
cancelButton <- ttkbutton(geneDialog, text = 'Cancel', command = onCancel)
19110-
tkgrid(cancelButton, padx = 10, pady = 10)
19111-
19112-
# Keep focus on the dialog
19113-
tkfocus(geneDialog)
19114-
}
19115-
19116-
displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
19117-
1911819039
onDisplayProteome <- function()
1911919040
{
1912019041
analyze_genes('')

0 commit comments

Comments
 (0)