Skip to content

Commit

Permalink
Merge pull request #69 from nwamsley1/fix_exponential_search
Browse files Browse the repository at this point in the history
Fix exponential search
  • Loading branch information
nwamsley1 authored Feb 25, 2025
2 parents 0d3dc64 + 7f6a44e commit c37df59
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/Routines/SearchDIA/CommonSearchUtils/queryFragmentIndex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function exponentialFragmentBinSearch(frag_index_bins::AbstractArray{FragIndexBi
frag_mz_min::Float32,
frag_mz_max::Float32,
step_size::UInt32)

#return lower_bound_guess, upper_bound_guess
initial_lower_bound_guess = lower_bound_guess
n = zero(UInt8)
step = one(UInt32)
Expand All @@ -44,26 +44,35 @@ function exponentialFragmentBinSearch(frag_index_bins::AbstractArray{FragIndexBi
upper_bound_guess += step #Exponentially increasing guess
if upper_bound_guess > frag_bin_max_idx #If guess exceeds limits
upper_bound_guess = frag_bin_max_idx #then set to maximum
if (getHigh(frag_index_bins[lower_bound_guess]) < frag_mz_min)
return upper_bound_guess, upper_bound_guess
end

#This was a mistake
#if (getHigh(frag_index_bins[lower_bound_guess]) < frag_mz_min)
# return upper_bound_guess, upper_bound_guess
#end
break
end
n += one(UInt8)
end
#If this condition is met, it is possible for the next observed
#fragment to match to fragment bins below `lower_bound_guess`
#If this is the case, use the original lower bound.
#=
n = one(UInt8)
while (getHigh(frag_index_bins[lower_bound_guess]) > frag_mz_min)
step = step >> one(UInt8)
#if (step === zero(UInt32))# (step > lower_bound_guess) | (step === zero(UInt32))
# if (step > lower_bound_guess)
# return initial_lower_bound_guess, upper_bound_guess
# else
# return lower_bound_guess, upper_bound_guess
# end
#end
if (step > lower_bound_guess) | (step === zero(UInt32))
return initial_lower_bound_guess, upper_bound_guess
end
lower_bound_guess -= step
n += one(UInt8)
end
=#
#println("lower_bound_guess $lower_bound_guess upper_bound_guess $upper_bound_guess")
return lower_bound_guess, upper_bound_guess
end
Expand Down
6 changes: 6 additions & 0 deletions src/structs/LibraryIon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,12 @@ struct BasicLibraryPrecursors
for pid in range(1, n)
pid_to_cv_fold[pid] = pg_to_cv_fold[accession_numbers[pid]]
end
if length(keys(accession_number_to_pgid)) <= 1
@warn "Library did not include protein accession numbers. Seeting cross-validation folds based on precursor_idx"
for pid in range(1, n)
pid_to_cv_fold[pid] = rand(cv_folds)
end
end
new(
precursor_table, n, accession_number_to_pgid, pid_to_cv_fold
)
Expand Down
2 changes: 1 addition & 1 deletion test/UnitTests/queryFragmentIndex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ end
UInt32(2048)#step_si´
)
@test upper_idx == frag_bin_max_idx
@test lower_idx == upper_idx
#@test lower_idx == upper_idx
@test getHigh(test_frag_bins[lower_idx]) < frag_mz_absolute_min
end
##########
Expand Down

0 comments on commit c37df59

Please sign in to comment.