-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
106 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
(ns cljam.io.cram | ||
{:clj-kondo/ignore [:missing-docstring]} | ||
(:require [cljam.io.cram.reader :as reader] | ||
[cljam.io.protocols :as protocols] | ||
[cljam.io.sequence :as cseq] | ||
[cljam.io.util.byte-buffer :as bb] | ||
[cljam.util :as util] | ||
[clojure.java.io :as cio]) | ||
(:import [cljam.io.cram.reader CRAMReader] | ||
[java.nio.channels FileChannel] | ||
[java.nio.file OpenOption StandardOpenOption])) | ||
|
||
(defn reader | ||
(^CRAMReader [f] (reader f {})) | ||
(^CRAMReader [f {:keys [reference]}] | ||
(let [file (cio/file f) | ||
url (util/as-url (.getAbsolutePath file)) | ||
ch (FileChannel/open (.toPath file) | ||
(into-array OpenOption [StandardOpenOption/READ])) | ||
bb (bb/allocate-lsb-byte-buffer 256) | ||
seq-rdr (some-> reference cseq/reader) | ||
header (volatile! nil) | ||
refs (delay | ||
(mapv (fn [{:keys [SN LN]}] {:name SN :len LN}) | ||
(:SQ @header))) | ||
rdr (reader/->CRAMReader url ch bb header refs seq-rdr)] | ||
(reader/read-file-definition rdr) | ||
(vreset! header (reader/read-header rdr)) | ||
rdr))) | ||
|
||
(defn read-header [rdr] | ||
(protocols/read-header rdr)) | ||
|
||
(defn read-refs [rdr] | ||
(protocols/read-refs rdr)) | ||
|
||
(defn read-alignments [rdr] | ||
(protocols/read-alignments rdr)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters