uk.ac.ebi.intact.application.dataConversion
Class PsiDataBuilder

java.lang.Object
  |
  +--uk.ac.ebi.intact.application.dataConversion.PsiDataBuilder
All Implemented Interfaces:
DataBuilder

public class PsiDataBuilder
extends java.lang.Object
implements DataBuilder

PSI-specific implementation of DataBuilder interface. This class will generate a PSI-format file from the data it is supplied with. The implementation is based on the Graph2MIF application written by Henning Mersch.

Version:
$Id: PsiDataBuilder.java,v 1.10 2004/03/10 10:47:28 clewing Exp $
Author:
Chris Lewington

Constructor Summary
PsiDataBuilder()
           
 
Method Summary
 org.w3c.dom.Element buildInteractionsOnly(java.util.Collection interactions, int limit)
          Produces an XML Document which contains only an interactionList.
 org.w3c.dom.Document getCurrentDocument()
          Used to obtain a PSI Document object that is initialised and ready for use when for example later appending lists.
 org.w3c.dom.Element getEntrySet()
          Provides the set of PSI entries currently generated.
 org.w3c.dom.Element getExperimentList()
          Provides access in Document format to the current Experiment List.
 org.w3c.dom.Element getInteractorList()
          Provides access in Document format to the current Interactor List.
 org.w3c.dom.Document newPsiDoc(boolean sourceElementNeeded)
          Creates an initialised PSI Document object.
 void processExperiments(java.util.Collection experiments)
          Generate the PSI xml for a list of experiments
 void writeData(java.lang.String fileName, org.w3c.dom.Document docToWrite)
          This method dumps the data created to the specified file destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PsiDataBuilder

public PsiDataBuilder()
Method Detail

newPsiDoc

public org.w3c.dom.Document newPsiDoc(boolean sourceElementNeeded)
Creates an initialised PSI Document object. This is useful for example when processing lagre datasets and information may need to be generated in segments.

Parameters:
sourceElementNeeded - true if an Intact source element is wanted, false otherwise. For example internal initialisation of this class will not need a source element as it is generated during processing; however for large datasets a source element may be required but without affecting the Document held internally by this class (which is what the generation of a PSI entry alone will do.) NB this aspect will probably be refactored at some point.
Returns:
Document an newly initialised PSI Document, or null if the creation failed. Note that the Document root is an EntrySet with a single Entry child that has its source element inititialised.

writeData

public void writeData(java.lang.String fileName,
                      org.w3c.dom.Document docToWrite)
               throws DataConversionException
Description copied from interface: DataBuilder
This method dumps the data created to the specified file destination.

Specified by:
writeData in interface DataBuilder
Parameters:
fileName - The name of the file to write to.
docToWrite - an XML document to write - if the data held by the builder is not XML or its own Document should be written, this parameter should be set to null.
Throws:
DataConversionException - thrown if there was a problem generating the file.
See Also:
DataBuilder

processExperiments

public void processExperiments(java.util.Collection experiments)
                        throws ElementNotParseableException
Generate the PSI xml for a list of experiments

Specified by:
processExperiments in interface DataBuilder
Parameters:
experiments - to convert to PSI-Format
Throws:
ElementNotParseableException - if PSIrequired Elements are missing within the object graph

getCurrentDocument

public org.w3c.dom.Document getCurrentDocument()
                                        throws ElementNotParseableException
Used to obtain a PSI Document object that is initialised and ready for use when for example later appending lists. Mainly used for processing large experiment sets where the interactions need to be generated in speerate files - this method allows for the generation of the 'root' PSI file.

Returns:
The current Document held by the builder. If called first this will provide an initialised Document; if called after generations have been made then it will return the current state of the Document.
Throws:
ElementNotParseableException - thron if somethingis wrong with the entry format

getEntrySet

public org.w3c.dom.Element getEntrySet()
Provides the set of PSI entries currently generated.

Returns:
an Element containing all the current PSI entries

getInteractorList

public org.w3c.dom.Element getInteractorList()
Provides access in Document format to the current Interactor List.

Returns:
A root Element for a tree containing the current InteractorList, or null if not yet built.

getExperimentList

public org.w3c.dom.Element getExperimentList()
Provides access in Document format to the current Experiment List.

Returns:
An Element containing the tree of current ExperimentList, or null if not yet built.

buildInteractionsOnly

public org.w3c.dom.Element buildInteractionsOnly(java.util.Collection interactions,
                                                 int limit)
                                          throws DataConversionException,
                                                 ElementNotParseableException
Produces an XML Document which contains only an interactionList. This is most likely to be of use for experiments which have very large numbers of Interactions (eg over 1000), and allows the caller to obtain XML in manageable 'chunks' for further processing. It is up to the caller to provide a reasonably well sized Collection - more than 'limit' (see below) will be rejected.

Parameters:
interactions - A Collections of Interactions to be proceesed
limit - The maximum number of interactions allowed to be processed as a single chunk.
Returns:
an XML DOM Element containing the relevant elements for the Interactions
Throws:
ElementNotParseableException - thrown if the Document could not be created.
DataConversionException - thrown if the parameter size is tooo big to be processed in one chunk.


IntAct Project - EMBL-EBI 2004 - intact-help@ebi.ac.uk