about summary refs log tree commit diff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/probesets.scm123
1 files changed, 123 insertions, 0 deletions
diff --git a/examples/probesets.scm b/examples/probesets.scm
new file mode 100755
index 0000000..1bbfec8
--- /dev/null
+++ b/examples/probesets.scm
@@ -0,0 +1,123 @@
+#! /usr/bin/env guile
+!#
+
+(use-modules (srfi srfi-1)
+             (srfi srfi-26)
+             (ice-9 getopt-long)
+             (ice-9 match)
+             (ice-9 regex)
+             (transform strings)
+             (transform sql)
+             (transform triples)
+             (transform special-forms))
+
+(define-transformer probeset->metadata
+  (tables (ProbeSet
+           (left-join GeneChip "ON GeneChip.Id = ProbeSet.ChipId"))
+          "WHERE ProbeSet.Name IS NOT NULL AND TRIM(ProbeSet.Name) != ''")
+  (triples
+      (string->identifier "probeset" (field ProbeSet Name))
+    (set rdf:type 'gnc:probeset)
+    (set skos:prefLabel (field ProbeSet Name))
+    (set skos:altLabel (sanitize-rdf-string (field ProbeSet alias)))
+    (set gnt:uses_genechip (string->identifier "platform" (field GeneChip Name) #:separator "_"))
+    (set gnt:has_target_id
+         (field ("NULLIF(TRIM(ProbeSet.TargetId), '')"
+                 TargetId)))
+    (set gnt:symbol (field ProbeSet Symbol))
+    (set dct:description (sanitize-rdf-string (field ProbeSet description)))
+    (set gnt:targets_region
+         (sanitize-rdf-string
+          (field ("NULLIF(TRIM(ProbeSet.Probe_set_target_region), '')"
+                  Probe_set_target_region))))
+    (set gnt:chr (field ProbeSet Chr))
+    (set gnt:mb (annotate-field (field ("IFNULL(ProbeSet.Mb, '')" Mb)) '^^xsd:double))
+    (set gnt:mb_mm8 (annotate-field (field ("IFNULL(ProbeSet.Mb_mm8, '')" Mb_mm8))
+                                    '^^xsd:double))
+    (set gnt:has_specificity
+         (field ("IFNULL(ProbeSet.Probe_set_specificity, '')"
+                 Probe_set_specificity)))
+    (set gnt:has_blat_score
+         (field ("IFNULL(ProbeSet.Probe_set_BLAT_score, '')"
+                 Probe_set_BLAT_score)))
+    (set gnt:has_blat_mb_start
+         (annotate-field (field ("IFNULL(ProbeSet.Probe_set_Blat_Mb_start, '')"
+                                 Probe_set_Blat_Mb_start))
+                         '^^xsd:double))
+    (set gnt:has_blat_mb_end
+         (annotate-field (field ("IFNULL(ProbeSet.Probe_set_Blat_Mb_end, '')"
+                                 Probe_set_Blat_Mb_end))
+                         '^^xsd:double))
+    (set gnt:has_blat_seq (sanitize-rdf-string (field ProbeSet BlatSeq)))
+    (set gnt:has_target_seq (sanitize-rdf-string (field ProbeSet TargetSeq)))
+    (set gnt:has_homologene_id (ontology 'homologene:
+                                         (field ("IFNULL(ProbeSet.HomoloGeneID, '')"
+                                                 HomoloGeneID))))
+    (set gnt:has_uniprot_id (ontology 'uniprot:
+                                      (field ("IFNULL(ProbeSet.UniProtID, '')"
+                                              UniProtID))))
+    (set gnt:has_pub_chem_id (ontology
+                              'pubchem:
+                              (field ("IFNULL(ProbeSet.PubChem_ID, '')"
+                                      PubChem_ID))))
+    (set gnt:has_kegg_id (ontology
+                          'kegg:
+                          (field ("IFNULL(ProbeSet.KEGG_ID, '')"
+                                  KEGG_ID))))
+    (set gnt:has_omim_id (ontology
+                          'omim:
+                          (let ((omim (field ("IFNULL(ProbeSet.OMIM, '')"
+                                              OMIM))))
+                            (if (number? omim)
+                                omim
+                                (regexp-substitute/global
+                                 #f "[^0-9]"
+                                 omim
+                                 'pre "" 'post)))))
+    (set gnt:has_chebi_id (ontology
+                         'chebi:
+                         (field ("IFNULL(ProbeSet.ChEBI_ID, '')"
+                                 ChEBI_ID))))))
+
+
+
+
+(let* ((option-spec
+        '((settings (single-char #\s) (value #t))
+          (output (single-char #\o) (value #t))
+          (documentation (single-char #\d) (value #t))))
+       (options (getopt-long (command-line) option-spec))
+       (settings (option-ref options 'settings #f))
+       (output (option-ref options 'output #f))
+       (documentation (option-ref options 'documentation #f))
+       (%connection-settings
+        (call-with-input-file settings
+          read)))
+  (with-documentation
+   (name "ProbeSet Metadata")
+   (connection %connection-settings)
+   (table-metadata? #f)
+   (prefixes
+    '(("gn:" "<http://genenetwork.org/id/>")
+      ("probeset:" "<http://genenetwork.org/probeset/>")
+      ("gnc:" "<http://genenetwork.org/category/>")
+      ("gnt:" "<http://genenetwork.org/term/>")
+      ("rdf:" "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>")
+      ("kegg:" "<http://bio2rdf.org/ns/kegg#>")
+      ("pubchem:" "<https://pubchem.ncbi.nlm.nih.gov/>")
+      ("omim:" "<https://www.omim.org/entry/>")
+      ("rdfs:" "<http://www.w3.org/2000/01/rdf-schema#>")
+      ("uniprot:" "<http://purl.uniprot.org/uniprot/>")
+      ("chebi:" "<http://purl.obolibrary.org/obo/CHEBI_>")
+      ("dct:" "<http://purl.org/dc/terms/>")
+      ("owl:" "<http://www.w3.org/2002/07/owl#>")
+      ("homologene:" "<https://bio2rdf.org/homologene:>")
+      ("xsd:" "<http://www.w3.org/2001/XMLSchema#>")
+      ("qb:" "<http://purl.org/linked-data/cube#>")
+      ("sdmx-measure:" "<http://purl.org/linked-data/sdmx/2009/measure#>")
+      ("skos:" "<http://www.w3.org/2004/02/skos/core#>")))
+   (inputs
+    (list probeset->metadata))
+   (outputs
+    `(#:documentation ,documentation
+      #:rdf ,output))))