diff --git a/project.clj b/project.clj index 025cc47a..7722537d 100644 --- a/project.clj +++ b/project.clj @@ -3,7 +3,8 @@ :url "https://github.com/chrovis/cljam" :license {:name "Apache License, Version 2.0" :url "https://www.apache.org/licenses/LICENSE-2.0"} - :dependencies [[org.clojure/tools.logging "0.5.0"] + :dependencies [[org.clojure/core.memoize "0.8.2"] + [org.clojure/tools.logging "0.5.0"] [org.clojure/tools.cli "0.4.2"] [org.apache.commons/commons-compress "1.19"] [clj-sub-command "0.5.1"] diff --git a/src/cljam/io/sam/util/cigar.clj b/src/cljam/io/sam/util/cigar.clj index 05f57f00..2e608bfe 100644 --- a/src/cljam/io/sam/util/cigar.clj +++ b/src/cljam/io/sam/util/cigar.clj @@ -1,5 +1,7 @@ (ns cljam.io.sam.util.cigar "Parser of CIGAR strings." + (:require [clojure.core.memoize :as memoize] + [proton.core :as proton]) (:import [java.nio ByteBuffer ByteOrder])) (defn parse @@ -45,7 +47,10 @@ #{\I} (recur xs r (+ s l) (update-last! idx (fn [x] [:i x [s (+ l s)]])))) (persistent! idx))))) -(def to-index (memoize to-index*)) +(def to-index + (memoize/lu to-index* :lu/threshold + (or (proton/as-int (System/getProperty "cljam.sam.cigar.cache-size")) + 1024))) (defn count-op "Returns length of CIGAR operations."