publisci 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +13 -0
  5. data/Gemfile +36 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +51 -0
  8. data/README.rdoc +48 -0
  9. data/Rakefile +68 -0
  10. data/bin/bio-publisci +106 -0
  11. data/bin/bio-publisci-server +50 -0
  12. data/examples/bio-band_integration.rb +9 -0
  13. data/examples/no_magic.prov +58 -0
  14. data/examples/no_magic.rb +58 -0
  15. data/examples/orm.prov +48 -0
  16. data/examples/primer-full.prov +120 -0
  17. data/examples/primer.prov +66 -0
  18. data/examples/prov_dsl.prov +85 -0
  19. data/examples/safe_gen.rb +7 -0
  20. data/examples/visualization/primer.prov +66 -0
  21. data/examples/visualization/prov_viz.rb +140 -0
  22. data/examples/visualization/viz.rb +35 -0
  23. data/features/create_generator.feature +21 -0
  24. data/features/integration.feature +12 -0
  25. data/features/integration_steps.rb +10 -0
  26. data/features/metadata.feature +37 -0
  27. data/features/metadata_steps.rb +40 -0
  28. data/features/orm.feature +60 -0
  29. data/features/orm_steps.rb +74 -0
  30. data/features/prov_dsl.feature +14 -0
  31. data/features/prov_dsl_steps.rb +11 -0
  32. data/features/reader.feature +25 -0
  33. data/features/reader_steps.rb +61 -0
  34. data/features/step_definitions/bio-publisci_steps.rb +0 -0
  35. data/features/store.feature +27 -0
  36. data/features/store_steps.rb +42 -0
  37. data/features/support/env.rb +13 -0
  38. data/features/writer.feature +14 -0
  39. data/features/writer_steps.rb +24 -0
  40. data/lib/bio-publisci.rb +64 -0
  41. data/lib/bio-publisci/analyzer.rb +57 -0
  42. data/lib/bio-publisci/datacube_model.rb +111 -0
  43. data/lib/bio-publisci/dataset/ORM/data_cube_orm.rb +240 -0
  44. data/lib/bio-publisci/dataset/ORM/observation.rb +20 -0
  45. data/lib/bio-publisci/dataset/configuration.rb +31 -0
  46. data/lib/bio-publisci/dataset/data_cube.rb +418 -0
  47. data/lib/bio-publisci/dataset/dataset.rb +11 -0
  48. data/lib/bio-publisci/dataset/dataset_for.rb +186 -0
  49. data/lib/bio-publisci/dataset/interactive.rb +72 -0
  50. data/lib/bio-publisci/dsl/config.rb +34 -0
  51. data/lib/bio-publisci/dsl/dataset_dsl.rb +93 -0
  52. data/lib/bio-publisci/dsl/dsl.rb +72 -0
  53. data/lib/bio-publisci/dsl/metadata_dsl.rb +85 -0
  54. data/lib/bio-publisci/dsl/prov_dsl.rb +143 -0
  55. data/lib/bio-publisci/metadata/generator.rb +323 -0
  56. data/lib/bio-publisci/metadata/metadata.rb +5 -0
  57. data/lib/bio-publisci/metadata/metadata_model.rb +25 -0
  58. data/lib/bio-publisci/metadata/prov/activity.rb +88 -0
  59. data/lib/bio-publisci/metadata/prov/agent.rb +100 -0
  60. data/lib/bio-publisci/metadata/prov/association.rb +107 -0
  61. data/lib/bio-publisci/metadata/prov/config.rb +34 -0
  62. data/lib/bio-publisci/metadata/prov/derivation.rb +60 -0
  63. data/lib/bio-publisci/metadata/prov/element.rb +120 -0
  64. data/lib/bio-publisci/metadata/prov/entity.rb +64 -0
  65. data/lib/bio-publisci/metadata/prov/model/prov_models.rb +109 -0
  66. data/lib/bio-publisci/metadata/prov/plan.rb +32 -0
  67. data/lib/bio-publisci/metadata/prov/prov.rb +78 -0
  68. data/lib/bio-publisci/metadata/prov/role.rb +40 -0
  69. data/lib/bio-publisci/metadata/prov/usage.rb +64 -0
  70. data/lib/bio-publisci/metadata/publisher.rb +25 -0
  71. data/lib/bio-publisci/mixins/custom_predicate.rb +38 -0
  72. data/lib/bio-publisci/mixins/dereferencable.rb +34 -0
  73. data/lib/bio-publisci/mixins/registry.rb +27 -0
  74. data/lib/bio-publisci/mixins/vocabulary.rb +8 -0
  75. data/lib/bio-publisci/output.rb +27 -0
  76. data/lib/bio-publisci/parser.rb +266 -0
  77. data/lib/bio-publisci/post_processor.rb +95 -0
  78. data/lib/bio-publisci/query/query_helper.rb +123 -0
  79. data/lib/bio-publisci/r_client.rb +54 -0
  80. data/lib/bio-publisci/readers/arff.rb +49 -0
  81. data/lib/bio-publisci/readers/base.rb +57 -0
  82. data/lib/bio-publisci/readers/csv.rb +88 -0
  83. data/lib/bio-publisci/readers/dataframe.rb +67 -0
  84. data/lib/bio-publisci/readers/maf.rb +199 -0
  85. data/lib/bio-publisci/readers/r_cross.rb +112 -0
  86. data/lib/bio-publisci/readers/r_matrix.rb +176 -0
  87. data/lib/bio-publisci/store.rb +56 -0
  88. data/lib/bio-publisci/writers/arff.rb +91 -0
  89. data/lib/bio-publisci/writers/base.rb +93 -0
  90. data/lib/bio-publisci/writers/csv.rb +31 -0
  91. data/lib/bio-publisci/writers/dataframe.rb +81 -0
  92. data/lib/bio-publisci/writers/json.rb +18 -0
  93. data/lib/r2rdf.rb +226 -0
  94. data/lib/template_bak.rb +12 -0
  95. data/lib/template_bak/publisci.rb +3 -0
  96. data/lib/vocabs/cc.rb +18 -0
  97. data/lib/vocabs/cert.rb +13 -0
  98. data/lib/vocabs/dc.rb +63 -0
  99. data/lib/vocabs/dc11.rb +23 -0
  100. data/lib/vocabs/doap.rb +45 -0
  101. data/lib/vocabs/exif.rb +168 -0
  102. data/lib/vocabs/foaf.rb +69 -0
  103. data/lib/vocabs/geo.rb +13 -0
  104. data/lib/vocabs/http.rb +26 -0
  105. data/lib/vocabs/ma.rb +78 -0
  106. data/lib/vocabs/owl.rb +59 -0
  107. data/lib/vocabs/rdfs.rb +17 -0
  108. data/lib/vocabs/rsa.rb +12 -0
  109. data/lib/vocabs/rss.rb +14 -0
  110. data/lib/vocabs/sioc.rb +93 -0
  111. data/lib/vocabs/skos.rb +36 -0
  112. data/lib/vocabs/wot.rb +21 -0
  113. data/lib/vocabs/xhtml.rb +9 -0
  114. data/lib/vocabs/xsd.rb +58 -0
  115. data/resources/maf_example.maf +10 -0
  116. data/resources/maf_rdf.ttl +1173 -0
  117. data/resources/primer.ttl +38 -0
  118. data/resources/queries/code_resources.rq +10 -0
  119. data/resources/queries/codes.rq +18 -0
  120. data/resources/queries/dataset.rq +7 -0
  121. data/resources/queries/dimension_ranges.rq +8 -0
  122. data/resources/queries/dimensions.rq +12 -0
  123. data/resources/queries/gene.rq +16 -0
  124. data/resources/queries/hugo_to_ensembl.rq +7 -0
  125. data/resources/queries/maf_column.rq +26 -0
  126. data/resources/queries/measures.rq +12 -0
  127. data/resources/queries/observation_labels.rq +8 -0
  128. data/resources/queries/observations.rq +13 -0
  129. data/resources/queries/patient.rq +11 -0
  130. data/resources/queries/patient_list.rq +11 -0
  131. data/resources/queries/patients_with_mutation.rq +18 -0
  132. data/resources/queries/properties.rq +8 -0
  133. data/resources/queries/test.rq +3 -0
  134. data/resources/weather.numeric.arff +28 -0
  135. data/scripts/get_gene_lengths.rb +50 -0
  136. data/scripts/islet_mlratio.rb +6 -0
  137. data/scripts/scan_islet.rb +6 -0
  138. data/scripts/update_reference.rb +25 -0
  139. data/server/helpers.rb +215 -0
  140. data/server/public/src-min-noconflict/LICENSE +24 -0
  141. data/server/public/src-min-noconflict/ace.js +11 -0
  142. data/server/public/src-min-noconflict/ext-chromevox.js +1 -0
  143. data/server/public/src-min-noconflict/ext-elastic_tabstops_lite.js +1 -0
  144. data/server/public/src-min-noconflict/ext-emmet.js +1 -0
  145. data/server/public/src-min-noconflict/ext-keybinding_menu.js +1 -0
  146. data/server/public/src-min-noconflict/ext-language_tools.js +1 -0
  147. data/server/public/src-min-noconflict/ext-modelist.js +1 -0
  148. data/server/public/src-min-noconflict/ext-old_ie.js +1 -0
  149. data/server/public/src-min-noconflict/ext-searchbox.js +1 -0
  150. data/server/public/src-min-noconflict/ext-settings_menu.js +1 -0
  151. data/server/public/src-min-noconflict/ext-spellcheck.js +1 -0
  152. data/server/public/src-min-noconflict/ext-split.js +1 -0
  153. data/server/public/src-min-noconflict/ext-static_highlight.js +1 -0
  154. data/server/public/src-min-noconflict/ext-statusbar.js +1 -0
  155. data/server/public/src-min-noconflict/ext-textarea.js +1 -0
  156. data/server/public/src-min-noconflict/ext-themelist.js +1 -0
  157. data/server/public/src-min-noconflict/ext-whitespace.js +1 -0
  158. data/server/public/src-min-noconflict/keybinding-emacs.js +1 -0
  159. data/server/public/src-min-noconflict/keybinding-vim.js +1 -0
  160. data/server/public/src-min-noconflict/mode-ruby.js +1 -0
  161. data/server/public/src-min-noconflict/snippets/ruby.js +1 -0
  162. data/server/public/src-min-noconflict/theme-twilight.js +1 -0
  163. data/server/public/src-min-noconflict/worker-coffee.js +1 -0
  164. data/server/public/src-min-noconflict/worker-css.js +1 -0
  165. data/server/public/src-min-noconflict/worker-javascript.js +1 -0
  166. data/server/public/src-min-noconflict/worker-json.js +1 -0
  167. data/server/public/src-min-noconflict/worker-lua.js +1 -0
  168. data/server/public/src-min-noconflict/worker-php.js +1 -0
  169. data/server/public/src-min-noconflict/worker-xquery.js +1 -0
  170. data/server/routes.rb +123 -0
  171. data/server/views/dsl.haml +65 -0
  172. data/server/views/dump.haml +3 -0
  173. data/server/views/import.haml +35 -0
  174. data/server/views/new_repository.haml +25 -0
  175. data/server/views/query.haml +28 -0
  176. data/server/views/repository.haml +25 -0
  177. data/spec/ORM/data_cube_orm_spec.rb +33 -0
  178. data/spec/ORM/prov_model_spec.rb +72 -0
  179. data/spec/analyzer_spec.rb +36 -0
  180. data/spec/bnode_spec.rb +66 -0
  181. data/spec/csv/bacon.csv +4 -0
  182. data/spec/csv/moar_bacon.csv +11 -0
  183. data/spec/data_cube_spec.rb +169 -0
  184. data/spec/dataset_for_spec.rb +77 -0
  185. data/spec/dsl_spec.rb +134 -0
  186. data/spec/generators/csv_spec.rb +44 -0
  187. data/spec/generators/dataframe_spec.rb +44 -0
  188. data/spec/generators/maf_spec.rb +40 -0
  189. data/spec/generators/r_cross_spec.rb +51 -0
  190. data/spec/generators/r_matrix_spec.rb +44 -0
  191. data/spec/length_lookup_spec.rb +0 -0
  192. data/spec/maf_query_spec.rb +343 -0
  193. data/spec/metadata/metadata_dsl_spec.rb +68 -0
  194. data/spec/prov/activity_spec.rb +74 -0
  195. data/spec/prov/agent_spec.rb +54 -0
  196. data/spec/prov/association_spec.rb +55 -0
  197. data/spec/prov/config_spec.rb +28 -0
  198. data/spec/prov/derivation_spec.rb +30 -0
  199. data/spec/prov/entity_spec.rb +52 -0
  200. data/spec/prov/role_spec.rb +94 -0
  201. data/spec/prov/usage_spec.rb +98 -0
  202. data/spec/queries/integrity/1.rq +21 -0
  203. data/spec/queries/integrity/11.rq +29 -0
  204. data/spec/queries/integrity/12.rq +37 -0
  205. data/spec/queries/integrity/14.rq +25 -0
  206. data/spec/queries/integrity/19_1.rq +21 -0
  207. data/spec/queries/integrity/19_2.rq +15 -0
  208. data/spec/queries/integrity/2.rq +22 -0
  209. data/spec/queries/integrity/3.rq +19 -0
  210. data/spec/queries/integrity/4.rq +13 -0
  211. data/spec/queries/integrity/5.rq +14 -0
  212. data/spec/r_builder_spec.rb +33 -0
  213. data/spec/resource/.RData +0 -0
  214. data/spec/resource/example.Rhistory +3 -0
  215. data/spec/spec_helper.rb +17 -0
  216. data/spec/turtle/bacon +147 -0
  217. data/spec/turtle/reference +2064 -0
  218. data/spec/turtle/weather +275 -0
  219. data/spec/writer_spec.rb +75 -0
  220. metadata +589 -0
