federkasten / cljam

A DNA Sequence Alignment/Map (SAM) library for Clojure

Home Page:https://chrovis.github.io/cljam

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cljam

A DNA Sequence Alignment/Map (SAM) library for Clojure. [API Reference]

Build Status

Dependency Status

Installation

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>

Getting started

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.

Command-line tool

cljam provides a command-line tool to use the features easily.

Executable installation

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.

Usage

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

Development

Test

To run all basic tests,

$ lein midje

To run heavy tests which uses remote large-size files,

$ lein midje :filter heavy

Generating document

cljam uses Marginalia for generating documents.

$ lein marg -m

generates HTML documents in docs directory.

Contributors

Sorted by first commit.

License

Copyright 2013-2016 Xcoo, Inc.

Licensed under the Apache License, Version 2.0.

About

A DNA Sequence Alignment/Map (SAM) library for Clojure

https://chrovis.github.io/cljam

License:Apache License 2.0


Languages

Language:Clojure 100.0%