Giter Site home page Giter Site logo

bio.io.vcf's Introduction

bio.io.vcf

A Clojure library designed for reading VCF (Variant Call Format) data, as defined by the 1000 Genomes Project:

http://www.1000genomes.org/wiki/Analysis/Variant%20Call%20Format/vcf-variant-call-format-version-41

Installing

Available from Clojars

Leiningen

[org.bioclojure/bio.io.vcf "0.1.0-SNAPSHOT"]

Maven

<dependency>
  <groupId>org.bioclojure</groupId>
  <artifactId>bio.io.vcf</artifactId>
  <version>0.1.0-SNAPSHOT</version>
</dependency>

Usage

Load the reader:

(require '[org.bioclojure.bio.io.vcf.reader :as vcf])

vcf-reader

The main entry point is the vcf-reader function. This takes a VCF as its only argument, which can be anything understood by clojure.java.io/input-stream (string, File, URI, ...). A Gzip-compressed input stream will be detected and automatically decompressed.

vcf-reader should be called inside of with-open to ensure the underlying input stream is closed.

(with-open [v (vcf/vcf-reader (io/resource "sample.vcf"))]
   (doall (vcf/variant-seq v)))

(with-open [v (vcf/vcf-reader "ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/release/20110521/ALL.chr1.phase1_release_v3.20101123.snps_indels_svs.genotypes.vcf.gz")] 
   (first (vcf/variant-seq v)))

header

Returns the requested header from a vcf:

(vcf/header v "INFO" "H2")
;; => {:id "H2", :number 0, :type "Flag", :description "HapMap2 membership"}

sample-ids

Returns the list of sample ids from the VCF.

(vcf/sample-ids v)
;; => ("NA00001" "NA00002" "NA00003")

variant-seq

Returns a lazy sequence of variants from the VCF.

(first (vcf/variant-seq v))
;; => {:chr "20",
;;     :info {"NS" 3, "DP" 14, "AF" [0.5], "DB" true, "H2" true},
;;     :alt ["A"],
;;     :ref "G",
;;     :filter ["PASS"],
;;     :pos 14370,
;;     :gtype
;;       {"NA00003" {"GT" "1/1", "GQ" 43, "DP" 5, "HQ" [nil nil]},
;;        "NA00002" {"GT" "1|0", "GQ" 48, "DP" 8, "HQ" [51 51]},
;;        "NA00001" {"GT" "0|0", "GQ" 48, "DP" 1, "HQ" [51 51]}},
;;     :qual 29,
;;     :id ["rs6054257"]}

pass?

Utility function for filtering PASSed variants in the VCF.

(with-open [v (vcf/vcf-reader (io/resource "example.vcf"))]
    (doall (filter vcf/pass? (vcf/variant-seq v))))

License

Copyright © 2013 Ray Miller [email protected]

Distributed under the Eclipse Public License, the same as Clojure.

bio.io.vcf's People

Contributors

ray1729 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.