apollo.dataadapter
Class AbstractApolloAdapter

java.lang.Object
  extended by org.bdgp.io.AbstractDataAdapter
      extended by apollo.dataadapter.AbstractApolloAdapter
All Implemented Interfaces:
ApolloDataAdapterI, org.bdgp.io.DataAdapter, org.bdgp.io.VisualDataAdapter
Direct Known Subclasses:
AnalysisAdapter, BaseGFFAdapter, BuilderAdapter, ChadoAdapter, ChadoXmlAdapter, DAS2Adapter, DummySequenceAdapter, EfetchSequenceAdapter, EnsCGIAdapter, EnsJAdapter, EnsJAdapter, GAMEAdapter, GbrowseAdapter, GenbankAdapter, GFF3Adapter, GraphAdapter, OtterAdapter, OtterXMLAdapter, SampleAdapter, SerialDiskAdapter, SimpleDASAdapter, SyntenyAdapter, SyntenyComparaAdapter

public abstract class AbstractApolloAdapter
extends org.bdgp.io.AbstractDataAdapter
implements ApolloDataAdapterI

All the dataadapters now subclass AbstractApolloAdapter, which new data adapters should do as well. In AbstractApolloAdapter.getCurationSet() apollo.config.Config.newDataAdapter(this) is called. This sets up the new style before the data loads. So all the subclasses have to call super.getCurationSet() at the start of their getCurationSet() method. A data adapter has to subclass AbstactApolloAdapter and call super.getCurationSet(). (AAA.getCS() also clears out all the old data that is still lingering). I know this is a bit of an awkward requirement and is easy to miss on coding a new data adapter. I am certainly open to other suggestions on how to get the notification out before the data loads. The problem is that org.bdgp.swing.widget.DataAdapterChooser is a bit of a black box and the first point of control one gets in apollo is in data adapters with DataAdapterGUI.doOperation which then calls DataAdapter.getCurationSet. One idea I had was to have DataAdapterChooser send out some sort of notification of whether its going to do a load or cancel. I've ran this by John Richter who is more or less in charge of org.bdgp utilities but I havent heard back yet. - MG


Field Summary
protected  CurationSet curation_set
           
protected static org.apache.log4j.Logger logger
           
protected  java.lang.String region
           
protected  Style style
           
 
Fields inherited from class org.bdgp.io.AbstractDataAdapter
listeners
 
Fields inherited from interface apollo.dataadapter.ApolloDataAdapterI
OP_APPEND_DATA, OP_READ_DATA, OP_READ_RAW_ANALYSIS, OP_READ_SEQUENCE, OP_WRITE_DATA
 
Constructor Summary
AbstractApolloAdapter()
           
 
Method Summary
 java.lang.Boolean addToCurationSet()
           
protected  void cacheUI(org.bdgp.io.IOOperation op, org.bdgp.io.DataAdapterUI ui)
           
 boolean canWriteData()
          Whether write operation is supported by data adapter
protected  void clearOldData()
          This has to be called in the subclass.getCurationSet (super.clearOldData()) to do the new data notification(clears old features) - also it notifies Config of style change.
 void clearStateInformation()
          This SHOULD reset all the contents of the stateInformation being held by an adapter: with setStateInformation, this is not guaranteed.
 void commitChanges(CompositeDataHolder cdh)
          SyntenyAdapter and SerialDiskAdapter override this
 void commitChanges(CompositeDataHolder cdh, boolean saveAnnots, boolean saveResults)
           
 void commitChanges(CurationSet curation)
          writes the changes from a featureChangeLog to a writeable datasource.
 void commitChanges(CurationSet curation, boolean saveAnnots, boolean saveResults)
           
 void commitChanges(java.lang.Object values)
          Straight from DataAdapterGUI.doOp.
 void commitChanges(java.lang.Object values, boolean saveAnnots, boolean saveResults)
          GAMEAdapter and ChadoXMLAdapter can specify whether to save annots and whether to save results
 java.util.Map getAdapters()
           
