#! /usr/bin/env guile
!#
(use-modules (srfi srfi-1)
(srfi srfi-26)
(ice-9 match)
(ice-9 regex)
(dump strings)
(dump sql)
(dump triples)
(dump special-forms))
(define %connection-settings
(call-with-input-file (list-ref (command-line) 1)
read))
(define %dump-directory
(list-ref (command-line) 2))
(define-dump dump-probeset
(tables (ProbeSet
(left-join GeneChip "ON GeneChip.Id = ProbeSet.ChipId")))
(schema-triples
(gn:name rdfs:range rdfs:Literal)
(gn:probeset rdfs:range rdfs:Literal))
(triples (ontology
'probeset:
(regexp-substitute/global
#f "[^A-Za-z0-9:]"
(field ("IFNULL(ProbeSet.Name, ProbeSet.Id)"
name))
'pre "_" 'post))
(set rdf:type 'gn:probeset)
(set gn:chipOf (string->identifier "platform" (field GeneChip Name)))
(set gn:name (field ProbeSet Name))
(set gn:symbol (field ProbeSet Symbol))
(set gn:description (sanitize-rdf-string
(field ProbeSet description)))
(set gn:chr (field ProbeSet Chr))
(set gn:mb (annotate-field (field ("IFNULL(ProbeSet.Mb, '')" Mb)) '^^xsd:double))
(multiset gn:tissue (map string-trim-both
(string-split
(field ("IFNULL(ProbeSet.Tissue, '')" Tissue))
#\,)))
(multiset gn:alias (map string-trim-both
(string-split (sanitize-rdf-string (field ProbeSet alias))
#\;)))
(set gn:unigene (field ProbeSet UniGeneId))
(set gn:generif (ontology 'generif: (field ProbeSet GeneId)))
(set gn:genbank (field ProbeSet GenbankId))
(set gn:blatSeq (sanitize-rdf-string
(string-trim-both (field ProbeSet BlatSeq))))
(set gn:targetSeq (sanitize-rdf-string (field ProbeSet TargetSeq)))
(set gn:omim (sanitize-rdf-string (string-trim-both (field ProbeSet OMIM))))
(set gn:RefSeq_TranscriptId (field ProbeSet RefSeq_TranscriptId))
(set gn:uniProtReference (ontology 'uniprot:
(field ProbeSet UniProtID)))))
(call-with-target-database
%connection-settings
(lambda (db)
(with-output-to-file (string-append %dump-directory "dump-probeset.ttl")
(lambda ()
(prefix "dct:" "")
(prefix "foaf:" "")
(prefix "generif:" "")
(prefix "gn:" "")
(prefix "owl:" "")
(prefix "phenotype:" "")
(prefix "pubmed:" "")
(prefix "rdf:" "")
(prefix "rdfs:" "")
(prefix "uniprot:" "")
(prefix "up:" "")
(prefix "xsd:" "")
(prefix "probeset:" "")
(newline)
(dump-probeset db))
#:encoding "utf8")))