Skip to content

Commit 30a2249

Browse files
authored
Update digestR.R
1 parent ff4823f commit 30a2249

File tree

1 file changed

+97
-22
lines changed

1 file changed

+97
-22
lines changed

R/digestR.R

+97-22
Original file line numberDiff line numberDiff line change
@@ -18956,29 +18956,104 @@ 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-
print(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+
# print(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)
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:', '')
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+
}
19000+
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")
19010+
19011+
# Fetch the threshold value from the current spectrum
19012+
if (fileFolder[[currentSpectrum]]$file.par$noise_override != -1) {
19013+
threshold <- fileFolder[[currentSpectrum]]$file.par$noise_override
19014+
} else {
19015+
threshold <- fileFolder[[currentSpectrum]]$file.par$noise_multiplier
19016+
}
19017+
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]
19024+
19025+
# Listbox to display the filtered genes
19026+
geneListVar <- tclVar()
19027+
tclObj(geneListVar) <- filteredGenes
19028+
19029+
geneListbox <- tklistbox(geneDialog, listvariable = geneListVar, selectmode = "single", width = 30, height = 10)
19030+
tkgrid(geneListbox, padx = 10, pady = 5)
19031+
19032+
# Add scrollbar for listbox
19033+
listScrollbar <- ttkscrollbar(geneDialog, orient = "vertical", command = function(...) tkyview(geneListbox, ...))
19034+
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)
19043+
}
19044+
tkdestroy(geneDialog) # Close the listbox window
19045+
}
19046+
19047+
# OK and Cancel buttons
19048+
okButton <- ttkbutton(geneDialog, text = 'OK', command = onGeneSelectOK)
19049+
tkgrid(okButton, padx = 10, pady = 10)
19050+
19051+
cancelButton <- ttkbutton(geneDialog, text = 'Cancel', command = function() tkdestroy(geneDialog))
19052+
tkgrid(cancelButton, padx = 10, pady = 10)
19053+
19054+
# Set focus on the listbox window
19055+
tkfocus(geneDialog)
19056+
}
1898219057

1898319058
onDisplayProteome <- function()
1898419059
{

0 commit comments

Comments
 (0)