protected  org.bdgp.io.DataAdapterUI getCachedUI(org.bdgp.io.IOOperation op)
           
 ApolloDataAdapterI getChildAdapter(int i)
          Throws not implemented exception as by default data adapter dont have species adapter (isComposite()=false).
 ApolloDataAdapterI getChildAdapter(java.lang.String species)
          Throws not implemented exception as by default data adapter dont have species adapter (isComposite()=false).
 CurationSet getCurationSet()
          returns a saved CurationSet.
 CurationState getCurationState()
          Get CurationState associated with data adapter.
 java.lang.String getDatabase()
           
 DataInput getDataInput()
           
protected  Style getDefaultStyle()
          Return style to use if no db (file) or db is not listed.
protected  java.lang.String getFilename()
          Returns null if not file
 java.lang.String getInput()
          Returns the input String passed to the DataAdapter, the input is of course associated with the input type Should this go into org.bdgp.io.DataAdapter?
 DataInputType getInputType()
          Returns the type of input data (gene,file,band...)
 java.lang.String getName()
          Name label for use in Data Adapter Chooser.
 ApolloNameAdapterI getNameAdapter(AnnotatedFeatureI annot)
           
 int getNumberOfChildAdapters()
          Returns 0 by default.
 java.lang.String getRawAnalysisResults(java.lang.String id)
           
 SequenceI getSequence(DbXref dbxref)
           
 SequenceI getSequence(DbXref dbxref, int start, int end)
           
 SequenceI getSequence(java.lang.String id)
          Strings for input types
 java.util.Vector getSequences(DbXref[] dbxref)
           
 java.util.Vector getSequences(DbXref[] dbxref, int[] start, int[] end)
           
 java.lang.String getSpecies()
          Synteny gives a species to each adapter to help keep track of them
 java.util.Properties getStateInformation()
          State info Properties carries all the info needed for the adapter to do its query This is an alternative to setDataInput.
 Style getStyle()
          By default return style associated with the adapter in apollo.cfg.
 java.lang.String getType()
          From org.bdgp.io.DataAdapter.
 boolean hasLinkData()
          Whether data adapter contains link data used for synteny, returns false by default override if otherwise
 void init()
          From org.bdgp.io.DataAdapter interface.
 boolean isComposite()
          By default return false - data adapter is not composite.
 void loadNewSpeciesFromLink(SeqFeatureI link, CompositeDataHolder c)
          Bring up the link as a species in synteny.
protected  boolean operationIsSupported(org.bdgp.io.IOOperation op)
          I think this should be taken out to force a data adapter to implement it.
 boolean rollbackAnnotations(CompositeDataHolder cdh)
          Send any necessary signals to the server to release annotation locks or undo edits --after the user has been prompted that these will be lost.
