My favorites
▼
|
Sign in
code915
My code for INSERM UMR915
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
tools
/
src
/
java
/
fr
/
inserm
/
umr915
/
tools
/
VCFToXML.java
‹r80
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
package fr.inserm.umr915.tools;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.XMLConstants;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;
import org.lindenb.io.IOUtils;
import org.lindenb.me.Me;
import org.lindenb.sw.vocabulary.DC;
import org.lindenb.sw.vocabulary.RDF;
import org.lindenb.sw.vocabulary.XLINK;
import fr.inserm.umr915.core.bio.vcf.VCFHeader;
import fr.inserm.umr915.core.bio.vcf.VCFRow;
public class VCFToXML
{
private static final Logger LOG=Logger.getLogger("fr.inserm.umr915");
private VCFToXML()
{
}
private void run(BufferedReader in) throws IOException
{
try {
VCFHeader header=VCFHeader.read(in);
XMLOutputFactory xmlfactory= XMLOutputFactory.newInstance();
XMLStreamWriter w= xmlfactory.createXMLStreamWriter(System.out,"UTF-8");
w.writeStartDocument("UTF-8","1.0");
w.writeStartElement("vcf");
w.writeAttribute("xmlns", "http://www.umr915.univ-nantes.fr/vcf/");
w.writeAttribute("xmlns", XMLConstants.XML_NS_URI, "xlink", XLINK.NS);
w.writeAttribute("xmlns", XMLConstants.XML_NS_URI, "rdf", RDF.NS);
w.writeAttribute("xmlns", XMLConstants.XML_NS_URI, "dc", DC.NS);
header.writeXML(w);
w.writeStartElement("body");
VCFRow row;
while((row=header.nextRow(in))!=null)
{
row.writeXML(w);
}
w.writeEndElement();
w.writeEndElement();
w.writeEndDocument();
w.flush();
w.close();
} catch (IOException e) {
throw e;
}
catch (Exception e) {
throw new IOException(e);
}
}
public static void main(String[] args)
{
VCFToXML app=null;
try {
app=new VCFToXML();
int optind=0;
while(optind<args.length)
{
if(args[optind].equals("-h"))
{
System.err.println("Convert a VCF (variant call format) to XML.");
System.err.println(Me.FIRST_NAME+" "+Me.LAST_NAME+" "+Me.WWW);
System.err.println(" --log-level <LEVEL> optional , one of "+Level.class.getName());
System.err.println("<file|url|stdin>");
return;
}
else if(args[optind].equals("--log-level"))
{
LOG.setLevel(Level.parse(args[++optind]));
}
else if(args[optind].equals("--"))
{
optind++;
break;
}
else if(args[optind].startsWith("-"))
{
System.err.println("Unnown option: "+args[optind]);
return;
}
else
{
break;
}
++optind;
}
if(optind==args.length)
{
LOG.info("reading from stdin");
app.run(new BufferedReader(new InputStreamReader(System.in)));
}
else if(optind+1==args.length)
{
String inputName=args[optind++];
LOG.info("reading from "+inputName);
BufferedReader in=IOUtils.openReader(inputName);
app.run(in);
in.close();
}
else
{
System.err.println("Illegal number of arguments");
return;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Show details
Hide details
Change log
r81
by plindenbaum.u915 on May 19, 2010
Diff
cont
Go to:
/trunk/build.xml
.../umr915/core/bio/vcf/VCFRow.java
...umr915/core/xml/StreamUtils.java
...nserm/umr915/tools/VCFToXML.java
Project members,
sign in
to write a code review
Older revisions
r80
by plindenbaum.u915 on May 19, 2010
Diff
cont
All revisions of this file
File info
Size: 3077 bytes, 143 lines
View raw file
Powered by
Google Project Hosting