Module: Xena
- Extended by:
- Resource
- Defined in:
- lib/rbbt/sources/Xena.rb
Constant Summary collapse
- DEFAULT_XENA_HUB =
"https://ucscpublic.xenahubs.net"- TCGA_HUB =
"https://tcga.xenahubs.net/"
Class Method Summary collapse
- .cohort_dataset(cohort, hub = DEFAULT_XENA_HUB) ⇒ Object
- .cohorts(hub = DEFAULT_XENA_HUB) ⇒ Object
-
.query(query, hub = DEFAULT_XENA_HUB) ⇒ Object
self.search_paths = {} self.search_paths = :lib.
- .tsv(file, hub = DEFAULT_XENA_HUB) ⇒ Object
Class Method Details
.cohort_dataset(cohort, hub = DEFAULT_XENA_HUB) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rbbt/sources/Xena.rb', line 52 def self.cohort_dataset(cohort, hub = DEFAULT_XENA_HUB) query ="(; datasetList\n(fn [cohorts]\n (let [count-table {:select [[:dataset.name :dname] [:%count.value :count]]\n :from [:dataset]\n :join [:field [:= :dataset.id :dataset_id]\n :code [:= :field.id :field_id]]\n :group-by [:dataset.name]\n :where [:= :field.name \"sampleID\"]}]\n (query {:select [:d.name :d.longtitle :count :d.type :d.datasubtype :d.probemap :d.text :d.status [:pm-dataset.text :pmtext]]\n :from [[:dataset :d]]\n :left-join [[:dataset :pm-dataset] [:= :pm-dataset.name :d.probemap]\n count-table [:= :dname :d.name]]\n :where [:in :d.cohort cohorts]})\n))\n [\"\#{ cohort }\"])\n EOF\n\n self.query(query, hub)\nend\n" |
.cohorts(hub = DEFAULT_XENA_HUB) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rbbt/sources/Xena.rb', line 38 def self.cohorts(hub = DEFAULT_XENA_HUB) query ="(;allCohorts\n(fn []\n(map :cohort\n (query\n {:select [[#sql/call [:distinct #sql/call [:ifnull :cohort \"(unassigned)\"]] :cohort]]\n :from [:dataset]})))\n)\n EOF\n\n self.query query, hub\nend\n" |
.query(query, hub = DEFAULT_XENA_HUB) ⇒ Object
self.search_paths = {} self.search_paths = :lib
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rbbt/sources/Xena.rb', line 18 def self.query(query, hub = DEFAULT_XENA_HUB) url = File.join(hub, 'data/') uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true header = {'Content-Type': 'text/plain'} request = Net::HTTP::Post.new(uri.request_uri, header) request.body = query response = http.request(request) JSON.parse(response.body) end |
.tsv(file, hub = DEFAULT_XENA_HUB) ⇒ Object
33 34 35 36 |
# File 'lib/rbbt/sources/Xena.rb', line 33 def self.tsv(file, hub = DEFAULT_XENA_HUB) url = "#{hub}/download/#{file}" TSV.open(url, :monitor => true, :header_hash => '') end |