A DNA Sequence Alignment/Map (SAM) library for Clojure. [API Reference] [Annotated Source]
cljam is available as a Maven artifact from Clojars.
Clojure CLI/deps.edn:
cljam {:mvn/version "0.8.5"}Leiningen/Boot:
[cljam "0.8.5"]cljam.io.tabixis rewritten. #180cljam.io.bam-index.writer/pos->lidx-offsetis moved tocljam.io.util.bin/pos->lidx-offset. #180cljam.io.sam.util/reg->binis moved tocljam.io.util.bin/reg->bin. Also, a coordinate system of its argument is changed from 0-based half-open to 1-based fully-closed. #190
To read a SAM/BAM format file,
(require '[cljam.io.sam :as sam])
;; Open a file
(with-open [r (sam/reader "path/to/file.bam")]
;; Retrieve header
(sam/read-header r)
;; Retrieve alignments
(doall (take 5 (sam/read-alignments r))))To create a sorted file,
(require '[cljam.io.sam :as sam]
'[cljam.algo.sorter :as sorter])
(with-open [r (sam/reader "path/to/file.bam")
w (sam/writer "path/to/sorted.bam")]
;; Sort by chromosomal coordinates
(sorter/sort-by-pos r w))To create a BAM index file,
(require '[cljam.algo.bam-indexer :as bai])
;; Create a new BAM index file
(bai/create-index "path/to/sorted.bam" "path/to/sorted.bam.bai")To calculate coverage depth for a BAM file,
(require '[cljam.io.sam :as sam]
'[cljam.algo.depth :as depth])
(with-open [r (sam/reader "path/to/sorted.bam")]
;; Pileup "chr1" alignments
(depth/depth r {:chr "chr1", :start 1, :end 10}))
;;=> (0 0 0 0 0 0 1 1 3 3)If you are Clojure beginner, read Getting Started for Clojure Beginners.
cljam provides a command-line tool to use the features easily.
NOTICE The command-line tool functionality will be removed from cljam on the next release. The functionality has been already integrated into Gnife, which is a pure command-line tool.
lein bin creates standalone console executable into target directory.
$ lein bin
Creating standalone executable: /path/to/cljam/target/cljamCopy the executable cljam somewhere in your $PATH.
All commands are displayed by cljam -h, and detailed help for each command are displayed by cljam [cmd] -h.
$ cljam view -hFor example, to display contents of a SAM file including the header,
$ cljam view --header path/to/file.samSee command-line tool manual for more information.
To run tests,
lein testfor basic tests,lein test :slowfor slow tests with local resources,lein test :remotefor tests with remote resources.
To get coverage
$ lein cloverageAnd open target/coverage/index.html.
cljam uses Codox for API reference and Marginalia for annotated source code.
$ lein docsgenerates these documents in target/docs and target/literate directories.
T. Takeuchi, A. Yamada, T. Aoki, and K. Nishimura. cljam: a library for handling DNA sequence alignment/map (SAM) with parallel processing. Source Code for Biology and Medicine, Vol. 11, No. 1, pp. 1-4, 2016.
Sorted by first commit.
- Toshiki Takeuchi (@totakke)
- Takashi Aoki (@federkasten)
- Atsuo Yamada (@ayamada)
- Jun Imura (@alumi)
- Shogo Ohta (@athos)
- Shunya Kawabata (@r6eve)
- Yuji Ito (@yito88)
- Akira Inoue (@niyarin)
- Atsushi Kitahara (@xckitahara)
- Kei Komazaki (@k-kom)
- Tomoki Matsuda (@matsutomo81)
- Ryutaro Nagata (@nuggetoriniku)
Copyright 2013-2024 Xcoo, Inc.
Licensed under the Apache License, Version 2.0.