A DNA Sequence Alignment/Map (SAM) library for Clojure. [API Reference]
cljam is available as a Maven artifact from Clojars.
To use with Leiningen, add the following dependency.
[cljam "0.1.4"]
To use with Maven, add the following dependency.
<dependency>
<groupId>cljam</groupId>
<artifactId>cljam</artifactId>
<version>0.1.4</version>
</dependency>
To read a SAM/BAM format file,
(require '[cljam.core :refer [reader]]
'[cljam.io :as io])
;; Open a file
(with-open [r (reader "path/to/file.bam")]
;; Retrieve header
(io/read-header r)
;; Retrieve alignments
(doall (take 5 (io/read-alignments r)))
To create a sorted file,
(require '[cljam.core :refer [reader writer]]
'[cljam.sorter :as sorter])
(with-open [r (reader "path/to/file.bam")
w (writer "path/to/sorted.bam")]
;; Sort by chromosomal coordinates
(sorter/sort-by-pos r w))
To create a BAM index file,
(require '[cljam.bam-indexer :as bai])
;; Create a new BAM index file
(bai/create-index "path/to/sorted.bam" "path/to/sorted.bam.bai")
To pileup,
(require '[cljam.core :refer [reader]]
'[cljam.pileup :as plp])
(with-open [r (reader "path/to/sorted.bam" :ignore-index false)]
;; Pileup "chr1" alignments
(take 10 (plp/pileup r "chr1" nil)))
;; => (0 0 1 1 3 3 3 3 2 3)
Check https://chrovis.github.io/cljam for more information.
cljam provides a command-line tool to use the features easily.
Run lein-bin
plugin and it creates standalone console executable into target
directory.
$ lein bin
Created /path/to/cljam/target/cljam-0.1.4.jar
Created /path/to/cljam/target/cljam-0.1.4-standalone.jar
Creating standalone executable: /path/to/cljam/target/cljam
Copy the executable 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 -h
For example, to display contents of a SAM file including the header,
$ cljam view --header path/to/file.sam
To run all basic tests,
$ lein midje
To run heavy tests which uses remote large-size files,
$ lein midje :filter heavy
cljam uses Marginalia for generating documents.
$ lein marg -m
generates HTML documents in docs
directory.
Sorted by first commit.
- Toshiki Takeuchi (@totakke)
- Takashi Aoki (@federkasten)
- Atsuo Yamada (@ayamada)
- Jun Imura (@alumi)
Copyright 2013-2016 Xcoo, Inc.
Licensed under the Apache License, Version 2.0.