diff options
author | Munyoki Kilyungi | 2023-05-15 21:20:50 +0300 |
---|---|---|
committer | BonfaceKilz | 2023-05-26 08:40:22 +0300 |
commit | afaa6b096ec0df7055faafbe7f89917f734b3897 (patch) | |
tree | 2c16dc1550468018e14bd4407b5344f895b90331 /examples/dump-publication.scm | |
parent | 79975a5dc78daa03b43d37b3fe636265c148abc0 (diff) | |
download | gn-transform-databases-afaa6b096ec0df7055faafbe7f89917f734b3897.tar.gz |
Replace dump.scm with separete dumps for several tables
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'examples/dump-publication.scm')
-rwxr-xr-x | examples/dump-publication.scm | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/examples/dump-publication.scm b/examples/dump-publication.scm new file mode 100755 index 0000000..bed957a --- /dev/null +++ b/examples/dump-publication.scm @@ -0,0 +1,90 @@ +#! /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-publication + (tables (Publication)) + (schema-triples + (gn:pubMedId rdfs:range rdfs:Literal) + (gn:title rdfs:range rdfs:Literal) + (gn:journal rdfs:range rdfs:Literal) + (gn:volume rdfs:range rdfs:Literal) + (gn:pages rdfs:range rdfs:Literal) + (gn:month rdfs:range rdfs:Literal) + (gn:year rdfs:range rdfs:Literal) + (gn:author rdfs:range rdfs:Literal) + (gn:abstract rdfs:range rdfs:Literal)) + (triples + (let ((pmid (field + ("IF(Publication.PubMed_ID IS NULL, '', CONVERT(Publication.PubMed_Id, INT))" + pmid))) + (publication-id (field Publication Id))) + (if (string-null? pmid) + (string->identifier "publication" + (number->string publication-id)) + (ontology 'pubmed: pmid))) + (set rdf:type 'gn:publication) + (set gn:pubMedId (field ("IFNULL(PubMed_ID, '')" pubmedId))) + (set gn:title (field Publication Title)) + (set gn:journal (field Publication Journal)) + (set gn:volume (field Publication Volume)) + (set gn:pages (field Publication Pages)) + (set gn:month (field Publication Month)) + (set gn:year (field Publication Year)) + (multiset gn:author + ;; The authors field is a comma + ;; separated list. Split it. + (map string-trim (string-split (sanitize-rdf-string (field Publication Authors)) #\,))) + (set gn:abstract + (sanitize-rdf-string (field Publication Abstract))))) + + + +(call-with-target-database + %connection-settings + (lambda (db) + (with-output-to-file (string-append %dump-directory "dump-publication.ttl") + (lambda () + (prefix "chebi:" "<http://purl.obolibrary.org/obo/CHEBI_>") + (prefix "dct:" "<http://purl.org/dc/terms/>") + (prefix "foaf:" "<http://xmlns.com/foaf/0.1/>") + (prefix "generif:" "<http://www.ncbi.nlm.nih.gov/gene?cmd=Retrieve&dopt=Graphics&list_uids=>") + (prefix "gn:" "<http://genenetwork.org/>") + (prefix "hgnc:" "<http://bio2rdf.org/hgnc:>") + (prefix "homologene:" "<https://bio2rdf.org/homologene:>") + (prefix "kegg:" "<http://bio2rdf.org/ns/kegg#>") + (prefix "molecularTrait:" "<http://genenetwork.org/molecular-trait/>") + (prefix "nuccore:" "<https://www.ncbi.nlm.nih.gov/nuccore/>") + (prefix "omim:" "<https://www.omim.org/entry/>") + (prefix "owl:" "<http://www.w3.org/2002/07/owl#>") + (prefix "phenotype:" "<http://genenetwork.org/phenotype/>") + (prefix "pubchem:" "<https://pubchem.ncbi.nlm.nih.gov/>") + (prefix "pubmed:" "<http://rdf.ncbi.nlm.nih.gov/pubmed/>") + (prefix "rdf:" "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>") + (prefix "rdfs:" "<http://www.w3.org/2000/01/rdf-schema#>") + (prefix "taxon:" "<http://purl.uniprot.org/taxonomy/>") + (prefix "uniprot:" "<http://purl.uniprot.org/uniprot/>") + (prefix "up:" "<http://purl.uniprot.org/core/>") + (prefix "xsd:" "<http://www.w3.org/2001/XMLSchema#>") + (newline) + (dump-publication db)) + #:encoding "utf8"))) |