Package org.biopax.paxtools.io
Class SimpleIOHandler
java.lang.Object
org.biopax.paxtools.io.BioPAXIOHandlerAdapter
org.biopax.paxtools.io.SimpleIOHandler
- All Implemented Interfaces:
BioPAXIOHandler
Simple BioPAX reader/writer.
This class provides a JAXP based I/O handler. As compared to Jena based implementation it offers ~10x performance,
significantly less memory requirements when reading large files and a lightweight deployement. It, however,
is not as robust as the Jena based reader and can not read non-RDF/XML OWL formats or non-UTF encodings.For those,
you might want to use the JenaIOHandler class
-
Nested Class Summary
Nested Classes -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionBasic constructor, defaults to Level 3 and default BioPAXFactorySimpleIOHandler(BioPAXFactory factory, BioPAXLevel level) Full constructorSimpleIOHandler(BioPAXLevel level) Basic constructor, defaults to level.defaultFactory -
Method Summary
Modifier and TypeMethodDescriptionvoidabsoluteUris(boolean absoluteUris) Sets the flag used when exporting a BioPAX model to RDF/XML: true - to always write full URI in rdf:resource and use rdf:about instead rdf:ID (does not matter xml:base is set or not).voidcheckRestrictions(boolean checkRestrictions) If set to true, property editors will check restrictions at the subclass level and throw an exception if violated.static StringconvertToOwl(Model model) Serializes a (not too large) BioPAX model to the RDF/XML (OWL) formatted string.voidconvertToOWL(Model model, OutputStream outputStream) Converts a model into BioPAX (OWL) format, and writes it into the outputStream.protected voidcreateAndBind(Model model) This method provides a hook for the implementers of this abstract class to create objects themselves and bind the properties to the objects.getId()This may be required for external applications to access the specific information (e.g., location) when reporting XML exceptions.protected voidinit(InputStream in) This method provides a hook for the implementers of this abstract class to perform the initial reading from the input stream.booleanbooleanbooleanvoidmergeDuplicates(boolean mergeDuplicates) If set to true, the reader will try to merge duplicate (same URI) individuals rather than throw an exception.voidnormalizeNameSpaces(boolean normalizeNameSpaces) Sets the flag used when exporting a BioPAX model to RDF/XML: true - to clean up current namespaces (e.g., those read from a file) and use defaults instead (prefixes: 'rdf', 'rdfs', 'owl', 'xsd')This method provides a hook for the implementers of this abstract class to set the namespaces of the model.protected voidreset(InputStream in) protected voidThis method resets the editor map.voidwriteObject(Writer out, BioPAXElement bean) Writes the XML representation of individual BioPAX element that is BioPAX-like but only for display or debug purpose (incomplete).Methods inherited from class org.biopax.paxtools.io.BioPAXIOHandlerAdapter
bindValue, convertFromOWL, convertToOWL, createAndAdd, fixReusedPEPs, getEditorMap, getFactory, getLevel, getRDFCommentEditor, getReusedPEPHelper, isFixReusedPEPs, resetLevel, resourceFixes, setEditorMap, setFactory
-
Constructor Details
-
SimpleIOHandler
public SimpleIOHandler()Basic constructor, defaults to Level 3 and default BioPAXFactory -
SimpleIOHandler
Basic constructor, defaults to level.defaultFactory- Parameters:
level- BioPAXLevel to handle.
-
SimpleIOHandler
Full constructor- Parameters:
factory- to create BioPAX objectslevel- BioPAX level to handle.
-
-
Method Details
-
mergeDuplicates
public void mergeDuplicates(boolean mergeDuplicates) If set to true, the reader will try to merge duplicate (same URI) individuals rather than throw an exception.- Parameters:
mergeDuplicates- true/false (default is false)
-
checkRestrictions
public void checkRestrictions(boolean checkRestrictions) If set to true, property editors will check restrictions at the subclass level and throw an exception if violated. This is true by default. WARNING: This is a static parameter and will change behaviour for the whole thread. Do not change unless you need to read a (relatively exotic) BioPAX export that violates subclass level restrictions.- Parameters:
checkRestrictions- true/false
-
resetEditorMap
protected void resetEditorMap()This method resets the editor map. Editor maps are used to map property names to property editors. Resetting the editor map might be required to switch between levels.- Specified by:
resetEditorMapin classBioPAXIOHandlerAdapter
-
getXmlStreamInfo
This may be required for external applications to access the specific information (e.g., location) when reporting XML exceptions.- Returns:
- current XML stream state summary
-
init
Description copied from class:BioPAXIOHandlerAdapterThis method provides a hook for the implementers of this abstract class to perform the initial reading from the input stream.- Specified by:
initin classBioPAXIOHandlerAdapter- Parameters:
in- BioPAX RDF/XML input stream
-
reset
- Overrides:
resetin classBioPAXIOHandlerAdapter
-
readNameSpaces
Description copied from class:BioPAXIOHandlerAdapterThis method provides a hook for the implementers of this abstract class to set the namespaces of the model.- Specified by:
readNameSpacesin classBioPAXIOHandlerAdapter- Returns:
- a map of namespaces.
-
createAndBind
Description copied from class:BioPAXIOHandlerAdapterThis method provides a hook for the implementers of this abstract class to create objects themselves and bind the properties to the objects.- Specified by:
createAndBindin classBioPAXIOHandlerAdapter- Parameters:
model- to be populated
-
getId
-
convertToOWL
Converts a model into BioPAX (OWL) format, and writes it into the outputStream. Saved data can be then read viaBioPAXIOHandlerinterface (e.g.,SimpleIOHandler). Note: When the model is incomplete (i.e., contains elements that refer externals, dangling BioPAX elements) and is exported by this method, it works; however one will find corresponding object properties set to NULL later, after converting such data back to Model. Note: if the model is too large, and the output stream is a byte array stream, then you can eventually get OutOfMemoryError "Requested array size exceeds VM limit" (max. array size is 2Gb)- Parameters:
model- model to be converted into OWL formatoutputStream- output stream into which the output will be written- Throws:
BioPaxIOException- in case of I/O problems
-
writeObject
Writes the XML representation of individual BioPAX element that is BioPAX-like but only for display or debug purpose (incomplete). Note: useBioPAXIOHandler.convertToOWL(org.biopax.paxtools.model.Model, java.io.OutputStream)convertToOWL(org.biopax.paxtools.model.Model, Object)} instead if you have a model and want to save and later restore it.- Parameters:
out- outputbean- BioPAX object- Throws:
IOException- when the output writer throws
-
absoluteUris
public void absoluteUris(boolean absoluteUris) Sets the flag used when exporting a BioPAX model to RDF/XML: true - to always write full URI in rdf:resource and use rdf:about instead rdf:ID (does not matter xml:base is set or not). This is good for the data loading to RDF/SPARQL servers, such as Virtuoso, so they generate correct and resolvable links from BioPAX URIs (use of rdf:ID="localId" and rdf:resource="#localID" is known to make them insert extra '#' between xml:base and localId).- Parameters:
absoluteUris- true/false - whether to force writing absolute URIs (thus, never use rdf:ID)
-
isAbsoluteUris
public boolean isAbsoluteUris()- Returns:
- true/false
- See Also:
-
normalizeNameSpaces
public void normalizeNameSpaces(boolean normalizeNameSpaces) Sets the flag used when exporting a BioPAX model to RDF/XML: true - to clean up current namespaces (e.g., those read from a file) and use defaults instead (prefixes: 'rdf', 'rdfs', 'owl', 'xsd')- Parameters:
normalizeNameSpaces- true/false
-
isNormalizeNameSpaces
public boolean isNormalizeNameSpaces()- Returns:
- true/false
- See Also:
-
isMergeDuplicates
public boolean isMergeDuplicates()- Returns:
- true/false
- See Also:
-
convertToOwl
Serializes a (not too large) BioPAX model to the RDF/XML (OWL) formatted string.- Parameters:
model- a BioPAX object model to convert to the RDF/XML format- Returns:
- the BioPAX data in the RDF/XML format
- Throws:
IllegalArgumentException- if model is nullOutOfMemoryError- when it cannot be stored in a byte array (max 2Gb).
-