-
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.
Merge pull request #317 from chrovis/feature/cram-index-generation
Support for CRAM index generation
- Loading branch information
Showing
17 changed files
with
669 additions
and
175 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,24 @@ | ||
(ns cljam.algo.cram-indexer | ||
(:require [cljam.io.crai :as crai] | ||
[cljam.io.cram.core :as cram.core] | ||
[cljam.io.cram.reader :as cram.reader] | ||
[cljam.io.sam.util.header :as sam.header])) | ||
|
||
(defn create-index | ||
"Creates a CRAM index file from the given CRAM file. | ||
Takes the following options: | ||
- skip-sort-order-check?: By default, the CRAM indexer checks if the header | ||
is declared as `SO:coordinate` and raises an error if not. | ||
If this option is set to true, the CRAM indexer will skip the header check | ||
and create an index file regardless of the header declaration." | ||
[in-cram out-crai & {:keys [skip-sort-order-check?]}] | ||
(with-open [r (cram.core/reader in-cram {}) | ||
w (crai/writer out-crai)] | ||
(let [header @(.-header r)] | ||
(when (and (not skip-sort-order-check?) | ||
(not= (sam.header/sort-order header) sam.header/order-coordinate)) | ||
(throw | ||
(ex-info "Cannot create CRAM index file for CRAM file not declared as sorted by coordinate" | ||
{:sort-order (sam.header/sort-order header)}))) | ||
(crai/write-index-entries w (cram.reader/generate-index-entries r))))) |
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
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
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
Oops, something went wrong.