Repository: chrovis/cljam
Pull request #247 (2021-09-29 09:21:56)

Fix error that occurs when querying intervals for missing chr
When issuing an interval query (using `c.u.i/find-overlap-intervals`) for a missing chr in the index, an error will be thrown:

```clojure
(require '[cljam.util.intervals :as intervals])

(def index
  (intervals/index-intervals
   [{:chr "chr1", :start 10000, :end 15000}
    {:chr "chr1", :start 20000, :end 25000}]))

(intervals/find-overlap-intervals index "chr1" 13000 17000)
;=> ({:chr "chr1", :start 10000, :end 15000})
(intervals/find-overlap-intervals index "chr1" 17000 19000)
;=> ()

(intervals/find-overlap-intervals index "chr2" 13000 17000)
;; Execution error (IllegalArgumentException) at cljam.util.intervals/eval5662$fn$G (intervals.clj:4).
;; No implementation of method: :find-overlap-intervals* of protocol: #'cljam.util.intervals/IIntervals found for class: nil
```

This PR fixes the error by guarding against `nil` with `some->`.


Patch:
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index b93d763..d94b510 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -21,7 +21,7 @@ jobs:
         lein cloverage --codecov
         bash <(curl -s https://codecov.io/bash) -f target/coverage/codecov.json
     - name: Coverage Graph
-      uses: codecov/codecov-action@v2.1.0
+      uses: codecov/codecov-action@v1.5.2
       with:
         token: ${{ secrets.CODECOV_TOKEN }}
         file: ./target/coverage/codecov.json
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 6cc1877..4471795 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -11,7 +11,7 @@ jobs:
       id : master_base_sha
       if : github.ref  == 'refs/heads/master'
       run: echo  "::set-output name=base_sha::${{ github.event.before }}"
-    - uses: xcoo/clj-lint-action@v1.1.10
+    - uses: xcoo/clj-lint-action@v1.1.9
       with:
         linters: "[\"clj-kondo\" \"kibit\" \"eastwood\"]"
         github_token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1c8187f..2e4aca1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,8 +2,6 @@
 
 ## [Unreleased]
 
-## [0.8.1] - 2021-09-28
-
 ### Added
 
 * Add support for fast interval finder. [#209](https://github.com/chrovis/cljam/pull/209)
@@ -21,31 +19,6 @@
 * Bump codecov/codecov-action from v1.0.13 to v1.0.14. [#213](https://github.com/chrovis/cljam/pull/213)
 * Bump codecov/codecov-action from v1.0.14 to v1.0.15. [#214](https://github.com/chrovis/cljam/pull/214)
 * Update java versions for testing. [#215](https://github.com/chrovis/cljam/pull/215)
-* Bump codecov/codecov-action from v1.0.15 to v1.1.0. [#216](https://github.com/chrovis/cljam/pull/216)
-* Bump codecov/codecov-action from v1.1.0 to v1.1.1. [#217](https://github.com/chrovis/cljam/pull/217)
-* Bump codecov/codecov-action from v1.1.1 to v1.2.0. [#218](https://github.com/chrovis/cljam/pull/218)
-* Bump codecov/codecov-action from v1.2.0 to v1.2.1. [#219](https://github.com/chrovis/cljam/pull/219)
-* Bump actions/cache from v2 to v2.1.4. [#220](https://github.com/chrovis/cljam/pull/220)
-* Bump codecov/codecov-action from v1.2.1 to v1.2.2. [#221](https://github.com/chrovis/cljam/pull/221)
-* Bump codecov/codecov-action from v1.2.2 to v1.3.1. [#222](https://github.com/chrovis/cljam/pull/222)
-* Bump codecov/codecov-action from v1.3.1 to v1.3.2. [#225](https://github.com/chrovis/cljam/pull/225)
-* Update actions/setup-java to v2. [#226](https://github.com/chrovis/cljam/pull/226)
-* Bump actions/cache from v2.1.4 to v2.1.5. [#227](https://github.com/chrovis/cljam/pull/227)
-* Bump codecov/codecov-action from v1.3.2 to v1.4.0. [#229](https://github.com/chrovis/cljam/pull/229)
-* Bump codecov/codecov-action from v1.4.0 to v1.4.1. [#230](https://github.com/chrovis/cljam/pull/230)
-* Bump xcoo/clj-lint-action from v1.1.7 to v1.1.8. [#231](https://github.com/chrovis/cljam/pull/231)
-* Bump codecov/codecov-action from v1.4.1 to v1.5.0. [#232](https://github.com/chrovis/cljam/pull/232)
-* Bump actions/checkout from 2 to 2.3.4. [#233](https://github.com/chrovis/cljam/pull/233)
-* Bump actions/cache from 2.1.5 to 2.1.6. [#234](https://github.com/chrovis/cljam/pull/234)
-* Bump xcoo/clj-lint-action from 1.1.8 to 1.1.9. [#235](https://github.com/chrovis/cljam/pull/235)
-* Add explanation to info exception. [#236](https://github.com/chrovis/cljam/pull/236)
-* Bump codecov/codecov-action from 1.5.0 to 1.5.2. [#237](https://github.com/chrovis/cljam/pull/237)
-* Fix bam encoder/decoder to convert sam to bam. [#239](https://github.com/chrovis/cljam/pull/239)
-* Fix parser generation not to interpret unnecessary data when calculat…. [#241](https://github.com/chrovis/cljam/pull/241)
-* Bump codecov/codecov-action from 1.5.2 to 2.0.1. [#242](https://github.com/chrovis/cljam/pull/242)
-* Bump codecov/codecov-action from 2.0.1 to 2.0.2. [#243](https://github.com/chrovis/cljam/pull/243)
-* Bump codecov/codecov-action from 2.0.2 to 2.0.3. [#244](https://github.com/chrovis/cljam/pull/244)
-* Bump codecov/codecov-action from 2.0.3 to 2.1.0. [#245](https://github.com/chrovis/cljam/pull/245)
 
 ## [0.8.0] - 2020-06-22
 
@@ -468,8 +441,7 @@ represents the first three bases of chromosome 1.
 
 First release
 
-[Unreleased]: https://github.com/chrovis/cljam/compare/0.8.1...HEAD
-[0.8.1]: https://github.com/chrovis/cljam/compare/0.8.0...0.8.1
+[Unreleased]: https://github.com/chrovis/cljam/compare/0.8.0...HEAD
 [0.8.0]: https://github.com/chrovis/cljam/compare/0.7.4...0.8.0
 [0.7.4]: https://github.com/chrovis/cljam/compare/0.7.3...0.7.4
 [0.7.3]: https://github.com/chrovis/cljam/compare/0.7.2...0.7.3
diff --git a/README.md b/README.md
index c194048..83a3fe3 100644
--- a/README.md
+++ b/README.md
@@ -15,13 +15,13 @@ cljam is available as a Maven artifact from [Clojars](https://clojars.org/cljam)
 Clojure CLI/deps.edn:
 
 ```clojure
-cljam {:mvn/version "0.8.1"}
+cljam {:mvn/version "0.8.0"}
 ```
 
 Leiningen/Boot:
 
 ```clojure
-[cljam "0.8.1"]
+[cljam "0.8.0"]
 ```
 
 ## Breaking changes in 0.8.0
@@ -160,7 +160,7 @@ Sorted by first commit.
 
 ## License
 
-Copyright 2013-2021 [Xcoo, Inc.](https://xcoo.jp/)
+Copyright 2013-2020 [Xcoo, Inc.](https://xcoo.jp/)
 
 Licensed under the [Apache License, Version 2.0](LICENSE).
 
diff --git a/project.clj b/project.clj
index 2b0454e..6bfe1c5 100644
--- a/project.clj
+++ b/project.clj
@@ -1,23 +1,23 @@
-(defproject cljam "0.8.2-SNAPSHOT"
+(defproject cljam "0.8.1-SNAPSHOT"
   :description "A DNA Sequence Alignment/Map (SAM) library for Clojure"
   :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/core.memoize "1.0.250"]
+  :dependencies [[org.clojure/core.memoize "1.0.236"]
                  [org.clojure/tools.logging "1.1.0"]
-                 [org.clojure/tools.cli "1.0.206"]
-                 [org.apache.commons/commons-compress "1.21"]
+                 [org.clojure/tools.cli "1.0.194"]
+                 [org.apache.commons/commons-compress "1.20"]
                  [clj-sub-command "0.6.0"]
-                 [digest "1.4.10"]
+                 [digest "1.4.9"]
                  [bgzf4j "0.1.0"]
                  [com.climate/claypoole "1.1.4"]
-                 [camel-snake-kebab "0.4.2"]
-                 [proton "0.2.2"]]
-  :profiles {:dev {:dependencies [[org.clojure/clojure "1.10.3"]
+                 [camel-snake-kebab "0.4.1"]
+                 [proton "0.1.8"]]
+  :profiles {:dev {:dependencies [[org.clojure/clojure "1.10.1"]
                                   [cavia "0.5.1"]
                                   [criterium "0.4.6"]
                                   [net.totakke/libra "0.1.1"]
-                                  [se.haleby/stub-http "0.2.10"]]
+                                  [se.haleby/stub-http "0.2.8"]]
                    :plugins [[lein-binplus "0.6.6" :exclusions [org.clojure/clojure]]
                              [lein-codox "0.10.7"]
                              [lein-marginalia "0.9.1" :exclusions [org.clojure/clojure]]
@@ -33,10 +33,10 @@
              :1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}
              :1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}
              :1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]}
-             :1.10 {:dependencies [[org.clojure/clojure "1.10.3"]]}
-             :uberjar {:dependencies [[org.clojure/clojure "1.10.3"]
-                                      [org.apache.logging.log4j/log4j-api "2.14.1"]
-                                      [org.apache.logging.log4j/log4j-core "2.14.1"]]
+             :1.10 {:dependencies [[org.clojure/clojure "1.10.1"]]}
+             :uberjar {:dependencies [[org.clojure/clojure "1.10.1"]
+                                      [org.apache.logging.log4j/log4j-api "2.13.3"]
+                                      [org.apache.logging.log4j/log4j-core "2.13.3"]]
                        :resource-paths ["bin-resources"]
                        :main cljam.tools.main
                        :jvm-opts ["-Dclojure.compiler.direct-linking=true"]
diff --git a/src/cljam/util/intervals.clj b/src/cljam/util/intervals.clj
index 5e60563..6197fe1 100644
--- a/src/cljam/util/intervals.clj
+++ b/src/cljam/util/intervals.clj
@@ -64,4 +64,4 @@
   "Find intervals that are on the given `chr` and overlap the given interval
   [`start` `end`] using indexes created by `index-intervals`."
   [indexed-intervals chr start end]
-  (find-overlap-intervals* (get indexed-intervals chr) start end))
+  (some-> (get indexed-intervals chr) (find-overlap-intervals* start end)))


Test patch:
diff --git a/test/cljam/util/intervals_test.clj b/test/cljam/util/intervals_test.clj
index bf0dc10..bfc6cd0 100644
--- a/test/cljam/util/intervals_test.clj
+++ b/test/cljam/util/intervals_test.clj
@@ -37,5 +37,6 @@
                      "chr2" 201 240 #{{:chr "chr2" :start 150 :end 250}
                                       {:chr "chr2" :start 180 :end 300}
                                       {:chr "chr2" :start 182 :end 201}
-                                      {:chr "chr2" :start 200 :end 400}})))
+                                      {:chr "chr2" :start 200 :end 400}}
+                     "chr3" 1 10 #{})))
                :sorted-map :nclist))