My favorites
▼
|
Sign in
code915
My code for INSERM UMR915
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
core
/
src
/
xsl
/
xvcf2vcf.xsl
‹r85
r463
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?xml version='1.0' encoding="ISO-8859-1"?>
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:vcf="http://www.umr915.univ-nantes.fr/vcf/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"
version='1.0'
>
<!--
Author:
Pierre lindenbaum PhD
www:
http://plindenbaum.blogspot.com
Motivation:
transform a VCF-XML file to a standard VCF file
VCF format:
http://www.1000genomes.org/wiki/doku.php?id=1000_genomes%3aanalysis%3avcf3.3
See also:
http://plindenbaum.blogspot.com/2010/05/first-rule-of-bioinfo-club.html
-->
<xsl:output method='text' encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates select="vcf:vcf"/>
</xsl:template>
<xsl:template match="vcf:vcf">
<xsl:apply-templates select="vcf:header"/>
<xsl:apply-templates select="vcf:body"/>
</xsl:template>
<xsl:template match="vcf:header">
<xsl:apply-templates select="vcf:fileformat"/>
<xsl:apply-templates select="vcf:infos"/>
<xsl:apply-templates select="vcf:formats"/>
<xsl:apply-templates select="vcf:metas"/>
<xsl:apply-templates select="vcf:columns"/>
</xsl:template>
<xsl:template match="vcf:fileformat">
<xsl:text>##fileformat=</xsl:text>
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="vcf:formats">
<xsl:for-each select="vcf:format">
<xsl:text>##FORMAT=</xsl:text>
<xsl:value-of select="vcf:id"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="vcf:count"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="vcf:type"/>
<xsl:text>,"</xsl:text>
<xsl:value-of select="vcf:desc"/>
<xsl:text>"
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="vcf:infos">
<xsl:for-each select="vcf:info">
<xsl:text>##INFO=</xsl:text>
<xsl:value-of select="vcf:id"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="vcf:count"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="vcf:type"/>
<xsl:text>,"</xsl:text>
<xsl:value-of select="vcf:desc"/>
<xsl:text>"
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="vcf:metas">
<xsl:for-each select="vcf:meta">
<xsl:text>##</xsl:text>
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template match="vcf:columns">
<xsl:for-each select="vcf:column">
<xsl:choose>
<xsl:when test="position()!=1">
<xsl:text> </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>#</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="."/>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="vcf:body">
<xsl:apply-templates select="vcf:variant"/>
</xsl:template>
<xsl:template match="vcf:variant">
<xsl:value-of select="vcf:chromosome"/>
<xsl:text> </xsl:text>
<xsl:value-of select="vcf:position"/>
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="vcf:id">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:text>.</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<xsl:value-of select="vcf:ref"/>
<xsl:text> </xsl:text>
<xsl:value-of select="vcf:alt"/>
<xsl:text> </xsl:text>
<xsl:value-of select="vcf:quality"/>
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="vcf:filter">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:text>.</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<xsl:apply-templates select="vcf:info" mode="body"/>
<xsl:text> </xsl:text>
<xsl:for-each select="vcf:call[1]/*">
<xsl:if test="position()!=1">
<xsl:text>:</xsl:text>
</xsl:if>
<xsl:value-of select="local-name(.)"/>
</xsl:for-each>
<xsl:for-each select="vcf:call">
<xsl:text> </xsl:text>
<xsl:for-each select="*">
<xsl:if test="position()!=1">
<xsl:text>:</xsl:text>
</xsl:if>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="vcf:info" mode="body">
<xsl:for-each select="*">
<xsl:if test="position()!=1">
<xsl:text>;</xsl:text>
</xsl:if>
<xsl:value-of select="concat(local-name(.),'=',.)"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Show details
Hide details
Change log
r86
by plindenbaum.u915 on May 20, 2010
Diff
cont
Go to:
...r915/core/bio/vcf/VCFHeader.java
.../umr915/core/bio/vcf/VCFRow.java
/trunk/core/src/xsl/xvcf2sql.xsl
/trunk/core/src/xsl/xvcf2vcf.xsl
Project members,
sign in
to write a code review
Older revisions
r85
by plindenbaum.u915 on May 19, 2010
Diff
cont
r84
by plindenbaum.u915 on May 19, 2010
Diff
cont
r83
by plindenbaum.u915 on May 19, 2010
Diff
cont
All revisions of this file
File info
Size: 4233 bytes, 172 lines
View raw file
Powered by
Google Project Hosting