DDBJ-KEGG-PDBj: pdb2rdf.xsl

File pdb2rdf.xsl, 5.6 KB (added by tore.eriksson, 14 years ago)

PDB2rdf sstylesheet v 0.4 - working prototype

Line 
1<xsl:stylesheet version="1.0"
2                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4                xmlns:pdbx="http://pdbj.protein.osaka-u.ac.jp/XML/pdbmlplus/pdbMLplus_v32.xsd"
5                xmlns:pdb="http://www.pdbj.org/ontology/pdb.owl#"
6                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
7                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8                xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
9                xmlns:ro="http://www.obofoundry.org/ro/ro.owl#"
10                xmlns:foaf="http://xmlns.com/foaf/0.1/"
11                xmlns:bibo="http://purl.org/ontology/bibo/"
12                xmlns:dc="http://purl.org/dc/elements/1.1/">
13  <xsl:output method="xml" indent="yes"/>
14
15  <xsl:template match="/">
16        <rdf:RDF>
17                <xsl:apply-templates/>
18        </rdf:RDF>
19  </xsl:template>
20   
21  <xsl:template match="pdbx:datablock">
22          <xsl:variable name="base" select="concat('http://www.pdbj.org/', translate(./pdbx:entryCategory/pdbx:entry/@id, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'))"/>
23          <pdb:Entry rdf:about="{$base}">
24                  <xsl:apply-templates select="pdbx:database_PDB_revCategory/pdbx:database_PDB_rev"/>
25                  <foaf:topic>
26                        <pdb:Structure>
27                                <xsl:apply-templates select="pdbx:entityCategory/pdbx:entity">
28                                        <xsl:with-param name="base" select="$base"/>
29                                </xsl:apply-templates>
30                                <xsl:apply-templates select="pdbx:citationCategory/pdbx:citation"/>
31                        </pdb:Structure>
32                </foaf:topic>
33        </pdb:Entry>
34  </xsl:template>
35
36  <xsl:template match="pdbx:entity">
37          <xsl:param name="base"/>
38          <xsl:variable name="id" select="@id"/>
39          <ro:contains>
40                <xsl:element name="{pdbx:type}" namespace="http://www.pdbj.org/ontology/pdb.owl#">
41                        <xsl:attribute name="rdf:about"><xsl:value-of select="concat($base, '#', $id)"/></xsl:attribute>
42                        <xsl:apply-templates select="pdbx:pdbx_description"/>
43                        <xsl:apply-templates select="/pdbx:datablock/pdbx:entity_src_genCategory/pdbx:entity_src_gen[@entity_id=$id]"/>
44                        <xsl:apply-templates select="/pdbx:datablock/pdbx:struct_refCategory/pdbx:struct_ref[@id=$id]"/>
45                        <xsl:apply-templates select="/pdbx:datablock/pdbx:entity_src_genCategory/pdbx:entity_src_gen[@entity_id=$id]/pdbx:pdbx_gene_src_ncbi_taxonomy_id"/>
46                </xsl:element>
47          </ro:contains>
48  </xsl:template>
49
50  <xsl:template match="pdbx:struct_ref[pdbx:db_name='UNP']">
51          <rdfs:seeAlso rdf:resource="http://purl.uniprot.org/uniprot/{pdbx:pdbx_db_accession}"/>
52  </xsl:template>
53
54  <xsl:template match="pdbx:entity_src_gen">
55          <ro:derived-from>
56                  <pdb:Gene>
57                          <xsl:apply-templates/>
58                  </pdb:Gene>
59          </ro:derived-from>
60        <xsl:apply-templates mode="source"/>
61  </xsl:template>
62
63  <xsl:template match="pdbx:pdbx_description[not(@xsi:nil)]">
64          <rdfs:comment>
65                  <xsl:value-of select="."/>
66          </rdfs:comment>
67  </xsl:template>
68
69  <xsl:template match="pdbx:pdbx_gene_src_gene[not(@xsi:nil)]|pdbx:title[not(@xsi:nil)]">
70          <rdfs:label>
71                  <xsl:value-of select="."/>
72          </rdfs:label>
73  </xsl:template>
74
75  <xsl:template match="pdbx:pdbx_gene_src_scientific_name[not(@xsi:nil)]|pdbx:gene_src_common_name[not(@xsi:nil)]" mode="org">
76          <rdfs:label>
77                  <xsl:value-of select="."/>
78          </rdfs:label>
79  </xsl:template>
80
81  <xsl:template match="pdbx:pdbx_gene_src_organ[not(@xsi:nil)]" mode="source">
82          <ro:derived_from>
83                  <pdb:Organ>
84                          <rdfs:label>
85                                  <xsl:value-of select="."/>
86                          </rdfs:label>
87                  </pdb:Organ>
88          </ro:derived_from>
89  </xsl:template>
90
91  <xsl:template match="pdbx:pdbx_gene_src_cell_line[not(@xsi:nil)]" mode="source">
92          <ro:derived_from>
93                  <pdb:CellLine>
94                          <rdfs:label>
95                                  <xsl:value-of select="."/>
96                          </rdfs:label>
97                  </pdb:CellLine>
98          </ro:derived_from>
99  </xsl:template>
100
101  <xsl:template match="pdbx:pdbx_gene_src_cell[not(@xsi:nil)]" mode="source">
102          <ro:derived_from>
103                  <pdb:Cell>
104                          <rdfs:label>
105                                  <xsl:value-of select="."/>
106                          </rdfs:label>
107                  </pdb:Cell>
108          </ro:derived_from>
109  </xsl:template>
110
111  <!-- Set this as main URI instead
112  <xsl:template match="pdbx:pdbx_database_id_DOI[not(@xsi:nil)]">
113          <rdfs:sameAs rdf:resource="urn:doi:{.}"/>
114  </xsl:template>
115  -->
116
117  <xsl:template match="pdbx:database_PDB_rev[1]">
118          <dc:created>
119                  <xsl:value-of select="pdbx:date_original"/>
120          </dc:created>
121          <xsl:if test="position()=last() and not(pdbx:date/@xsi:nil)">
122                <dc:modified>
123                        <xsl:value-of select="pdbx:date"/>
124                </dc:modified>
125        </xsl:if>
126  </xsl:template>
127
128  <xsl:template match="pdbx:database_PDB_rev[last()]">
129          <dc:modified>
130                  <xsl:value-of select="pdbx:date"/>
131          </dc:modified>
132  </xsl:template>
133
134  <xsl:template match="pdbx:pdbx_gene_src_ncbi_taxonomy_id">
135          <ro:derived-from>
136                  <rdf:Resource rdf:about="http://www.ncbi.nlm.nih.gov/taxonomy/{.}">
137                          <xsl:apply-templates select="../pdbx:pdbx_gene_src_scientific_name|../pdbx:gene_src_common_name" mode="org"/>
138                  </rdf:Resource>
139          </ro:derived-from>
140  </xsl:template>
141
142  <!-- Should check for not xsi:nil value -->
143  <xsl:template match="pdbx:citation[@id='primary']">
144          <foaf:page>
145                  <bibo:AcademicArticle>
146                          <xsl:if test="pdbx:pdbx_database_id_DOI[not(@xsi:nil)]">
147                                  <xsl:attribute name="rdf:about">
148                                          <xsl:text>urn:doi:</xsl:text>
149                                          <xsl:value-of select="pdbx:pdbx_database_id_DOI"/>
150                                  </xsl:attribute>
151                          </xsl:if>
152                          <rdfs:seeAlso rdf:resource="http://ncbi.nlm.nih.gov/pubmed/{pdbx:pdbx_database_id_PubMed}"/>
153                         <xsl:apply-templates/>
154                  </bibo:AcademicArticle>
155          </foaf:page>
156  </xsl:template>
157
158  <xsl:template match="*"/>
159  <xsl:template match="text()"/>
160  <xsl:template match="text()" mode="source"/>
161</xsl:stylesheet>