This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_literal(obj) | |
if obj.is_a? String | |
if val = Integer(obj) rescue nil | |
val | |
elsif val = Float(obj) rescue nil | |
val | |
else | |
'"'+obj+'"' | |
end | |
elsif obj == nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def code_lists(codes, data, var, options={}) | |
options = defaults().merge(options) | |
lists = [] | |
codes.map{|code| | |
str = <<-EOF.unindent | |
code:#{code.downcase.capitalize} a rdfs:Class, owl:Class; | |
rdfs:subClassOf skos:Concept ; | |
rdfs:label "Code list for #{code} - codelist class"@en; | |
rdfs:comment "Specifies the #{code} for each observation"; | |
rdfs:seeAlso code:#{code.downcase} . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def concept_codes(codes, data, var, options={}) | |
options = defaults().merge(options) | |
concepts = [] | |
codes.map{|code| | |
data[code].uniq.map{|value| | |
concepts << <<-EOF.unindent | |
<code/#{code.downcase}/#{value}> a skos:Concept, code:#{code.downcase.capitalize}; | |
skos:topConceptOf code:#{code.downcase} ; | |
skos:prefLabel "#{value}" ; | |
skos:inScheme code:#{code.downcase} . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@base <http://www.rqtl.org/ns/dc/> . | |
@prefix ns: <http://www.rqtl.org/ns/dataset/bacon#> . | |
@prefix qb: <http://purl.org/linked-data/cube#> . | |
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | |
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | |
@prefix prop: <http://www.rqtl.org/dc/properties/> . | |
@prefix cs: <http://www.rqtl.org/dc/dataset/bacon/cs/> . | |
@prefix code: <http://www.rqtl.org/dc/dataset/bacon/code/> . | |
@prefix class: <http://www.rqtl.org/dc/dataset/bacon/class/> . | |
@prefix owl: <http://www.w3.org/2002/07/owl#> . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data_cube :triplified_example do | |
source "examples/marker_regression.RData" | |
dimensions "chr" | |
measures "pos", "lod" | |
end | |
metadata do | |
data :triplified_example | |
description "Marker regression on example listeria dataset" | |
author do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'open-uri' | |
require 'text-table' | |
def html_table(url,row_length,table_num = 0,ops=nil,header_length=row_length-1,less_headers=nil) | |
doc = Nokogiri::HTML(open(url)) | |
main = doc.xpath('//table').to_a[table_num] | |
vals = main.search('td//text()[normalize-space()]') | |
headers = vals[0..header_length].map(&:to_s) | |
rows = vals.to_a.reject{|v| headers.include? v.to_s}.each_slice(row_length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'googlevoiceapi' | |
require 'json' | |
class GVPoller | |
def fetch_messages | |
api = @api | |
json_data = api.messages_json() | |
js = JSON.parse(json_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"in_room": true, | |
"settings": { | |
"mgmtOptsOn": false, | |
"contractsOn": false, | |
"fields": 2 | |
}, | |
"stageName": "Plant", | |
"year": 4, | |
"stageNumber": 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'publisci' | |
include PubliSci::DSL | |
# Specify input data | |
data do | |
# use local or remote paths | |
source 'https://github.com/wstrinz/publisci/raw/master/spec/csv/bacon.csv' | |
# specify datacube properties | |
dimension 'producer', 'pricerange' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"in_room": true, | |
"settings": | |
{ | |
"mgmtOptsOn": false, | |
"contractsOn": false, | |
"fields": 2 | |
}, | |
"stageName": "Plant", | |
"year": 4, |