about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xexamples/phenotype.scm54
1 files changed, 51 insertions, 3 deletions
diff --git a/examples/phenotype.scm b/examples/phenotype.scm
index d3ef4ba..af47b51 100755
--- a/examples/phenotype.scm
+++ b/examples/phenotype.scm
@@ -12,8 +12,55 @@
              (transform sql)
              (transform triples)
              (transform special-forms))
+
+(define (blank-p str)
+  (if (string-blank? str) #f str))
 
 
+(define-transformer gnc:phenotype->gn:phenotype
+  (tables (Phenotype))
+  (triples "gnc:phenotype"
+    (set skos:member
+         (let ((post-abbrev (blank-p (field Phenotype Post_publication_abbreviation)))
+               (pre-abbrev (blank-p (field Phenotype Pre_publication_abbreviation)))
+               (post-desc (blank-p (field Phenotype Post_publication_description)))
+               (pre-desc (blank-p (field Phenotype Post_publication_description))))
+           (string->identifier
+            "phenotype"
+            (or post-abbrev pre-abbrev post-desc pre-desc)
+            #:separator "_")))))
+
+(define-transformer gn:phenotype->metadata
+  (tables (Phenotype))
+  (triples (let ((post-abbrev (blank-p (field Phenotype Post_publication_abbreviation)))
+                 (pre-abbrev (blank-p (field Phenotype Pre_publication_abbreviation)))
+                 (post-desc (blank-p (field Phenotype Post_publication_description)))
+                 (pre-desc (blank-p (field Phenotype Post_publication_description))))
+             (string->identifier
+              "phenotype"
+              (or post-abbrev pre-abbrev post-desc pre-desc)
+              #:separator "_"))
+    (set rdf:type 'gnc:phenotype)
+    ;; All phenotypes have a post-publication description
+    (set dct:description
+         (sanitize-rdf-string
+          (field Phenotype Post_publication_description)))
+    ;; All phenotypes have a post-publication abbreviation
+    (set gnt:abbreviation (sanitize-rdf-string (field Phenotype Post_publication_abbreviation)))
+    (set gnt:has_lab_code (field Phenotype Lab_code))
+    (set gnt:submitter
+         (sanitize-rdf-string (field Phenotype Submitter)))
+    (set dct:contributor (sanitize-rdf-string (field Phenotype Owner)))
+    (set skos:member
+         (let ((post-abbrev (blank-p (field Phenotype Post_publication_abbreviation)))
+               (pre-abbrev (blank-p (field Phenotype Pre_publication_abbreviation)))
+               (post-desc (blank-p (field Phenotype Post_publication_description)))
+               (pre-desc (blank-p (field Phenotype Post_publication_description))))
+           (string->identifier
+            "phenotype"
+            (or post-abbrev pre-abbrev post-desc pre-desc)
+            #:separator "_")))))
+
 (define-transformer phenotypes
   (tables (PublishXRef
            (left-join InbredSet "ON InbredSet.InbredSetId = PublishXRef.InbredSetId")
@@ -52,8 +99,8 @@
                                   '^^xsd:double))
     (set gnt:locus (sanitize-rdf-string (field PublishXRef Locus)))
     (set gnt:lod_score (annotate-field
-                  (field ("IFNULL((PublishXRef.LRS/4.604), '')" lrs))
-                  '^^xsd:double))
+                        (field ("IFNULL((PublishXRef.LRS/4.604), '')" lrs))
+                        '^^xsd:double))
     (set gnt:additive
          (annotate-field (field ("IFNULL(PublishXRef.additive, '')" additive))
                          '^^xsd:double))
@@ -101,7 +148,8 @@
       ("pubmed:" "<http://rdf.ncbi.nlm.nih.gov/pubmed/>")))
    (inputs
     (list
-     phenotypes))
+     gnc:phenotype->gn:phenotype
+     gn:phenotype->metadata))
    (outputs
     `(#:documentation ,documentation
       #:rdf ,output))))