protected  boolean rollbackAnnotations(CurationSet curationSet)
          Overridden by AnnotationEnsJAdapter and EfeatchSequenceAdapter
 void setCuration(CurationSet curation)
          This region is used for overlay onto this existing curation
 void setCurationNumber(int curationNumber)
           
 void setCurationState(CurationState curationState)
           
 void setDatabase(java.lang.String database)
          Presently only game adapter uses this
 void setDataInput(DataInput dataInput)
          This should replace setInput.
 void setDataLoadListener(DataLoadListener l)
          We currently only need one DataLoadListener(curSet controller) if we need more than one change this to addDataLoadListener
 void setInput(java.lang.String input)
          Input string that corresponds with the input type (eg gene name for gene input type)
 void setInputType(DataInputType type)
          DataInputType describes the type of input (gene,cytology,scaffold...) does this belong in the abstract class?
 void setLocation(GenomicRange chromosomeLocation)
          GenomicRange is a convenient object to carry chromosome, start and end.
 void setName(java.lang.String n)
           
 void setPadLeft(int padLeft)
          Request to "pad" the input padLeft basepairs to the left(5' forward strand) - default noop - presently only used by game adapter in synteny context
 void setPadRight(int padRight)
          Request to "pad" the input padRight basepairs to the right(3' forward strand)
 void setRegion(java.lang.String region)
          This region doesnt seem to be used anywhere?
 void setSpecies(java.lang.String species)
           
 void setStateInformation(java.util.Properties p)
          This should set StateInformation object! see StateInformation for Strings to use for keys.
 void setStyle(Style style)
          By default a data adapter uses the style listed with it in the config file.
 
Methods inherited from class org.bdgp.io.AbstractDataAdapter
addProgressListener, fireProgressEvent, removeProgressListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.bdgp.io.VisualDataAdapter
addProgressListener, fireProgressEvent, getUI, removeProgressListener
 
Methods inherited from interface org.bdgp.io.DataAdapter
getSupportedOperations
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

region

protected java.lang.String region

curation_set

protected CurationSet curation_set

style

protected Style style
Constructor Detail

AbstractApolloAdapter

public AbstractApolloAdapter()
Method Detail

init

public void init()
From org.bdgp.io.DataAdapter interface. no-op default implementation. A data adapter should override this if it needs to do some initialization.

Specified by:
init in interface org.bdgp.io.DataAdapter

getName

public java.lang.String getName()
Name label for use in Data Adapter Chooser. Don't override this method--call setName from your constructor.

Specified by:
getName in interface org.bdgp.io.DataAdapter

setName

public void setName(java.lang.String n)

getType

public java.lang.String getType()
From org.bdgp.io.DataAdapter. Default implementation returns "". Override this to return a string describing the data adapter. The reason for the default implementation is that as far as I can tell getType is not used by apollo nor org.bdgp, so seems silly to require it. Am i missing something?

Specified by:
getType in interface org.bdgp.io.DataAdapter

setCurationNumber

public void setCurationNumber(int curationNumber)

setCurationState

public void setCurationState(CurationState curationState)

getCurationState

public CurationState getCurationState()
Description copied from interface: ApolloDataAdapterI
Get CurationState associated with data adapter.

Specified by:
getCurationState in interface ApolloDataAdapterI

getNameAdapter

public ApolloNameAdapterI getNameAdapter(AnnotatedFeatureI annot)

setDataInput

public void setDataInput(DataInput dataInput)
Description copied from interface: ApolloDataAdapterI
This should replace setInput. setInput is limited to just a String which is awkward for locations where you have to jam several fields into one String. DataInput deals with locations much better. DataInput can complement stateInfo (hopefully?)

Specified by:
setDataInput in interface ApolloDataAdapterI

getDataInput

public DataInput getDataInput()

getFilename

protected java.lang.String getFilename()
Returns null if not file


setInputType

public void setInputType(DataInputType type)
DataInputType describes the type of input (gene,cytology,scaffold...) does this belong in the abstract class?

Specified by:
setInputType in interface ApolloDataAdapterI

getInputType

public DataInputType getInputType()
Returns the type of input data (gene,file,band...)

Specified by:
getInputType in interface ApolloDataAdapterI
See Also:
Should this go into org.bdgp.io.DataAdapter?

getInput

public java.lang.String getInput()
Returns the input String passed to the DataAdapter, the input is of course associated with the input type Should this go into org.bdgp.io.DataAdapter?

Specified by:
getInput in interface ApolloDataAdapterI

setInput

public void setInput(java.lang.String input)
Input string that corresponds with the input type (eg gene name for gene input type)

Specified by:
setInput in interface ApolloDataAdapterI

clearOldData

protected void clearOldData()
                     throws ApolloAdapterException
This has to be called in the subclass.getCurationSet (super.clearOldData()) to do the new data notification(clears old features) - also it notifies Config of style change. This needs to be called after it has been verified that the user input is ok. e.g. that the filename is a valid filename. Otherwise old data will be cleared out but the new has failed. Split into 2 methods? fireDataLoadEvent and setStyle? or rename newDataLoading?

Throws:
ApolloAdapterException

rollbackAnnotations

public boolean rollbackAnnotations(CompositeDataHolder cdh)
Send any necessary signals to the server to release annotation locks or undo edits --after the user has been prompted that these will be lost. By default this method has an empty implementation: it is overridden, for instance, in the ensj-adapter

Specified by:
rollbackAnnotations in interface ApolloDataAdapterI

rollbackAnnotations

protected boolean rollbackAnnotations(CurationSet curationSet)
Overridden by AnnotationEnsJAdapter and EfeatchSequenceAdapter


getSequence

public SequenceI getSequence(java.lang.String id)
                      throws ApolloAdapterException
Description copied from interface: ApolloDataAdapterI
Strings for input types

Specified by:
getSequence in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

getSequence

public SequenceI getSequence(DbXref dbxref)
                      throws ApolloAdapterException
Specified by:
getSequence in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

getSequence

public SequenceI getSequence(DbXref dbxref,
                             int start,
                             int end)
                      throws ApolloAdapterException
Specified by:
getSequence in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

getSequences

public java.util.Vector getSequences(DbXref[] dbxref)
                              throws ApolloAdapterException
Specified by:
getSequences in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

getSequences

public java.util.Vector getSequences(DbXref[] dbxref,
                                     int[] start,
                                     int[] end)
                              throws ApolloAdapterException
Specified by:
getSequences in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

getRawAnalysisResults

public java.lang.String getRawAnalysisResults(java.lang.String id)
                                       throws ApolloAdapterException
Specified by:
getRawAnalysisResults in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

setRegion

public void setRegion(java.lang.String region)
               throws ApolloAdapterException
This region doesnt seem to be used anywhere?

Specified by:
setRegion in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

setCuration

public void setCuration(CurationSet curation)
                 throws ApolloAdapterException
This region is used for overlay onto this existing curation

Specified by:
setCuration in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

commitChanges

public void commitChanges(CurationSet curation)
                   throws ApolloAdapterException
Description copied from interface: ApolloDataAdapterI
writes the changes from a featureChangeLog to a writeable datasource. Not just a featureChangeLog - this writes out the whole curationSet

Specified by:
commitChanges in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

commitChanges

public void commitChanges(CompositeDataHolder cdh)
                   throws ApolloAdapterException
SyntenyAdapter and SerialDiskAdapter override this

Specified by:
commitChanges in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

commitChanges

public void commitChanges(java.lang.Object values)
                   throws ApolloAdapterException
Description copied from interface: ApolloDataAdapterI
Straight from DataAdapterGUI.doOp. Could be cur set or comp data holder

Specified by:
commitChanges in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

commitChanges

public void commitChanges(java.lang.Object values,
                          boolean saveAnnots,
                          boolean saveResults)
                   throws ApolloAdapterException
GAMEAdapter and ChadoXMLAdapter can specify whether to save annots and whether to save results

Specified by:
commitChanges in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

commitChanges

public void commitChanges(CurationSet curation,
                          boolean saveAnnots,
                          boolean saveResults)
                   throws ApolloAdapterException
Throws:
ApolloAdapterException

commitChanges

public void commitChanges(CompositeDataHolder cdh,
                          boolean saveAnnots,
                          boolean saveResults)
                   throws ApolloAdapterException
Throws:
ApolloAdapterException

getCurationSet

public CurationSet getCurationSet()
                           throws ApolloAdapterException
Description copied from interface: ApolloDataAdapterI
returns a saved CurationSet.

Specified by:
getCurationSet in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

getStateInformation

public java.util.Properties getStateInformation()
Description copied from interface: ApolloDataAdapterI
State info Properties carries all the info needed for the adapter to do its query This is an alternative to setDataInput. For most cases setDataInput should be sufficient. This should return StateInformation

Specified by:
getStateInformation in interface ApolloDataAdapterI

setStateInformation

public void setStateInformation(java.util.Properties p)
Description copied from interface: ApolloDataAdapterI
This should set StateInformation object! see StateInformation for Strings to use for keys.

Specified by:
setStateInformation in interface ApolloDataAdapterI

setLocation

public void setLocation(GenomicRange chromosomeLocation)
GenomicRange is a convenient object to carry chromosome, start and end. May at some point replace this with a more generic Location object, for non chromosome locations, this will do for now. This sets state info properties INPUT_TYPE = "Location", INPUT_ID = chromName, START & END


clearStateInformation

public void clearStateInformation()
This SHOULD reset all the contents of the stateInformation being held by an adapter: with setStateInformation, this is not guaranteed.


addToCurationSet

public java.lang.Boolean addToCurationSet()
                                   throws ApolloAdapterException
Specified by:
addToCurationSet in interface ApolloDataAdapterI
Throws:
ApolloAdapterException

operationIsSupported

protected boolean operationIsSupported(org.bdgp.io.IOOperation op)
I think this should be taken out to force a data adapter to implement it. If a data adapter doesnt have a ui it can return null for this.


canWriteData

public boolean canWriteData()
Whether write operation is supported by data adapter

Specified by:
canWriteData in interface ApolloDataAdapterI

cacheUI

protected void cacheUI(org.bdgp.io.IOOperation op,
                       org.bdgp.io.DataAdapterUI ui)

getCachedUI

protected org.bdgp.io.DataAdapterUI getCachedUI(org.bdgp.io.IOOperation op)

hasLinkData

public boolean hasLinkData()
Whether data adapter contains link data used for synteny, returns false by default override if otherwise

Specified by:
hasLinkData in interface ApolloDataAdapterI

isComposite

public boolean isComposite()
By default return false - data adapter is not composite. SyntenyAdpapter overrides this to return true.

Specified by:
isComposite in interface ApolloDataAdapterI

getChildAdapter

public ApolloDataAdapterI getChildAdapter(java.lang.String species)
Throws not implemented exception as by default data adapter dont have species adapter (isComposite()=false). SyntenyAdapter overrides this, and returns its species adapters

Specified by:
getChildAdapter in interface ApolloDataAdapterI

getChildAdapter

public ApolloDataAdapterI getChildAdapter(int i)
Throws not implemented exception as by default data adapter dont have species adapter (isComposite()=false). SyntenyAdapter overrides this, and returns its species adapters

Specified by:
getChildAdapter in interface ApolloDataAdapterI

getNumberOfChildAdapters

public int getNumberOfChildAdapters()
Returns 0 by default. SyntenyAdapter overrides.

Specified by:
getNumberOfChildAdapters in interface ApolloDataAdapterI

getAdapters

public java.util.Map getAdapters()
Specified by:
getAdapters in interface ApolloDataAdapterI

setSpecies

public void setSpecies(java.lang.String species)

getSpecies

public java.lang.String getSpecies()
Description copied from interface: ApolloDataAdapterI
Synteny gives a species to each adapter to help keep track of them

Specified by:
getSpecies in interface ApolloDataAdapterI

getStyle

public Style getStyle()
By default return style associated with the adapter in apollo.cfg. This can be overridden by setStyle, which is used by SyntenyAdapter to overrides its childrens style with its own. Once we have the ability to switch between single and multi species, the style will need to be synched with it (not there yet). Also a style can have other styles it loads depending on the db that is being loaded (yes this is a little quirky and perhaps needs a revisit).

Specified by:
getStyle in interface ApolloDataAdapterI

getDefaultStyle

protected Style getDefaultStyle()
Return style to use if no db (file) or db is not listed. This is the style listed in apollo.cfg with the data adapter


setDatabase

public void setDatabase(java.lang.String database)
Presently only game adapter uses this

Specified by:
setDatabase in interface ApolloDataAdapterI

getDatabase

public java.lang.String getDatabase()

loadNewSpeciesFromLink

public void loadNewSpeciesFromLink(SeqFeatureI link,
                                   CompositeDataHolder c)
                            throws org.bdgp.io.DataAdapterException
Bring up the link as a species in synteny. Presently this can only be done in synteny mode - eventually would be nice to do from regular apollo From ApolloDataAdapterI - default throws exception - SyntenyAdapter overrides

Specified by:
loadNewSpeciesFromLink in interface ApolloDataAdapterI
Throws:
org.bdgp.io.DataAdapterException

setPadLeft

public void setPadLeft(int padLeft)
Request to "pad" the input padLeft basepairs to the left(5' forward strand) - default noop - presently only used by game adapter in synteny context

Specified by:
setPadLeft in interface ApolloDataAdapterI

setPadRight

public void setPadRight(int padRight)
Request to "pad" the input padRight basepairs to the right(3' forward strand)

Specified by:
setPadRight in interface ApolloDataAdapterI

setStyle

public void setStyle(Style style)
By default a data adapter uses the style listed with it in the config file. In synteny mode the childrens default style needs to be overridden by the synteny adapters style. This method is for the synteny override of its child adapters style. also using for SpeciesToStyle override(game).

Specified by:
setStyle in interface ApolloDataAdapterI

setDataLoadListener

public void setDataLoadListener(DataLoadListener l)
We currently only need one DataLoadListener(curSet controller) if we need more than one change this to addDataLoadListener

Specified by:
setDataLoadListener in interface ApolloDataAdapterI