From 222019fa2f85f2d63f3fd733edbe691b8d37bf4d Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 23 May 2023 15:11:58 +0300 Subject: Add genotype dump * examples/dump-genotype.scm: New dump for genotypes and their associated datasets(that were not dumped from the info-files table). Signed-off-by: Munyoki Kilyungi --- examples/dump-genotype.scm | 122 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100755 examples/dump-genotype.scm diff --git a/examples/dump-genotype.scm b/examples/dump-genotype.scm new file mode 100755 index 0000000..13e4885 --- /dev/null +++ b/examples/dump-genotype.scm @@ -0,0 +1,122 @@ +#! /usr/bin/env guile +!# + +(use-modules (rnrs programs) + (rnrs io ports) + (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-genofreeze + (tables (GenoFreeze + (left-join InfoFiles "ON InfoFiles.InfoPageName = GenoFreeze.Name") + (left-join InbredSet "ON GenoFreeze.InbredSetId = InbredSet.InbredSetId")) + "WHERE GenoFreeze.public > 0 AND InfoFiles.InfoPageName IS NULL") + (schema-triples + (gn:datasetOfInbredSet rdfs:range gn:inbredSet) + (gn:genotypeDataset rdfs:subPropertyOf gn:dataset) + (gn:shortName rdfs:range rdfs:Literal)) + (triples (ontology + 'dataset: + (regexp-substitute/global + #f "[^A-Za-z0-9:]" + (field GenoFreeze Name) + 'pre "_" 'post)) + (set rdf:type 'gn:genotypeDataset) + (set gn:name (field GenoFreeze Name)) + (set gn:fullName (field GenoFreeze FullName)) + (set gn:shortName (field GenoFreeze ShortName)) + (set dct:created (annotate-field + (field GenoFreeze CreateTime) + '^^xsd:date)) + (set gn:datasetOfInbredSet + (string->identifier "inbredSet" (field InbredSet Name InbredSetName))))) + +(define-dump dump-genotypes + (tables (Geno + (left-join GenoXRef "ON Geno.Id = GenoXRef.GenoId") + (left-join GenoFreeze "ON GenoFreeze.Id = GenoXRef.GenoFreezeId") + (left-join InfoFiles "ON InfoFiles.InfoPageName = GenoFreeze.Name"))) + (schema-triples + (gn:genotypeDataset rdfs:subPropertyOf gn:dataset)) + (triples + (ontology + 'genotype: + (regexp-substitute/global + #f "[^A-Za-z0-9:]" + (field ("CONCAT(IF(GenoFreeze.Name IS NULL, '', CONCAT(GenoFreeze.Name, ':')), Geno.Name)" abbrev)) + 'pre "_" 'post)) + (set rdf:type 'gn:genotype) + (set gn:name (sanitize-rdf-string (field Geno Name))) + (set gn:markerName (sanitize-rdf-string (field Geno Marker_Name))) + (set gn:chr (field Geno Chr)) + (set gn:mb (annotate-field (field ("IFNULL(Geno.Mb, '')" Mb)) '^^xsd:double)) + (set gn:sequence (annotate-field (field Geno Sequence) '^^xsd:int)) + (set gn:source (field Geno Source)) + (set gn:source2 (field Geno Source2)) + (set gn:genotypeOfDataset + (ontology 'dataset: + (regexp-substitute/global + #f "[^A-Za-z0-9:]" + (field GenoFreeze Name) + 'pre "_" 'post))) + (set gn:chrNum + (annotate-field + (field ("IFNULL(Geno.chr_num, '')" chr_num)) + '^^xsd:int)) + (set gn:comments (field ("CAST(CONVERT(BINARY CONVERT(Geno.Comments USING latin1) USING utf8) AS VARCHAR(255))" Comments))) + (set gn:cM + (annotate-field + (field ("IFNULL(GenoXRef.cM, '')" Chr_mm8)) + '^^xsd:int)))) + + + +(call-with-target-database + %connection-settings + (lambda (db) + (with-output-to-file (string-append %dump-directory "dump-genotype.ttl") + (lambda () + (prefix "chebi:" "") + (prefix "dct:" "") + (prefix "foaf:" "") + (prefix "generif:" "") + (prefix "gn:" "") + (prefix "hgnc:" "") + (prefix "homologene:" "") + (prefix "kegg:" "") + (prefix "molecularTrait:" "") + (prefix "nuccore:" "") + (prefix "omim:" "") + (prefix "owl:" "") + (prefix "phenotype:" "") + (prefix "pubchem:" "") + (prefix "pubmed:" "") + (prefix "rdf:" "") + (prefix "rdfs:" "") + (prefix "taxon:" "") + (prefix "uniprot:" "") + (prefix "up:" "") + (prefix "xsd:" "") + (prefix "genotype:" "") + (prefix "dataset:" "") + (newline) + (dump-genofreeze db) + (dump-genotypes db)) + #:encoding "utf8"))) -- cgit v1.2.3