about summary refs log tree commit diff
#! /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))


#!

The ProbeData table contains StrainID.

MariaDB [db_webqtl]> select * from ProbeData limit 2;
+--------+----------+---------+
| Id     | StrainId | value   |
+--------+----------+---------+
| 503636 |       42 | 11.6906 |
| 503636 |       43 | 11.4205 |
+--------+----------+---------+

Likewise

MariaDB [db_webqtl]> select * from ProbeSetData wher limit 2;
+----+----------+-------+
| Id | StrainId | value |
+----+----------+-------+
|  1 |        1 | 5.742 |
|  1 |        2 | 5.006 |
+----+----------+-------+

To get at the strain use

MariaDB [db_webqtl]> select * from Strain where Id=1 limit 15;
+----+--------+--------+-----------+--------+-------+
| Id | Name   | Name2  | SpeciesId | Symbol | Alias |
+----+--------+--------+-----------+--------+-------+
|  1 | B6D2F1 | B6D2F1 |         1 | NULL   | NULL  |
+----+--------+--------+-----------+--------+-------+

A typical query may look like

SELECT Strain.Name, Strain.Id FROM Strain, Species
WHERE Strain.Name IN f{create_in_clause(self.samplelist)}
AND Strain.SpeciesId=Species.Id
AND Species.name = %s, (self.group.species,)

At this point it is not very clear how Name, Name2, Symbol and Alias are used.

!#

(define-transformer strain
  (tables (Strain
           (left-join Species "ON Strain.SpeciesId = Species.SpeciesId")))
  (schema-triples
   (gnt:alias rdfs:domain gnc:strain)
   (gnt:alias a owl:ObjectProperty)
   (gnt:gene_symbol rdfs:domain gnc:strain)
   (gnt:gene_symbol a owl:ObjectProperty))
  (triples (string->identifier
            "strain"
            (field Strain Name)
            #:separator "_")
    (set rdf:type 'gnc:strain)
    (set gnt:has_species (string->identifier "" (remap-species-identifiers (field Species Fullname))))
    ;; Name, and maybe a second name
    (set rdfs:label (sanitize-rdf-string (field Strain Name)))
    (set skos:altLabel (sanitize-rdf-string (field ("IF ((Strain.Name2 != Strain.Name), Strain.Name2, '')" Name2))))
    (set gnt:alias (sanitize-rdf-string (field ("IF ((Strain.Alias != Strain.Name), Strain.Alias, '')" Alias))))
    (set gnt:gene_symbol (field Strain Symbol))))

(define-transformer mapping-method
  (tables (MappingMethod))
  (schema-triples
   (gnc:mapping_method a skos:ConceptScheme)
   (gnc:mapping_method skos:prefLabel "Mapping Method Vocabulary")
   (gnc:mapping_method skos:definition "Controlled vocabulary describing statistical/computational methods used for mapping in GeneNetwork."))
  (triples
      (string->identifier "mapping_method" (field MappingMethod Name) #:separator "_")
    (set rdf:type 'skos:Concept)
    (set skos:inScheme 'gnc:mapping_method)
    (set skos:prefLabel (field MappingMethod Name))))

(define-transformer mapping-method-fan-out
  (tables (MappingMethod))
  (triples
      'gnc:mapping_method
    (set skos:member (string->identifier "mapping_method" (field MappingMethod Name) #:separator "_"))))

(define-transformer avg-method-fan-out
  (tables (AvgMethod))
  (triples
      'gnc:avg_method
    (set skos:member (string->identifier "avg_method" (field AvgMethod Name AvgMethodName) #:separator "_"))))

(define-transformer avg-method
  ;; The Name and Normalization fields seem to be the same. Dump only
  ;; the Name field.
  (tables (AvgMethod))
  (schema-triples
   (gnc:avg_method a skos:ConceptScheme)
   (gnc:avg_method skos:prefLabel "Normalization and Averaging Method Vocabulary")
   (gnc:avg_method skos:definition "Controlled vocabulary describing normalization, transformation, and summarization methods applied in GeneNetwork."))
  (triples (string->identifier "avg_method" (field AvgMethod Name AvgMethodName) #:separator "_")
    (set rdf:type 'skos:Concept)
    (set skos:inScheme 'gnc:avg_method)
    (set skos:prefLabel (field AvgMethod Normalization))))



(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 "Strain Metadata")
   (connection %connection-settings)
   (table-metadata? #f)
   (prefixes
    '(("gn:" "<http://rdf.genenetwork.org/v1/id/>")
      ("gnc:" "<http://rdf.genenetwork.org/v1/category/>")
      ("owl:" "<http://www.w3.org/2002/07/owl#>")
      ("gnt:" "<http://rdf.genenetwork.org/v1/term/>")
      ("skos:" "<http://www.w3.org/2004/02/skos/core#>")
      ("xkos:" "<http://rdf-vocabulary.ddialliance.org/xkos#>")
      ("rdf:" "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>")
      ("rdfs:" "<http://www.w3.org/2000/01/rdf-schema#>")
      ("taxon:" "<http://purl.uniprot.org/taxonomy/>")))
   (inputs
    (list strain mapping-method avg-method mapping-method-fan-out avg-method-fan-out))
   (outputs
    `(#:documentation ,documentation
      #:rdf ,output))))