Permalink
Browse files

Initial check-in of JEnsembl wrapper

  • Loading branch information...
1 parent 1715360 commit 7d21fa1472ad0766da127746e501edcc4e88f471 @ray1729 committed Oct 3, 2012
Showing with 101 additions and 25 deletions.
  1. +7 −4 .gitignore
  2. +0 −21 README
  3. +31 −0 README.md
  4. +7 −0 project.clj
  5. +15 −0 src/ensembl/config.clj
  6. +35 −0 src/ensembl/core.clj
  7. +6 −0 test/ensembl/test/core.clj
View
@@ -1,5 +1,8 @@
-pom.xml
+/pom.xml
*jar
-lib
-classes
-*~
+/lib
+/classes
+/native
+/.lein-failures
+/checkouts
+/.lein-deps-sum
View
@@ -1,21 +0,0 @@
-# bio.ensembl
-
-This is the very experimental beginnings of a Clojure API for
-accessing Ensembl databases. There is a long way to go before this
-will be useful to anyone.
-
-See also <http://www.ensembl.org/info/docs/api/core/index.html>.
-
-## Usage
-
-FIXME: write
-
-## Installation
-
-FIXME: write
-
-## License
-
-Copyright (C) 2011 Ray Miller <ray@1729.org.uk>
-
-Distributed under the Eclipse Public License, the same as Clojure.
View
@@ -0,0 +1,31 @@
+# ensembl
+
+An experimental Clojure API wrapping the excellent Java Ensembl
+library JEnsembl, <http://jensembl.sourceforge.net/>.
+
+This is *alpha* software: it is incomplete and the API is subject to
+change.
+
+Please drop me a line if you would like to help with this effort or
+have suggestions for how the API should shape up.
+
+## Usage
+
+ (use 'ensembl.core)
+
+ (def ensreg (registry :ensembldb))
+
+ (def human (species "human" :registry ensreg)
+
+or
+
+ (with-registry ensreg
+ (def human (species "human")))
+
+ (list-chromosomes human)
+
+## License
+
+Copyright (C) 2012 Ray Miller <ray@1729.org.uk>.
+
+Distributed under the Eclipse Public License, the same as Clojure.
View
@@ -0,0 +1,7 @@
+(defproject ensembl "1.0.0-SNAPSHOT"
+ :description "FIXME: write description"
+ :dependencies [[org.clojure/clojure "1.4.0"]
+ [uk.ac.roslin/ensembl-data-access "1.13"]
+ [uk.ac.roslin/ensembl-config "1.68"]]
+ :repositories [["jensembl" {:url "http://jensembl.sourceforge.net/m2-repo" :checksum :ignore :snapshots false }]
+ ["biojava" {:url "http://www.biojava.org/download/maven/" :checksum :ignore :snapshots false }]])
@@ -0,0 +1,15 @@
+(ns ensembl.config)
+
+(defn assembly-exception-type
+ [t]
+ (uk.ac.roslin.ensembl.config.AssemblyExceptionType/getType
+ (.toUpperCase (name t))))
+
+(defn data-source
+ [ds]
+ (uk.ac.roslin.ensembl.config.DBConnection$DataSource/valueOf
+ (.toUpperCase (name ds))))
+
+(defn ensembl-db-type
+ [t]
+ (uk.ac.roslin.ensembl.config.EnsemblDBType/getDBTypeForName (name t)))
View
@@ -0,0 +1,35 @@
+(ns ensembl.core
+ (:use [ensembl.config :only (data-source)])
+ (:import [uk.ac.roslin.ensembl.dao.database DBRegistry]))
+
+(def ^:dynamic *registry* nil)
+(def ^:dynamic *species* nil)
+
+(defmacro with-registry
+ [registry & body]
+ `(binding [*registry* ~registry] ~@body))
+
+(defmacro with-species
+ [species & body]
+ `(binding [*species* ~species] ~@body))
+
+(defn registry
+ [ds]
+ (DBRegistry. (data-source ds)))
+
+(defn list-species
+ [& {:keys [registry] :or {registry *registry*}}]
+ (map (memfn getDatabaseStyleName) (.getSpecies registry)))
+
+(defn species
+ [s & {:keys [registry] :or {registry *registry*}}]
+ (or (.getSpeciesByEnsemblName registry (name s))
+ (.getSpeciesByAlias registry (name s))))
+
+(defn list-chromosomes
+ [s]
+ (map key (.getChromosomes s)))
+
+(defn chromosome
+ [n & {:keys [species] :or {species *species*}}]
+ (.getChromosomeByName (ensembl.core/species species) n))
@@ -0,0 +1,6 @@
+(ns ensembl.test.core
+ (:use [ensembl.core])
+ (:use [clojure.test]))
+
+(deftest replace-me ;; FIXME: write
+ (is false "No tests have been written."))

0 comments on commit 7d21fa1

Please sign in to comment.