-
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.
Add support for generating CSI that can be read by htslib
- Loading branch information
Showing
8 changed files
with
113 additions
and
26 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 |
---|---|---|
@@ -1,12 +1,21 @@ | ||
(ns cljam.algo.vcf-indexer | ||
"Indexer of VCF." | ||
(:require [cljam.io.csi :as csi] | ||
[cljam.io.vcf :as vcf])) | ||
[cljam.io.vcf :as vcf]) | ||
(:import cljam.io.vcf.reader.VCFReader)) | ||
|
||
(defn create-index | ||
"Creates a CSI index file from the VCF file." | ||
[in-bgzipped-vcf out-csi {:keys [shift depth] :or {shift 14 depth 5}}] | ||
(with-open [r (vcf/reader in-bgzipped-vcf)] | ||
(let [offsets (vcf/read-file-offsets r) | ||
csi (csi/offsets->index offsets shift depth)] | ||
|
||
names (->> (map :chr-name offsets) | ||
(concat (->> (.meta-info ^VCFReader r) | ||
:contig | ||
(mapv :id))) | ||
distinct) | ||
csi (csi/offsets->index offsets shift depth | ||
{:variant-file-type :VCF | ||
:names names})] | ||
(csi/write-index out-csi csi)))) |
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
Binary file not shown.
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