1 /* Copyright (c) 2009 Peter Troshin
\r
3 * Jalview Web Services @version: 2.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
18 package compbio.pipeline._jpred;
\r
22 import javax.xml.stream.XMLInputFactory;
\r
23 import javax.xml.stream.XMLStreamException;
\r
24 import javax.xml.stream.XMLStreamReader;
\r
27 public class BlastParser {
\r
29 static class Psiseq {
\r
34 * args[0] is assumed to be the name of a Blast output file
\r
35 * @throws XMLStreamException
\r
36 * @throws FileNotFoundException
\r
38 public static void main(String[] args) throws FileNotFoundException, XMLStreamException {
\r
39 XMLInputFactory f = XMLInputFactory.newInstance();
\r
40 XMLStreamReader r = f.createXMLStreamReader( new BufferedInputStream(new FileInputStream(new File(args[0]))));
\r
41 List<Psiseq> pl = new ArrayList<Psiseq>();
\r
43 while(r.hasNext()) {
\r
44 int idx = r.next();
\r
45 //System.out.println(idx);
\r
47 if(r.isStartElement()) {
\r
48 String name = r.getLocalName();
\r
49 if(name.equals("Hit") ) {
\r
52 if(name.equals("Hit_id") ) {
\r
53 //System.out.println(r.getElementText());
\r
54 psi.id = r.getElementText();
\r
55 System.out.println(psi.id);
\r
57 if(name.equals("Hsp_hseq")) {
\r
58 psi.seq = r.getElementText();
\r
59 System.out.println(psi.seq);
\r
63 if(r.isEndElement()) {
\r
64 String name = r.getLocalName();
\r
65 if(name.equals("Hit") ) {
\r