Class SimpleIOHandler

java.lang.Object
org.biopax.paxtools.io.BioPAXIOHandlerAdapter
org.biopax.paxtools.io.SimpleIOHandler
All Implemented Interfaces:
BioPAXIOHandler

public final class SimpleIOHandler extends BioPAXIOHandlerAdapter
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
  • Constructor Details

    • SimpleIOHandler

      public SimpleIOHandler()
      Basic constructor, defaults to Level 3 and default BioPAXFactory
    • SimpleIOHandler

      public SimpleIOHandler(BioPAXLevel level)
      Basic constructor, defaults to level.defaultFactory
      Parameters:
      level - BioPAXLevel to handle.
    • SimpleIOHandler

      public SimpleIOHandler(BioPAXFactory factory, BioPAXLevel level)
      Full constructor
      Parameters:
      factory - to create BioPAX objects
      level - 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:
      resetEditorMap in class BioPAXIOHandlerAdapter
    • getXmlStreamInfo

      public String 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

      protected void init(InputStream in)
      Description copied from class: BioPAXIOHandlerAdapter
      This method provides a hook for the implementers of this abstract class to perform the initial reading from the input stream.
      Specified by:
      init in class BioPAXIOHandlerAdapter
      Parameters:
      in - BioPAX RDF/XML input stream
    • reset

      protected void reset(InputStream in)
      Overrides:
      reset in class BioPAXIOHandlerAdapter
    • readNameSpaces

      protected Map<String,String> readNameSpaces()
      Description copied from class: BioPAXIOHandlerAdapter
      This method provides a hook for the implementers of this abstract class to set the namespaces of the model.
      Specified by:
      readNameSpaces in class BioPAXIOHandlerAdapter
      Returns:
      a map of namespaces.
    • createAndBind

      protected void createAndBind(Model model)
      Description copied from class: BioPAXIOHandlerAdapter
      This method provides a hook for the implementers of this abstract class to create objects themselves and bind the properties to the objects.
      Specified by:
      createAndBind in class BioPAXIOHandlerAdapter
      Parameters:
      model - to be populated
    • getId

      public String getId()
    • convertToOWL

      public void convertToOWL(Model model, OutputStream outputStream)
      Converts a model into BioPAX (OWL) format, and writes it into the outputStream. Saved data can be then read via BioPAXIOHandler interface (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 format
      outputStream - output stream into which the output will be written
      Throws:
      BioPaxIOException - in case of I/O problems
    • writeObject

      public void writeObject(Writer out, BioPAXElement bean) throws IOException
      Writes the XML representation of individual BioPAX element that is BioPAX-like but only for display or debug purpose (incomplete). Note: use BioPAXIOHandler.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 - output
      bean - 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:
      • normalizeNameSpaces()
    • isMergeDuplicates

      public boolean isMergeDuplicates()
      Returns:
      true/false
      See Also:
    • convertToOwl

      public static String convertToOwl(Model model)
      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 null
      OutOfMemoryError - when it cannot be stored in a byte array (max 2Gb).