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

30
app.jl
View File

@ -80,6 +80,7 @@ rgb_ViridisPalette =reinterpret(ColorTypes.RGB24, ViridisPalette)
end end
@onchange file_name begin @onchange file_name begin
msg = "" msg = ""
try
if contains(file_name,".imzML") if contains(file_name,".imzML")
warning_fr = "" warning_fr = ""
full_route = joinpath( file_route, file_name ) full_route = joinpath( file_route, file_name )
@ -96,7 +97,9 @@ rgb_ViridisPalette =reinterpret(ColorTypes.RGB24, ViridisPalette)
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
if Sys.islinux()
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS 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
@ -104,9 +107,30 @@ rgb_ViridisPalette =reinterpret(ColorTypes.RGB24, ViridisPalette)
else else
warning_fr = "is not an imzML file" warning_fr = "is not an imzML file"
end 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
warning_fr = "Loading plot..."
spectraMz = LoadMzml(full_routeMz)
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 else
full_route = "/" full_route = "/"
warning_fr = "is not an imzML file" warning_fr = "is not an imzML or mzML file"
end
catch e
msg = "There was an error, please verify the file and try again. $(e)"
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
if Sys.islinux()
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS 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,8 +242,10 @@ rgb_ViridisPalette =reinterpret(ColorTypes.RGB24, ViridisPalette)
lastimgTriq = indeximgTriq lastimgTriq = indeximgTriq
end end
GC.gc() # Trigger garbage collection GC.gc() # Trigger garbage collection
if Sys.islinux()
ccall(:malloc_trim, Int32, (Int32,), 0) # Ensure julia returns the freed memory to OS 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
@page("/", "app.jl.html") @page("/", "app.jl.html")