@@ -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,10 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
4
+
5
+ SELECT DISTINCT ?dimension ?dimLabel ?codeList ?class WHERE{
6
+ ?dimension a qb:DimensionProperty;
7
+ rdfs:label ?dimLabel;
8
+ qb:codeList ?codeList;
9
+ rdfs:range ?class.
10
+ }
@@ -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 skos: <http://www.w3.org/2004/02/skos/core#>
4
+
5
+
6
+ SELECT DISTINCT ?dimension ?code ?codeLabel WHERE {
7
+ ?dim a qb:DimensionProperty;
8
+ rdfs:label ?dimension;
9
+ qb:codeList ?codes.
10
+
11
+ ?component qb:dimension ?dim.
12
+ ?dsd qb:component ?component.
13
+
14
+ ?dataSet qb:structure ?dsd.
15
+
16
+ ?codes skos:hasTopConcept ?code.
17
+ ?code skos:prefLabel ?codeLabel.
18
+ }
@@ -0,0 +1,7 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+
4
+ SELECT DISTINCT ?dataset ?label WHERE{
5
+ ?dataset a qb:DataSet;
6
+ rdfs:label ?label.
7
+ }
@@ -0,0 +1,8 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+
4
+ SELECT DISTINCT ?dimension ?range ?label WHERE {
5
+ ?dimension a qb:DimensionProperty;
6
+ rdfs:label ?label;
7
+ rdfs:range ?range.
8
+ }
@@ -0,0 +1,12 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+
4
+ SELECT DISTINCT ?dimension ?label WHERE{
5
+ ?dimension a qb:DimensionProperty;
6
+ rdfs:label ?label.
7
+
8
+ ?component qb:dimension ?dimension.
9
+ ?dsd qb:component ?component.
10
+
11
+ ?dataSet qb:structure ?dsd.
12
+ }
@@ -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,12 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+
4
+ SELECT DISTINCT ?measure ?label WHERE{
5
+ ?measure a qb:MeasureProperty;
6
+ rdfs:label ?label.
7
+
8
+ ?component qb:measure ?measure.
9
+ ?dsd qb:component ?component.
10
+
11
+ ?dataSet qb:structure ?dsd.
12
+ }
@@ -0,0 +1,8 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX prop: <http://www.rqtl.org/dc/properties/>
4
+
5
+ SELECT DISTINCT ?observation ?label WHERE{
6
+ ?observation a qb:Observation;
7
+ rdfs:label ?label.
8
+ }
@@ -0,0 +1,13 @@
1
+ PREFIX qb: <http://purl.org/linked-data/cube#>
2
+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3
+ PREFIX prop: <http://www.rqtl.org/dc/properties/>
4
+
5
+ SELECT DISTINCT ?observation ?property ?value WHERE{
6
+ ?observation a qb:Observation;
7
+ ?property ?value ;
8
+ qb:dataSet ?dataSet .
9
+
10
+ { ?property a qb:DimensionProperty. }
11
+ UNION
12
+ { ?property a qb:MeasureProperty. }
13
+ }
@@ -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,8 @@
1
+ SELECT DISTINCT ?comp ?label
2
+ WHERE {
3
+ {?comp a qb:MeasureProperty;
4
+ rdfs:label ?label.}
5
+ UNION
6
+ {?comp a qb:DimensionProperty;
7
+ rdfs:label ?label.}
8
+ }LIMIT 5
@@ -0,0 +1,3 @@
1
+ SELECT * WHERE{
2
+ ?s ?p ?o
3
+ }LIMIT 10
@@ -0,0 +1,28 @@
1
+ % 1. Title: Weather Database
2
+ %
3
+ % 2. Sources:
4
+ % (a) Generated from RDF source spec/turtle/weather
5
+ %
6
+ @RELATION weather
7
+
8
+ @ATTRIBUTE humidity integer
9
+ @ATTRIBUTE outlook {sunny, overcast, rainy}
10
+ @ATTRIBUTE play {no, yes}
11
+ @ATTRIBUTE temperature integer
12
+ @ATTRIBUTE windy {FALSE, TRUE}
13
+
14
+ @DATA
15
+ 85,sunny,no,85,FALSE
16
+ 90,sunny,no,80,TRUE
17
+ 86,overcast,yes,83,FALSE
18
+ 96,rainy,yes,70,FALSE
19
+ 80,rainy,yes,68,FALSE
20
+ 70,rainy,no,65,TRUE
21
+ 65,overcast,yes,64,TRUE
22
+ 95,sunny,no,72,FALSE
23
+ 70,sunny,yes,69,FALSE
24
+ 80,rainy,yes,75,FALSE
25
+ 70,sunny,yes,75,TRUE
26
+ 90,overcast,yes,72,TRUE
27
+ 75,overcast,yes,81,FALSE
28
+ 91,rainy,no,71,TRUE
@@ -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
+
@@ -0,0 +1,6 @@
1
+ load File.dirname(__FILE__) + '/../lib/bio-publisci.rb'
2
+
3
+ gen = PubliSci::Readers::RMatrix.new
4
+ con = Rserve::Connection.new
5
+ con.eval("load('#{ARGV[0] || './.RData'}')")
6
+ gen.generate_n3(con, "islet.mlratio", "pheno", {measures: ["probe","individual","pheno"], no_labels: true})
@@ -0,0 +1,6 @@
1
+ load File.dirname(__FILE__) + '/../lib/bio-publisci.rb'
2
+
3
+ gen = PubliSci::Readers::RMatrix.new
4
+ con = Rserve::Connection.new
5
+ con.eval("load('#{ARGV[0] || './.RData'}')")
6
+ gen.generate_n3(con, "scan.islet", "scan", {measures: ["probe","marker","lod"], no_labels: true})
@@ -0,0 +1,25 @@
1
+ puts "Really rewrite reference files? This could mess up the tests... [y/N]"
2
+ exit unless gets.chomp == 'y'
3
+
4
+ puts "overwriting #{File.absolute_path(File.dirname(__FILE__) + '/../spec/turtle/bacon')}"
5
+ load File.dirname(__FILE__) + '/../lib/bio-publisci.rb'
6
+
7
+ gen = PubliSci::Readers::CSV.new
8
+ turtle_string = gen.generate_n3(File.dirname(__FILE__) + '/../spec/csv/bacon.csv','bacon',{dimensions:["producer","pricerange"], label_column:0})
9
+ open(File.dirname(__FILE__) + '/../spec/turtle/bacon', 'w'){|f| f.write turtle_string}
10
+
11
+ rcon = Rserve::Connection.new
12
+ gen = PubliSci::Readers::Dataframe.new
13
+ rcon.void_eval <<-EOF
14
+ library(qtl)
15
+ data(listeria)
16
+ mr = scanone(listeria,method="mr")
17
+ EOF
18
+ rexp = rcon.eval 'mr'
19
+ turtle_string = gen.generate_n3(rexp,'mr')
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')}"
data/server/helpers.rb ADDED
@@ -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