Testing condition to avoid errors in macOS

This commit is contained in:
José Julián Sierra Álvarez 2024-10-12 11:18:22 -06:00 committed by GitHub
parent faca7c82cb
commit 72cb64e731
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

60
app.jl
View File

@ -80,33 +80,57 @@ rgb_ViridisPalette =reinterpret(ColorTypes.RGB24, ViridisPalette)
end end
@onchange file_name begin @onchange file_name begin
msg = "" msg = ""
if contains(file_name,".imzML") try
warning_fr = "" if contains(file_name,".imzML")
full_route = joinpath( file_route, file_name ) warning_fr = ""
if isfile(full_route) # check if the file exists full_route = joinpath( file_route, file_name )
full_routeMz = split( full_route, "." )[1] * ".mzML" # Splitting the route from imzml to mzml so the plotting can work if isfile(full_route) # check if the file exists
if isfile(full_routeMz) && (full_routeMz2 == "" || full_routeMz2 != full_routeMz) # check if there is an mzML file around full_routeMz = split( full_route, "." )[1] * ".mzML" # Splitting the route from imzml to mzml so the plotting can work
if isfile(full_routeMz) && (full_routeMz2 == "" || full_routeMz2 != full_routeMz) # check if there is an mzML file around
Disab_btn = true
warning_fr = "Loading plot..."
spectraMz = LoadMzml(full_routeMz)
# dims = size(spectraMz)
# scansMax = dims[2] # we get the total of scansMax
# traceSpectra = PlotlyBase.scatter(x = spectraMz[1, 1], y = spectraMz[2, 1], mode="lines")
traceSpectra = PlotlyBase.scatter(x = mean(spectraMz[1,:]), y = mean(spectraMz[2,:]), mode="lines")
plotdata = [traceSpectra] # we add the data of spectra to the plot
spectraMz = nothing # Important for memory cleaning
GC.gc() # Trigger garbage collection
if Sys.islinux()
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS
end
warning_fr = "Plot loaded."
Disab_btn = false
full_routeMz2 = full_routeMz # to avoid creating the plot if its the same file read as before
end
else
warning_fr = "is not an imzML file"
end
elseif contains(file_name,".mzML")
full_routeMz = joinpath( file_route, file_name )
warning_fr = "$(full_routeMz)"
if isfile(full_routeMz) && (full_routeMz2 == "" || full_routeMz2 != full_routeMz) # check if there is an mzML file around # check if the file exists
Disab_btn = true Disab_btn = true
warning_fr = "Loading plot..." warning_fr = "Loading plot..."
spectraMz = LoadMzml(full_routeMz) spectraMz = LoadMzml(full_routeMz)
# dims = size(spectraMz)
# scansMax = dims[2] # we get the total of scansMax
# traceSpectra = PlotlyBase.scatter(x = spectraMz[1, 1], y = spectraMz[2, 1], mode="lines")
traceSpectra = PlotlyBase.scatter(x = mean(spectraMz[1,:]), y = mean(spectraMz[2,:]), mode="lines") traceSpectra = PlotlyBase.scatter(x = mean(spectraMz[1,:]), y = mean(spectraMz[2,:]), mode="lines")
plotdata = [traceSpectra] # we add the data of spectra to the plot plotdata = [traceSpectra] # we add the data of spectra to the plot
spectraMz = nothing # Important for memory cleaning spectraMz = nothing # Important for memory cleaning
GC.gc() # Trigger garbage collection GC.gc() # Trigger garbage collection
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS if Sys.islinux()
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS
end
warning_fr = "Plot loaded." warning_fr = "Plot loaded."
Disab_btn = false Disab_btn = false
full_routeMz2 = full_routeMz # to avoid creating the plot if its the same file read as before full_routeMz2 = full_routeMz # to avoid creating the plot if its the same file read as before
end end
else else
warning_fr = "is not an imzML file" full_route = "/"
warning_fr = "is not an imzML or mzML file"
end end
else catch e
full_route = "/" msg = "There was an error, please verify the file and try again. $(e)"
warning_fr = "is not an imzML file"
end end
end end
@onchange Nmass begin @onchange Nmass begin
@ -159,7 +183,9 @@ rgb_ViridisPalette =reinterpret(ColorTypes.RGB24, ViridisPalette)
spectra = nothing # Important for memory cleaning spectra = nothing # Important for memory cleaning
slice = nothing slice = nothing
GC.gc() # Trigger garbage collection GC.gc() # Trigger garbage collection
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS if Sys.islinux()
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS
end
Disab_btn = false Disab_btn = false
end end
@onbutton ImgMinus begin @onbutton ImgMinus begin
@ -216,7 +242,9 @@ rgb_ViridisPalette =reinterpret(ColorTypes.RGB24, ViridisPalette)
lastimgTriq = indeximgTriq lastimgTriq = indeximgTriq
end end
GC.gc() # Trigger garbage collection GC.gc() # Trigger garbage collection
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS if Sys.islinux()
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS
end
end end
# == Pages == # == Pages ==
# register a new route and the page that will be loaded on access # register a new route and the page that will be loaded on access