Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ray1729/Bio-Ensembl
base: cbf0dfecb1
...
head fork: ray1729/Bio-Ensembl
compare: 7d21fa1472
  • 2 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
View
11 .gitignore
@@ -1,5 +1,8 @@
-pom.xml
+/pom.xml
*jar
-lib
-classes
-*~
+/lib
+/classes
+/native
+/.lein-failures
+/checkouts
+/.lein-deps-sum
View
21 README
@@ -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
31 README.md
@@ -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
14 project.clj
@@ -1,7 +1,7 @@
-(defproject ray1729/bio.ensembl "1.0.0-SNAPSHOT"
- :description "Clojure functions for interacting with EnsEMBL database"
- :dependencies [[org.clojure/clojure "1.2.0"]
- [org.clojure/clojure-contrib "1.2.0"]
- [clojureql "1.0.0"]
- [mysql/mysql-connector-java "5.1.15"]]
- :dev-dependencies [[swank-clojure "1.2.1"]])
+(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 }]])
View
15 src/ensembl/config.clj
@@ -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
35 src/ensembl/core.clj
@@ -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))
View
62 src/ray1729/bio/ensembl/core.clj
@@ -1,62 +0,0 @@
-(ns ray1729.bio.ensembl.core
- (:refer-clojure
- :exclude [take drop sort distinct conj! disj! compile case])
- (:use
- [clojure.contrib.sql :only (with-connection)]
- [clojureql.core]))
-
-(def *ensembldb-host* "ensembldb.ensembl.org")
-(def *ensembldb-port* 5306)
-(def *species-id* 1)
-
-(defn ensembldb
- [dbname]
- {:classname "com.mysql.jdbc.Driver"
- :subprotocol "mysql"
- :user "anonymous"
- :subname (format "//%s:%s/%s" *ensembldb-host* *ensembldb-port* dbname)
- :auto-commit true
- :fetch-size 500})
-
-(def mousedb (ensembldb "mus_musculus_core_61_37n"))
-
-;;(open-global :mousedb mousedb)
-
-(defn fetch-gene-by-stable-id
- [id]
- (-> (table :gene_stable_id)
- (select (where (= :stable_id id)))
- (join (table :gene) :gene_id)
- (project [:gene.* :gene_stable_id.stable_id])))
-
-(defn fetch-gene-by-external-name
- [name]
- (let [base-query (-> (table :gene)
- (select (where (= :gene.is_current 1)))
- (join (table :gene_stable_id) :gene_id)
- (join (table :seq_region)
- (where (= :gene.seq_region_id :seq_region.seq_region_id)))
- (join (table :coord_system)
- (where (and (= :coord_system.coord_system_id :seq_region.coord_system_id)
- (= :coord_system.species_id *species-id*))))
- (join (table :object_xref)
- (where (and (= :object_xref.ensembl_id :gene.gene_id)
- (= :object_xref.ensembl_object_type "Gene"))))
- (join (table :xref)
- (where (= :xref.xref_id :object_xref.xref_id))))
- query1 (-> base-query
- (select (where (or (= :xref.dbprimary_acc name)
- (= :xref.display_label name))))
- (project [:gene.*, :gene_stable_id.stable_id])
- (distinct))
- query2 (-> base-query
- (join (table :external_synonym)
- (where (= :external_synonym.xref_id :object_xref.xref_id)))
- (select (where (= :external_synonym.synonym name)))
- (project [:gene.*, :gene_stable_id.stable_id])
- (distinct))]
- (union query1 query2)))
-
-;; XXX Throws exception "No value specified for parameter 7"
-;; (with-connection mousedb @(fetch-gene-by-external-name "Cbx1"))
-
View
4 test/ray1729/bio/ensembl/test/core.clj → test/ensembl/test/core.clj
@@ -1,5 +1,5 @@
-(ns ray1729.bio.ensembl.test.core
- (:use [ray1729.bio.ensembl.core] :reload)
+(ns ensembl.test.core
+ (:use [ensembl.core])
(:use [clojure.test]))
(deftest replace-me ;; FIXME: write

No commit comments for this range

Something went wrong with that request. Please try again.