Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 11cd8ee
Showing
5 changed files
with
92 additions
and
0 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,31 @@ | ||
# bio.sam | ||
|
||
Clojure interface to SAM-JDK. Just at proof of concept stage, provides function | ||
to read SAM/BAM files and return lazy-seq of SAMRecord objects. | ||
|
||
## Usage | ||
|
||
(use '[bio.sam.core :only (read-sam)]) | ||
|
||
(def s (read-sam "examples/toy.sam")) | ||
|
||
(map (memfn getReadString) s) | ||
|
||
## Installation | ||
|
||
FIXME: write | ||
|
||
## See also | ||
|
||
http://picard.sourceforge.net/ | ||
|
||
## License | ||
|
||
Copyright (C) 2010, Ray Miller <ray@1729.org.uk>. | ||
|
||
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE | ||
PUBLIC LICENSE, <http://www.eclipse.org/org/documents/epl-v10.php>. | ||
|
||
ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES | ||
RECIPIENT’S ACCEPTANCE OF THIS AGREEMENT. | ||
|
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,7 @@ | ||
@SQ SN:ref LN:45 | ||
r001 163 ref 7 30 8M2I4M1D3M = 37 39 TTAGATAAAGGATACTG * | ||
r002 0 ref 9 30 1S2I6M1P1I4M2I * 0 0 AAAAGATAAGGATAAA * | ||
r003 0 ref 9 30 5H6M * 0 0 AGCTAA * | ||
r004 0 ref 16 30 6M14N1I5M * 0 0 ATAGCTCTCAGC * | ||
r003 16 ref 29 30 6H5M * 0 0 TAGGC * | ||
r001 83 ref 37 30 9M = 7 -39 CAGCGCCAT * |
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,5 @@ | ||
(defproject bio.sam "1.0.0-SNAPSHOT" | ||
:description "FIXME: write" | ||
:dependencies [[org.clojure/clojure "1.2.0-master-SNAPSHOT"] | ||
[org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]] | ||
:dev-dependencies [[swank-clojure "1.2.1"]]) |
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,43 @@ | ||
(ns bio.sam.core | ||
(:use [clojure.contrib.io :only (file)]) | ||
(:import [net.sf.samtools SAMFileReader SAMRecordIterator])) | ||
|
||
(defn read-sam [filename] | ||
"Read file in SAM/BAM format and return a lazy sequence of | ||
SAMRecord objects. Close the file when the last record has | ||
been read" | ||
(let [sam-reader (SAMFileReader. (file filename)) | ||
read-record (fn this [#^SAMRecordIterator it] | ||
(lazy-seq | ||
(if (.hasNext it) | ||
(cons (.next it) (this it)) | ||
(do (.close it) (.close sam-reader)))))] | ||
(read-record (.iterator sam-reader)))) | ||
|
||
(comment | ||
|
||
(def s (read-sam "examples/toy.sam")) | ||
;;=> #'user/s | ||
|
||
(first s) | ||
;;=> #<SAMRecord r001 2/2 17b aligned read.> | ||
|
||
(.getCigarString (first s)) | ||
;;=> "8M2I4M1D3M" | ||
|
||
(map (memfn getCigarString) s) | ||
;;=> ("8M2I4M1D3M" "1S2I6M1P1I4M2I" "5H6M" "6M14N1I5M" "6H5M" "9M") | ||
|
||
(.getReadLength (first s)) | ||
;;=> 17 | ||
|
||
(map (memfn getReadLength) s) | ||
;;=> (17 16 6 12 5 9) | ||
|
||
(map (memfn getReadString) s) | ||
;;=> ("TTAGATAAAGGATACTG" "AAAAGATAAGGATAAA" "AGCTAA" "ATAGCTCTCAGC" "TAGGC" "CAGCGCCAT") | ||
|
||
;; See <http://picard.sourceforge.net/javadoc/net/sf/samtools/SAMRecord.html> | ||
;; for other methods supported by SAMRecord | ||
|
||
) |
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,6 @@ | ||
(ns bio.sam.core-test | ||
(:use [bio.sam.core] :reload-all) | ||
(:use [clojure.test])) | ||
|
||
(deftest replace-me ;; FIXME: write | ||
(is false)) |