bio-publisci 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +10 -0
  3. data/Rakefile +1 -1
  4. data/bin/bio-publisci-server +50 -0
  5. data/features/reader_steps.rb +1 -1
  6. data/lib/bio-publisci.rb +11 -2
  7. data/lib/bio-publisci/datacube_model.rb +92 -88
  8. data/lib/bio-publisci/dataset/ORM/data_cube_orm.rb +0 -1
  9. data/lib/bio-publisci/dataset/data_cube.rb +78 -44
  10. data/lib/bio-publisci/dataset/dataset_for.rb +26 -27
  11. data/lib/bio-publisci/metadata/metadata_model.rb +21 -23
  12. data/lib/bio-publisci/metadata/prov/model/prov_models.rb +5 -5
  13. data/lib/bio-publisci/output.rb +1 -1
  14. data/lib/bio-publisci/parser.rb +130 -12
  15. data/lib/bio-publisci/post_processor.rb +95 -0
  16. data/lib/bio-publisci/query/query_helper.rb +13 -8
  17. data/lib/bio-publisci/readers/arff.rb +1 -1
  18. data/lib/bio-publisci/readers/base.rb +57 -0
  19. data/lib/bio-publisci/readers/csv.rb +2 -5
  20. data/lib/bio-publisci/readers/dataframe.rb +2 -2
  21. data/lib/bio-publisci/readers/maf.rb +199 -0
  22. data/lib/bio-publisci/readers/r_cross.rb +6 -10
  23. data/lib/bio-publisci/readers/r_matrix.rb +1 -1
  24. data/lib/bio-publisci/writers/base.rb +16 -0
  25. data/lib/bio-publisci/writers/json.rb +18 -0
  26. data/resources/maf_example.maf +10 -0
  27. data/resources/maf_rdf.ttl +1173 -0
  28. data/resources/primer.ttl +38 -0
  29. data/resources/queries/gene.rq +16 -0
  30. data/resources/queries/hugo_to_ensembl.rq +7 -0
  31. data/resources/queries/maf_column.rq +26 -0
  32. data/resources/queries/patient.rq +11 -0
  33. data/resources/queries/patient_list.rq +11 -0
  34. data/resources/queries/patients_with_mutation.rq +18 -0
  35. data/scripts/get_gene_lengths.rb +50 -0
  36. data/scripts/islet_mlratio.rb +1 -1
  37. data/scripts/scan_islet.rb +1 -1
  38. data/scripts/update_reference.rb +8 -3
  39. data/server/helpers.rb +215 -0
  40. data/server/public/src-min-noconflict/LICENSE +24 -0
  41. data/server/public/src-min-noconflict/ace.js +11 -0
  42. data/server/public/src-min-noconflict/ext-chromevox.js +1 -0
  43. data/server/public/src-min-noconflict/ext-elastic_tabstops_lite.js +1 -0
  44. data/server/public/src-min-noconflict/ext-emmet.js +1 -0
  45. data/server/public/src-min-noconflict/ext-keybinding_menu.js +1 -0
  46. data/server/public/src-min-noconflict/ext-language_tools.js +1 -0
  47. data/server/public/src-min-noconflict/ext-modelist.js +1 -0
  48. data/server/public/src-min-noconflict/ext-old_ie.js +1 -0
  49. data/server/public/src-min-noconflict/ext-searchbox.js +1 -0
  50. data/server/public/src-min-noconflict/ext-settings_menu.js +1 -0
  51. data/server/public/src-min-noconflict/ext-spellcheck.js +1 -0
  52. data/server/public/src-min-noconflict/ext-split.js +1 -0
  53. data/server/public/src-min-noconflict/ext-static_highlight.js +1 -0
  54. data/server/public/src-min-noconflict/ext-statusbar.js +1 -0
  55. data/server/public/src-min-noconflict/ext-textarea.js +1 -0
  56. data/server/public/src-min-noconflict/ext-themelist.js +1 -0
  57. data/server/public/src-min-noconflict/ext-whitespace.js +1 -0
  58. data/server/public/src-min-noconflict/keybinding-emacs.js +1 -0
  59. data/server/public/src-min-noconflict/keybinding-vim.js +1 -0
  60. data/server/public/src-min-noconflict/mode-ruby.js +1 -0
  61. data/server/public/src-min-noconflict/snippets/ruby.js +1 -0
  62. data/server/public/src-min-noconflict/theme-twilight.js +1 -0
  63. data/server/public/src-min-noconflict/worker-coffee.js +1 -0
  64. data/server/public/src-min-noconflict/worker-css.js +1 -0
  65. data/server/public/src-min-noconflict/worker-javascript.js +1 -0
  66. data/server/public/src-min-noconflict/worker-json.js +1 -0
  67. data/server/public/src-min-noconflict/worker-lua.js +1 -0
  68. data/server/public/src-min-noconflict/worker-php.js +1 -0
  69. data/server/public/src-min-noconflict/worker-xquery.js +1 -0
  70. data/server/routes.rb +123 -0
  71. data/server/views/dsl.haml +65 -0
  72. data/server/views/dump.haml +3 -0
  73. data/server/views/import.haml +35 -0
  74. data/server/views/new_repository.haml +25 -0
  75. data/server/views/query.haml +28 -0
  76. data/server/views/repository.haml +25 -0
  77. data/spec/ORM/data_cube_orm_spec.rb +1 -0
  78. data/spec/bnode_spec.rb +66 -0
  79. data/spec/data_cube_spec.rb +66 -63
  80. data/spec/dataset_for_spec.rb +36 -16
  81. data/spec/dsl_spec.rb +41 -0
  82. data/spec/generators/csv_spec.rb +3 -3
  83. data/spec/generators/dataframe_spec.rb +2 -2
  84. data/spec/generators/maf_spec.rb +40 -0
  85. data/spec/generators/r_cross_spec.rb +2 -2
  86. data/spec/generators/r_matrix_spec.rb +2 -2
  87. data/spec/length_lookup_spec.rb +0 -0
  88. data/spec/maf_query_spec.rb +343 -0
  89. data/spec/resource/example.Rhistory +1 -1
  90. data/spec/turtle/bacon +9 -9
  91. data/spec/turtle/reference +43 -43
  92. data/spec/turtle/weather +10 -10
  93. data/spec/writer_spec.rb +16 -2
  94. metadata +212 -61
