Last update: 2011-06-23

org.proteios.io.mzdata
Class MzDataImporter

java.lang.Object
  extended by org.proteios.io.mzdata.MzDataImporter

public class MzDataImporter
extends Object

This class supports import of mzData files into Proteios. An mzData file contains information on a mass spectrometry experiment. The mzData file is first vaildated against the XML Schema Definition file mzdata.xsd. If the file is valid, its content is parsed and selected information stored in Proteios. The mzData file is parsed using cursor-based XML stream parsing. The StAX (Stream API for XML) parser finds start and stop (end) tags, which are then processed. Element attributes are located in the start tag, and elements of simple types are stored directly after the start tag is read. For more complex elements, values of attributes and sub-elements are collected in temporary variables, until the end tag is reached, and the colelcted contents are stored. Example: XML tag tagData At start tag: Method thisTagElementStart() stores attribute values. Between tags: tagData is stored in temporary StringBuffer. At end tag: Method thisTagItem() processes collected data. Tag data may be exchanged for a start/end tag pair, etc.

Version:
2.0
Author:
Olle
Last modified
$Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $

Constructor Summary
MzDataImporter(SessionControl sc)
          Default constructor.
MzDataImporter(String xsdFilePath, SessionControl sc)
          Constructor that takes an xml schema definition as parameter.
 
Method Summary
 void enableDbControl()
          Make sure that DbControl is running.
 void enableDbControl(BasicItem item)
          Make sure that DbControl is running, and that the item is attached to it.
 PeakList getPeakList()
          Get the current PeakList for the mzData file.
 PeakListSet getPeakListSet()
          Get the PeakListSet created from the imported mzData file.
 ProgressReporter getProgressReporter()
          Get the ProgressReporter.
 File getSourceFile()
          Get source core file with mzData.
 String getXMLFilePath()
          Get mzData XML file path.
 String getXsdFilePath()
          Get XSD schema file to validate against.
 void importFile(File file)
           
 void importFile(InputStream iStream)
           
 void importFile(String xmlFilePath)
          Imports mzData file.
 void processCData(javax.xml.stream.XMLStreamReader parser)
          Processes a CData event.
 void processCharacters(javax.xml.stream.XMLStreamReader parser)
          Processes a Characters event.
 void processEndElement(javax.xml.stream.XMLStreamReader parser)
          Processes an EndElement event.
 void processEvent(int event, javax.xml.stream.XMLStreamReader parser)
          Processes an event.
 void processStartElement(javax.xml.stream.XMLStreamReader parser)
          Processes a StartElement event.
 void setPeakList(PeakList peakList)
          Set the current PeakList for the mzData file.
 void setPeakListSet(PeakListSet peakListSet)
          Set the PeakListSet for the mzData file.
 void setProgressReporter(ProgressReporter progress)
          Set the ProgressReporter.
 void setSourceFile(File sourceFile)
          Set source core file with mzData.
 void setXMLFilePath(String xmlFilePath)
          Set mzData XML file path.
 void setXsdFilePath(String xsdFilePath)
          Set XSD schema file to validate against.
 boolean valid(InputStream xmlInputStream)
          Validates mzData input stream against current mzData XSD file.
 boolean valid(String xmlFilePath)
          Validates mzData file against current mzData XSD file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MzDataImporter

public MzDataImporter(SessionControl sc)
Default constructor.


MzDataImporter

public MzDataImporter(String xsdFilePath,
                      SessionControl sc)
Constructor that takes an xml schema definition as parameter.

Parameters:
xsdFilePath - The XML Schema Definition to use.
Method Detail

getXsdFilePath

public String getXsdFilePath()
Get XSD schema file to validate against.

Returns:
xsdFilePath String with path for XSD schema file.

setXsdFilePath

public void setXsdFilePath(String xsdFilePath)
Set XSD schema file to validate against.

Parameters:
xsdFilePath - String with path for XSD schema file.

getXMLFilePath

public String getXMLFilePath()
Get mzData XML file path.

Returns:
xmlFilePath String with path for mzData XML file.

setXMLFilePath

public void setXMLFilePath(String xmlFilePath)
Set mzData XML file path.

Parameters:
xmlFilePath - String with path for mzData XML file.

getSourceFile

public File getSourceFile()
Get source core file with mzData.

Returns:
sourceFile File source core file with mzData.

setSourceFile

public void setSourceFile(File sourceFile)
Set source core file with mzData.

Parameters:
sourceFile - File source core file with mzData.

getPeakListSet

public PeakListSet getPeakListSet()
Get the PeakListSet created from the imported mzData file.

