[Biojava-l] PdbToXMLConverter output
jon portuondo murguiondo
jon portuondo murguiondo <jon.portuondo01@campus.upf.es>
Tue, 7 Jan 2003 08:56:30
PdbToXMLConverter doesn't have main method.
For these reason, I used he program that Matthew gave me, called PDBConverter.java. This is the source of the PDBConverter.java:
----------------------------------------------------------------------------------------------------
package org.biojava.bio.program;
import java.io.*;
import org.biojava.bio.program.*;
public class PDBConverter {
public static void main(String[] args)
throws Exception {
StringBuffer sbuf = new StringBuffer();
BufferedReader in = new BufferedReader(
new FileReader(
new File(args[0]) ) );
for(
String line = in.readLine();
line != null;
line = in.readLine()
) {
sbuf.append(line);
}
PdbToXMLConverter converter =
new PdbToXMLConverter(sbuf.toString());
converter.convert();
}
}
--------------------------------------------------------------------------------------------------
With this program I finally get an output from
PdbToXMLConverter, but it is really odd.
To get it run I typed:
java org.biojava.bio.program.PDBConverter
/home/jon/1FS1.pdb
------------------------------------------------------------------------------------------------
<?xml version="1.0"?>
no protocol: HEADER LIGASE 08-SEP-00 1FS1 TITLE
INSIGHTS INTO SCF UBIQUITIN LIGASES FROM THE
STRUCTURE OF TITLE 2 THE SKP1-SKP2 COMPLEX
COMPND MOL_ID: 1; COMPND 2 MOLECULE: CYCLIN
A/CDK2-ASSOCIATED P19; COMPND 3 CHAIN: A, C;
COMPND 4 FRAGMENT: RESIDUES 101-153; COMPND
5 SYNONYM: SKP2 F-BOX; COMPND 6 ENGINEERED:
YES; COMPND 7 MOL_ID: 2; COMPND 8 MOLECULE:
CYCLIN A/CDK2-ASSOCIATED P45; COMPND 9
CHAIN: B, D; COMPND 10 FRAGMENT: RESIDUES
1-147; COMPND 11 SYNONYM: SKP1; COMPND 12
ENGINEERED: YES SOURCE MOL_ID: 1; SOURCE 2
ORGANISM_SCIENTIFIC: HOMO SAPIENS; SOURCE 3
ORGANISM_COMMON: HUMAN; SOURCE 4
EXPRESSION_SYSTEM: ESCHERICHIA COLI; SOURCE
5 EXPRESSION_SYSTEM_COMMON: BACTERIA;
SOURCE 6 MOL_ID: 2; SOURCE 7
ORGANISM_SCIENTIFIC: HOMO SAPIENS; SOURCE
---------------------------------------------------------------------------------------------------
This is supposed to be an structured XML, but there is no change of line and I think it's clearly a defectous output (if it isn't, tell me please).
Thanks for all!
If you want to see PdbToXMLConverter.java, here it is:
----------------------------------------------------------------------------------------------------
/*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
*/
package org.biojava.bio.program;
import org.xml.sax.ContentHandler;
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
import java.util.*;
import org.biojava.bio.program.sax.PdbSAXParser;
import org.biojava.bio.program.xml.SimpleXMLEmitter;
/**
* <p>
* A class that converts Protein Data Bank (PDB) to
* XML that will validate against the biojava:MacromolecularStructure DTD.
* <p>
* <b>Note this code is experimental and subject to change without notice.
* </b>
* <p>
* Copyright © 2000 Cambridge Antibody Technology.
* All Rights Reserved.
* <p>
* Primary author -<ul>
* <li>Simon Brocklehurst (CAT)
* </ul>
* Other authors -<ul>
* <li>Tim Dilks (CAT)
* <li>Colin Hardman (CAT)
* <li>Stuart Johnston (CAT)
*</ul>
*
* This code was first released to the biojava.org project, July 2000.
*
* @author Cambridge Antibody Technology (CAT)
* @version 0.1
*
* @see org.biojava.bio.program.sax.BlastLikeSAXParser
* @see SimpleXMLEmitter
*/
public class PdbToXMLConverter {
private String oInput;
private XMLReader oParser;
private boolean tStrict = true;
/**
* Creates a new <code>BlastToXMLConverter</code> instance.
*
*/
public PdbToXMLConverter(String poInput) {
oInput = poInput;
}
public void convert() throws java.io.IOException,
org.xml.sax.SAXException {
//Access functionality of biojava classes through
//standard org.xml.sax interfaces...
/**
* Create a SAX Parser that takes the native output
* from blast-like bioinformatics software.
*/
oParser = (XMLReader) new PdbSAXParser();
/**
* Dynamically change configuration of the parser
* in regard of Namespace support. Here,
* the xml.org/features/namespaces feature is simply "reset"
* to its default value for SAX2.
* The xml.org/features/namespaces-prefixes feature is
* also set to true. This is to ensure that xmlns attributes
* are reported by the parser. These are required because we want
* to configure the XMLEmitter to output qualified names (see below).
*/
try {
oParser.setFeature("http://xml.org/sax/features/namespaces",true);
oParser.setFeature("http://xml.org/sax/features/namespace-prefixes",
true);
} catch (Exception e) {
//If an illegal conmbination of features is chosen,
//roll back to default settings. Output a warning,
//even though this might mess up the output...
System.out.println("WARNING: ignoring attempt to set illegal " +
"combination of parser features");
}
/**
* Create an XML ContentHandler. This
* implementation of the DocumentHandler
* interface simple outputs nicely formatted
* XML. Passing a true value to the SimpleXMLEmitter
* constructor instructs the ContentHandler
* to take QNames from the SAXParser, rather
* than LocalNames.
*/
ContentHandler oHandler =
(ContentHandler) new SimpleXMLEmitter(true);
/**
* Give the parser a reference to the ContentHandler
* so that it can send SAX2 mesagges.
*/
oParser.setContentHandler(oHandler);
/**
* Now make the Parser parse the output from the
* blast-like software and emit XML as specificed
* by the DocumentHandler.
*/
oParser.parse(oInput);
System.out.println();
}
}