@@ -0,0 +1,38 @@
1
+ @prefix prov: <http://www.w3.org/ns/prov#> .
2
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
3
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
5
+
6
+ <http://example.org/entity/chart1> a prov:Entity ;
7
+ prov:wasAttributedTo <http://example.org/agent/derek> ;
8
+ rdfs:label "chart1" .
9
+
10
+ <http://example.org/entity/composition1> a prov:Entity ;
11
+ rdfs:label "composition1" .
12
+
13
+ <http://example.org/entity/regionList1> a prov:Entity ;
14
+ rdfs:label "regionList1" .
15
+
16
+ <http://example.org/entity/dataSet1> a prov:Entity ;
17
+ rdfs:label "dataSet1" .
18
+
19
+ <http://example.org/agent/derek> a prov:Agent ;
20
+ foaf:name "Derek" ;
21
+ prov:actedOnBehalfOf <http://example.org/agent/chartgen> ;
22
+ rdfs:label "derek" .
23
+
24
+ <http://example.org/agent/chartgen> a prov:Organization ;
25
+ rdfs:label "chartgen" .
26
+
27
+ <http://example.org/activity/illustrate> a prov:Activity ;
28
+ prov:generated <http://example.org/entity/chart1> ;
29
+ prov:used <http://example.org/entity/composition1>;
30
+ prov:wasAssociatedWith <http://example.org/agent/derek> ;
31
+ rdfs:label "illustrate" .
32
+
33
+ <http://example.org/activity/compose1> a prov:Activity ;
34
+ prov:generated <http://example.org/entity/composition1> ;
35
+ prov:used <http://example.org/entity/regionList1>, <http://example.org/entity/dataSet1>;
36
+ prov:wasAssociatedWith <http://example.org/agent/derek> ;
37
+ rdfs:label "compose1" .
38
+
@@ -0,0 +1,16 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+
4
+ SELECT DISTINCT ?gene WHERE {
5
+ [] a qb:ComponentSpecification;
6
+ rdfs:label "Tumor_Sample_Barcode";
7
+ qb:measure ?barcode_measure.
8
+
9
+ ?patient_obs a qb:Observation;
10
+ ?barcode_measure ?barcode;
11
+ <http://onto.strinz.me/properties/patient_id> "%{patient}";
12
+ <http://onto.strinz.me/properties/Hugo_Symbol> ?gene.
13
+
14
+
15
+ # ?node <http://semanticscience.org/resource/SIO_000300> ?gene ;
16
+ }
@@ -0,0 +1,7 @@
1
+ SELECT distinct ?hgnc ?ensembl where {
2
+ {?hgnc <http://bio2rdf.org/hgnc_vocabulary:approved_symbol> "%{hugo_symbol}"}
3
+ UNION
4
+ {?hgnc <http://bio2rdf.org/hgnc_vocabulary:synonym> "%{hugo_symbol}"}
5
+
6
+ ?hgnc <http://bio2rdf.org/hgnc_vocabulary:x-ensembl> ?ensembl
7
+ }
@@ -0,0 +1,26 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX sio: <http://semanticscience.org/resource/>
4
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
5
+
6
+ SELECT DISTINCT ?column WHERE {
7
+ [] a qb:ComponentSpecification;
8
+ rdfs:label "%{column}";
9
+ qb:measure ?column_measure.
10
+
11
+ [] a qb:ComponentSpecification;
12
+ rdfs:label "patient_id";
13
+ qb:measure ?patient_id.
14
+
15
+ ?obs a qb:Observation;
16
+ ?patient_id "%{patient}" ;
17
+ ?column_measure ?column.
18
+ # {
19
+ # ?obs ?column_measure ?column.
20
+ # FILTER isLiteral(?column)
21
+ # }
22
+ # UNION
23
+ # {?obs ?column_measure [ sio:SIO_000300 ?column ]}
24
+ # UNION
25
+ # {?obs ?column_measure [ sio:SIO_000008 [sio:SIO_000300 ?column] ]}
26
+ }
@@ -0,0 +1,11 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+
4
+ SELECT (COUNT(?barcode) as ?barcodes) WHERE {
5
+ [] a qb:ComponentSpecification;
6
+ rdfs:label "patient_id";
7
+ qb:measure ?patient_id.
8
+
9
+ [] a qb:Observation;
10
+ ?patient_id ?barcode.
11
+ }
@@ -0,0 +1,11 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+
4
+ SELECT DISTINCT ?id WHERE {
5
+ [] a qb:ComponentSpecification;
6
+ rdfs:label "patient_id";
7
+ qb:measure ?patient_id.
8
+
9
+ [] a qb:Observation;
10
+ ?patient_id ?id.
11
+ }
@@ -0,0 +1,18 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX sio: <http://semanticscience.org/resource/>
4
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
5
+
6
+ SELECT DISTINCT ?patient_id WHERE {
7
+ [] a qb:ComponentSpecification;
8
+ rdfs:label "Hugo_Symbol";
9
+ qb:measure ?column_measure.
10
+
11
+ [] a qb:ComponentSpecification;
12
+ rdfs:label "patient_id";
13
+ qb:measure ?patient_id_property.
14
+
15
+ ?obs a qb:Observation;
16
+ ?column_measure <http://identifiers.org/hgnc.symbol/%{hugo_symbol}> ;
17
+ ?patient_id_property ?patient_id .
18
+ }
@@ -0,0 +1,50 @@
1
+ # require_relative '../lib/bio-publisci.rb'
2
+ require 'bio-publisci'
3
+ def gene_lengths(repo)
4
+
5
+ gene_query = <<-EOF
6
+ PREFIX qb: <http://purl.org/linked-data/cube#>
7
+
8
+ SELECT DISTINCT ?gene WHERE {
9
+ ?obs a qb:Observation;
10
+ <http://onto.strinz.me/properties/Hugo_Symbol> ?gene.
11
+ }
12
+ EOF
13
+
14
+ genes = PubliSci::QueryHelper.execute(gene_query,repo).map(&:gene)
15
+ puts "retrieving information for #{genes.size} genes"
16
+
17
+ all_genes = []
18
+ genes.each_slice(250){|slice|
19
+ sadi_in = <<-EOF
20
+ @prefix sio: <http://semanticscience.org/resource/>.
21
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
22
+ @prefix serviceowl: <http://biordf.org:8080/sadi_service_ontologies/HUGO_2_ENSEMBLGENEINFO.owl/>.
23
+
24
+ EOF
25
+
26
+ slice.each{|gene|
27
+ sadi_in += <<-EOF
28
+ <#{gene}> a serviceowl:HUGO_2_ENSEMBLGENEINFO_Input;
29
+ sio:SIO_000300 "#{gene}".
30
+ EOF
31
+ }
32
+ response = PubliSci::SADI_request.fetch_async('http://biordf.org:8080/cgi-bin/services/HUGO_2_ENSEMBLGENEINFO_async.pl',sadi_in)
33
+ puts "chunk done #{ all_genes.size}"
34
+ all_genes << response.join("\n\n")
35
+ }
36
+ all_genes.join("\n\n")
37
+ end
38
+
39
+ repo_uri = ARGV[0] || 'http://localhost:8080'
40
+
41
+ repo = RDF::FourStore::Repository.new(repo_uri)
42
+
43
+ lengths = gene_lengths(repo)
44
+ puts lengths
45
+ if ARGV[1] == "save"
46
+ repo << RDF::Turtle::Reader.new(lengths)
47
+ else
48
+ open('gene_lengths.ttl','w'){|f| f.write lengths }
49
+ end
50
+
@@ -1,6 +1,6 @@
1
1
  load File.dirname(__FILE__) + '/../lib/bio-publisci.rb'
2
2
 
3
- gen = PubliSci::Reader::RMatrix.new
3
+ gen = PubliSci::Readers::RMatrix.new
4
4
  con = Rserve::Connection.new
5
5
  con.eval("load('#{ARGV[0] || './.RData'}')")
6
6
  gen.generate_n3(con, "islet.mlratio", "pheno", {measures: ["probe","individual","pheno"], no_labels: true})
@@ -1,6 +1,6 @@
1
1
  load File.dirname(__FILE__) + '/../lib/bio-publisci.rb'
2
2
 
3
- gen = PubliSci::Reader::RMatrix.new
3
+ gen = PubliSci::Readers::RMatrix.new
4
4
  con = Rserve::Connection.new
5
5
  con.eval("load('#{ARGV[0] || './.RData'}')")
6
6
  gen.generate_n3(con, "scan.islet", "scan", {measures: ["probe","marker","lod"], no_labels: true})
@@ -4,12 +4,12 @@ exit unless gets.chomp == 'y'
4
4
  puts "overwriting #{File.absolute_path(File.dirname(__FILE__) + '/../spec/turtle/bacon')}"
5
5
  load File.dirname(__FILE__) + '/../lib/bio-publisci.rb'
6
6
 
7
- gen = PubliSci::Reader::CSV.new
7
+ gen = PubliSci::Readers::CSV.new
8
8
  turtle_string = gen.generate_n3(File.dirname(__FILE__) + '/../spec/csv/bacon.csv','bacon',{dimensions:["producer","pricerange"], label_column:0})
9
9
  open(File.dirname(__FILE__) + '/../spec/turtle/bacon', 'w'){|f| f.write turtle_string}
10
10
 
11
11
  rcon = Rserve::Connection.new
12
- gen = PubliSci::Reader::Dataframe.new
12
+ gen = PubliSci::Readers::Dataframe.new
13
13
  rcon.void_eval <<-EOF
14
14
  library(qtl)
15
15
  data(listeria)
@@ -17,4 +17,9 @@ mr = scanone(listeria,method="mr")
17
17
  EOF
18
18
  rexp = rcon.eval 'mr'
19
19
  turtle_string = gen.generate_n3(rexp,'mr')
20
- open(File.dirname(__FILE__) + '/../spec/turtle/reference', 'w'){|f| f.write turtle_string}
20
+ open(File.dirname(__FILE__) + '/../spec/turtle/reference', 'w'){|f| f.write turtle_string}
21
+ puts "overwriting #{File.absolute_path(File.dirname(__FILE__) + '/../spec/turtle/reference')}"
22
+
23
+ turtle_string = PubliSci::Dataset.for('resources/weather.numeric.arff',false)
24
+ open(File.dirname(__FILE__) + '/../spec/turtle/weather', 'w'){|f| f.write turtle_string}
25
+ puts "overwriting #{File.absolute_path(File.dirname(__FILE__) + '/../spec/turtle/weather')}"
@@ -0,0 +1,215 @@
1
+ class PubliSciServer < Sinatra::Base
2
+
3
+ helpers do
4
+
5
+ def h(str)
6
+ CGI::escapeHTML(str.to_s)
7
+ end
8
+
9
+ def format_ttl(str)
10
+ #TODO make this actually work right
11
+ str.gsub("\n","\n<br>").gsub('<br> ','<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ').gsub('<br> ','<br>&nbsp; &nbsp; &nbsp; ')
12
+ end
13
+
14
+ def self.configure_server(opts)
15
+ set :port, opts[:port].to_i if opts[:port]
16
+ set :bind, opts[:bind] if opts[:bind]
17
+ if opts[:type]
18
+ if opts[:type] == "fourstore"
19
+ uri = opts[:uri] || 'http://localhost:80802'
20
+ set :repository, RDF::FourStore::Repository.new(uri.dup)
21
+ else
22
+ set :repository, RDF::Repository.new
23
+ end
24
+ else
25
+ set :repository, RDF::Repository.new
26
+ end
27
+ end
28
+
29
+ def print_usage
30
+ str = puts <<-EOF
31
+ Bio-PubliSci Server Interface
32
+
33
+ Description: Start the server and point your browser to localhost:4567
34
+
35
+ Usage: bio-publisci-server [options]
36
+
37
+ EOF
38
+ end
39
+
40
+ CONTENT_TYPES={'xml' => 'text/xml','json' => 'application/json','ttl' => 'text/n3'}
41
+
42
+ def content_for(data,fallback=:to_html,format=(params[:format] || request.accept))
43
+ if params[:format]
44
+ format = CONTENT_TYPES[format]
45
+ else
46
+ format = format.first
47
+ end
48
+ if CONTENT_TYPES.values.include? format
49
+ content_type format #, :charset => 'utf-8'
50
+ end
51
+
52
+ case format.to_s
53
+ when 'text/xml'
54
+ data.to_xml
55
+ when 'application/json'
56
+ data.to_json
57
+ else
58
+ if data.respond_to? fallback
59
+ data.send(fallback)
60
+ else
61
+ data.to_s
62
+ end
63
+ end
64
+ end
65
+
66
+ def rdf_content_for(data,fallback=:to_html,format=(params[:format] || request.accept))
67
+ if params[:format]
68
+ format = CONTENT_TYPES[format]
69
+ else
70
+ format = format.first
71
+ end
72
+ if CONTENT_TYPES.values.include? format
73
+ content_type format #, :charset => 'utf-8'
74
+ end
75
+
76
+ case format.to_s
77
+ when 'text/xml'
78
+ data.to_rdfxml
79
+ when 'application/rdf+xml'
80
+ data.to_rdfxml
81
+ when 'application/json'
82
+ data.dump(:jsonld, :standard_prefixes => true)
83
+ when 'text/n3'
84
+ data.to_ttl
85
+ else
86
+ if data.respond_to? fallback
87
+ data.send(fallback)
88
+ else
89
+ data.to_s
90
+ end
91
+ end
92
+ end
93
+
94
+ def content_response(html_resp,content=:no_content)
95
+ if !CONTENT_TYPES.keys.include?(params[:format].to_s) and request.accept? 'text/html'
96
+ if html_resp.is_a? Symbol
97
+ haml html_resp
98
+ else
99
+ html_resp
100
+ end
101
+ else
102
+ content
103
+ end
104
+ end
105
+
106
+ def create_repository(type,uri)
107
+ if type == "in_memory"
108
+ flash[:notice] = "#{type} repository created!"
109
+ RDF::Repository.new
110
+ elsif type == "4store"
111
+ unless RDF::URI(uri).valid?
112
+ flash[:notice] = "Need a valid URI for a FourStore repository"
113
+ nil
114
+ end
115
+
116
+ flash[:notice] = "#{type} repository created!"
117
+ RDF::FourStore::Repository.new(uri)
118
+ else
119
+ raise "UnkownTypeForSomeReason?: #{type}"
120
+ end
121
+ end
122
+
123
+ def clear_repository
124
+ repo = settings.repository
125
+ if repo.is_a? RDF::FourStore::Repository
126
+ passwd = settings.sudo_pass
127
+ raise "need sudo password set to clear 4store" unless passwd
128
+ `echo #{passwd} | sudo -S killall 4s-backend`
129
+ `echo #{passwd} | sudo -S killall 4s-httpd`
130
+ `echo #{passwd} | sudo -S 4s-backend-setup test`
131
+ `echo #{passwd} | sudo -S 4s-backend test`
132
+ `echo #{passwd} | sudo -S 4s-httpd -U test`
133
+
134
+ else
135
+ repo.clear
136
+ end
137
+ end
138
+
139
+ def default_prefixes
140
+ <<-EOF
141
+ PREFIX qb: <http://purl.org/linked-data/cube#>
142
+ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
143
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
144
+ PREFIX owl: <http://www.w3.org/2002/07/owl#>
145
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
146
+
147
+ EOF
148
+ end
149
+
150
+ def example_query
151
+ default_prefixes +
152
+ <<-EOF
153
+ SELECT * WHERE {
154
+ ?s ?p ?o
155
+ } LIMIT 10
156
+ EOF
157
+ end
158
+
159
+ def example_dsl
160
+ <<-EOF
161
+ data do
162
+ object "https://raw.github.com/wstrinz/bioruby-publisci/master/spec/csv/bacon.csv"
163
+
164
+ object "https://raw.github.com/wstrinz/bioruby-publisci/master/resources/weather.numeric.arff"
165
+ end
166
+ EOF
167
+ end
168
+
169
+ def load_dsl(script)
170
+ ev = PubliSci::DSL::Instance.new
171
+ begin
172
+ ev.instance_eval(script)
173
+ rescue Exception => e
174
+ raise "Caught error in eval #{e} #{e.backtrace}"
175
+ end
176
+
177
+ import_rdf(ev.instance_eval("generate_n3"),:ttl)
178
+ end
179
+
180
+ def import_rdf(input,type)
181
+ if input.is_a?(File) || input.is_a?(Tempfile)
182
+ f = Tempfile.new(['',".#{type}"])
183
+ begin
184
+ f.write(input.read)
185
+ f.close
186
+ oldsize = settings.repository.size
187
+ settings.repository.load(f.path, format: type)
188
+ ensure
189
+ f.unlink
190
+ end
191
+ "#{settings.repository.size - oldsize} triples imported"
192
+ else
193
+ oldsize = settings.repository.size
194
+ read = RDF::Reader.for(type.to_sym)
195
+ read = read.new(input)
196
+ settings.repository << read
197
+ "#{settings.repository.size - oldsize} triples imported"
198
+ end
199
+ end
200
+
201
+ def query_repository(query,format_result = true)
202
+ repo = settings.repository
203
+ if repo.is_a? RDF::FourStore::Repository
204
+ sols = SPARQL::Client.new("#{settings.repository.uri}/sparql/").query(query)
205
+ elsif repo.is_a? RDF::Repository
206
+ sols = SPARQL::Client.new(settings.repository).query(query)
207
+ else
208
+ raise "Unrecognized Repository: #{settings.repository.class}"
209
+ end
210
+
211
+ sols
212
+
213
+ end
214
+ end
215
+ end