Returns:
peakListSet PeakListSet the PeakListSet created from the mzdata file.

setPeakListSet

public void setPeakListSet(PeakListSet peakListSet)
Set the PeakListSet for the mzData file.

Parameters:
peakListSet - PeakListSet the peakListSet to set.

getPeakList

public PeakList getPeakList()
Get the current PeakList for the mzData file.

Returns:
peakList The current created PeakList for the mzdata file.

setPeakList

public void setPeakList(PeakList peakList)
Set the current PeakList for the mzData file.

Parameters:
peakList - PeakList the peakList to set.

getProgressReporter

public ProgressReporter getProgressReporter()
Get the ProgressReporter.

Returns:
The ProgressReporter object.

setProgressReporter

public void setProgressReporter(ProgressReporter progress)
Set the ProgressReporter.

Parameters:
progress - The ProgressReporter object to set.

valid

public boolean valid(String xmlFilePath)
              throws javax.xml.stream.XMLStreamException,
                     SAXException
Validates mzData file against current mzData XSD file.

Parameters:
xmlFilePath - String with path of XML file to validate.
Returns:
True if the file is valid, else false
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error
SAXException

valid

public boolean valid(InputStream xmlInputStream)
              throws javax.xml.stream.XMLStreamException,
                     SAXException
Validates mzData input stream against current mzData XSD file.

Parameters:
xmlInputStream - XML input stream to validate.
Returns:
True if the XML input stream is valid, else false
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error
SAXException

importFile

public void importFile(File file)
                throws javax.xml.stream.XMLStreamException,
                       SAXException
Throws:
javax.xml.stream.XMLStreamException
SAXException

importFile

public void importFile(String xmlFilePath)
                throws javax.xml.stream.XMLStreamException,
                       SAXException
Imports mzData file.

Parameters:
xmlFilePath - String with path of mzData XML file to import.
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error
SAXException

importFile

public void importFile(InputStream iStream)
                throws javax.xml.stream.XMLStreamException,
                       SAXException
Throws:
javax.xml.stream.XMLStreamException
SAXException

processEvent

public void processEvent(int event,
                         javax.xml.stream.XMLStreamReader parser)
                  throws javax.xml.stream.XMLStreamException
Processes an event.

Parameters:
event - int current event.
parser - XMLStreamReader instance.
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error

processStartElement

public void processStartElement(javax.xml.stream.XMLStreamReader parser)
                         throws javax.xml.stream.XMLStreamException
Processes a StartElement event. The blocks in the if-else section are placed in the order of appearance of the start elements in the mzData XML file. This not essential for the functionality, but makes it easier to see if a specific element is handled or not. Elements that may be daughter elements to different types of parent elements, e.g. and , are placed at a suitable location. The {elementname}ElementStart(parser) methods called here normally: 1. Collect values from attributes in the start element. 2. Perform specific initializations. The parser argument is only used to get attribute values, not to advance further in the XML structure.

Parameters:
parser - XMLStreamReader instance.
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error

processEndElement

public void processEndElement(javax.xml.stream.XMLStreamReader parser)
                       throws javax.xml.stream.XMLStreamException
Processes an EndElement event. The blocks in the if-else section are placed in the order of appearance of the end elements in the mzData XML file. This is not essential for the functionality, but makes it easier to see if a specific element is handled or not. Note that this means that the blocks for parent and daughter elements come in reverse order than the one in processStartElement(). Elements that may be daughter elements to different types of parent elements, e.g. and , are placed at a suitable location. Data between the start and end elements stored by processCharacters(parser) in a temporary string buffer is collected, and an optional {elementname}Item() method is called. The {elementname}Item() methods called here normally: 1. Processes/stores data collected for element. 2. Perform specific re-initializations.

Parameters:
parser - XMLStreamReader instance.
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error

processCharacters

public void processCharacters(javax.xml.stream.XMLStreamReader parser)
                       throws javax.xml.stream.XMLStreamException
Processes a Characters event.

Parameters:
parser - XMLStreamReader instance.
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error

processCData

public void processCData(javax.xml.stream.XMLStreamReader parser)
                  throws javax.xml.stream.XMLStreamException
Processes a CData event.

Parameters:
parser - XMLStreamReader instance.
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error

enableDbControl

public void enableDbControl()
Make sure that DbControl is running.


enableDbControl

public void enableDbControl(BasicItem item)
Make sure that DbControl is running, and that the item is attached to it.

Parameters:
item - BasicItem item to reattach to DbController

Last update: 2011-06-23