Skip to content

Commit

Permalink
use smallest possible UInt for the path templates to save some space,…
Browse files Browse the repository at this point in the history
… maybe will speed things further
  • Loading branch information
JokingHero committed Apr 9, 2024
1 parent c889090 commit 5787851
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/motif_path_templates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ For example: ACTG and ANNN with restriction to length 2, would result in these s
This length does not includes PAM - it applies directly to the guide seqeunce. The default is full length of the guide and its maximal distance.
"""
struct PathTemplates
paths::Matrix{Int}
distances::Vector{Int}
paths::Matrix{<:Unsigned}
distances::Vector{UInt8}
#len::Int # length without the PAM
#max_distance::Int
mismatch_only::Bool
Expand Down Expand Up @@ -330,13 +330,12 @@ function build_PathTemplates(
paths = CHOPOFF.load(joinpath(dir, "Cas9_d4_p16_paths.bin"))
distances = CHOPOFF.load(joinpath(dir, "Cas9_d4_p16_distances.bin"))
paths = paths[:, 1:restrict_to_len]
paths = Int.(paths)
distances = Int.(distances)
not_dups = map(!, BitVector(nonunique(DataFrame(paths, :auto))))
not_over_dist = BitVector(distances .<= d)
not = not_dups .& not_over_dist
paths = paths[not, :]
distances = distances[not]
paths = convert.(smallestutype(maximum(paths)), paths)
paths = PathTemplates(paths, distances, mismatch_only, motif, withPAM, restrict_to_len)
if storagepath != ""
save(paths, storagepath)
Expand Down Expand Up @@ -396,6 +395,8 @@ function build_PathTemplates(
distances = vcat([repeat([convert(UInt8, i)], paths_lengths[i + 1]) for i in 0:d]...)
distances = distances[not_dups]

paths_expanded = convert.(smallestutype(maximum(paths_expanded)), paths_expanded)
distances = UInt8.(distances)
paths = PathTemplates(paths_expanded, distances, mismatch_only, motif, withPAM, restrict_to_len)
if storagepath != ""
save(paths, storagepath)
Expand Down

0 comments on commit 5787851

Please sign in to comment.