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 =<<-EOF (; datasetList (fn [cohorts] (let [count-table {:select [[:dataset.name :dname] [:%count.value :count]] :from [:dataset] :join [:field [:= :dataset.id :dataset_id] :code [:= :field.id :field_id]] :group-by [:dataset.name] :where [:= :field.name "sampleID"]}] (query {:select [:d.name :d.longtitle :count :d.type :d.datasubtype :d.probemap :d.text :d.status [:pm-dataset.text :pmtext]] :from [[:dataset :d]] :left-join [[:dataset :pm-dataset] [:= :pm-dataset.name :d.probemap] count-table [:= :dname :d.name]] :where [:in :d.cohort cohorts]}) )) ["#{ cohort }"]) EOF self.query(query, hub) end |
.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 =<<-EOF (;allCohorts (fn [] (map :cohort (query {:select [[#sql/call [:distinct #sql/call [:ifnull :cohort "(unassigned)"]] :cohort]] :from [:dataset]}))) ) EOF self.query query, hub end |
.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 |