apollo.dataadapter.chado
Class ChadoAdapter

java.lang.Object
  extended by org.bdgp.io.AbstractDataAdapter
      extended by apollo.dataadapter.AbstractApolloAdapter
          extended by apollo.dataadapter.chado.ChadoAdapter
All Implemented Interfaces:
ApolloDataAdapterI, org.bdgp.io.DataAdapter, org.bdgp.io.VisualDataAdapter

public class ChadoAdapter
extends AbstractApolloAdapter

A data adapter that allows Apollo to communicate with a Chado-compliant relational database. Note that this class is one of two adapter classes required by the Apollo data adapter specification; the other one is ChadoAdapterGUI.

This data adapter was written primarily as an exercise to help me to learn the Chado schema (as it was implemented at TIGR in late 2003.) Therefore there are numerous caveats, of which a few are listed below:

Finally, here are some thoughts on two additional topics; the first is the question of SO-compliance, and the second is the issue of how to refactor the adapter to make it more configurable. 1. SO compliance: the adapter is definitely *not* SO-compliant, although it could probably be made to work with a SO-enabled version of Chado simply by looking up the cvterm_ids for the crucial elements of the central dogma on which the gene representation depends (e.g. exon, transcript, etc.) Handling inheritance properly and dynamically discovering the relationships between SO terms by querying the database, however, is likely to be a more challenging undertaking. In other words, getting it to work should be easy, but getting it to work right is likely to be hard. (Isn't this always the way?) 2. Making the adapter more configurable. Good progress has already been made on this front in terms of setting up the architecture to allow connections to different types of Chado databases (Sybase, PostgresQL, etc.), although this has not been tested. What the adapter really needs is a way for the user (or Apollo "administrator" or application programmer) to configure what annotations should be read from different data sources. One thing that significantly impeded efforts to use Apollo here at TIGR is the fact that Apollo supports only one tiers file for each data adapter. This is fine if you only have a couple of different databases, but we have tens or hundreds, each with different data, and we would really like to be able to configure the display on a finer-grained basis than is allowed by the current setup.

Version:
$Revision: 1.53 $ $Date: 2009-06-20 03:49:40 $ $Author: jcrabtree $
Author:
Jonathan Crabtree
See Also:
ChadoAdapterGUI

Field Summary
static java.lang.String CHADO_DB
           
static java.lang.String DRIVER_CLASS
           
static java.lang.String JDBC_URL
           
protected static org.apache.log4j.Logger logger
           
static java.lang.String PASSWORD
           
protected  java.util.Properties stateInfo
          The current driver properties set by the GUI in the most recent call to setStateInformation.
protected  org.bdgp.io.IOOperation[] SUPPORTED_OPS
          Array containing the list of IO operations supported by this adapter; currently the adapter supports read-only access to a Chado database.
static java.lang.String USERNAME
           
 
Fields inherited from class apollo.dataadapter.AbstractApolloAdapter
curation_set, region, 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
ChadoAdapter()
           
 
Method Summary
 java.lang.Boolean addToCurationSet()
           
 void commitChanges(CurationSet curation)
          Writes back curation set via jdbc, using the curations sets transactions
 ChadoDatabase getActiveDatabase()
          Returns active database.
 CurationSet getCurationSet()
          returns a saved CurationSet.
 java.lang.String getGFFSource()
           
 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
protected  void getSequenceList(java.lang.String featType, java.util.Vector uniquenames, java.util.Vector descriptions)
          Read a list of sequence IDs and descriptions into two parallel Vectors.
 java.util.Vector getSequences(DbXref[] dbxref)
           
 java.util.Vector getSequences(DbXref[] dbxref, int[] start, int[] end)
           
 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()
          A chado database can set its own style.
 org.bdgp.io.IOOperation[] getSupportedOperations()
          Returns a list of all operations supported by this data adapter
 java.lang.String getType()
          From org.bdgp.io.DataAdapter.
 org.bdgp.io.DataAdapterUI getUI(org.bdgp.io.IOOperation op)
          Returns a user interface for the requested IOOperation.
 boolean hasLinkData()
          Return true - this means that the features potentially have synteny data associated with them and then can be used in the synteny viewer this follows the game model of embedding links in the features
 void init()
          From org.bdgp.io.DataAdapter interface.
 void setDbLoginForDefaultDb(java.lang.String login)
          Created to modify the login/username from the command line
 void setDbPassAndActiveForDb(java.lang.String chadoDb, java.lang.String pass)
          Set password to pass for the chadoDB identified by chadoDb and set this DB as active Created to modify the password from the command line
 void setDbPassForDb(java.lang.String chadoDb, java.lang.String pass)
          Set password to pass for the chadoDB identified by chadoDb Created to modify the password from the command line
 void setDbPassForDefaultDb(java.lang.String pass)
          Created to modify the password from the command line
 void setFlatFileWriteMode(boolean flatFileWriteMode)
          Used to set the flat file write mode flag from the command line.
 void setGFFSource(java.lang.String gffSource)
           
 void setStateInformation(java.util.Properties p)
          This should set StateInformation object! see StateInformation for Strings to use for keys.
 
Methods inherited from class apollo.dataadapter.AbstractApolloAdapter
cacheUI, canWriteData, clearOldData, clearStateInformation, commitChanges, commitChanges, commitChanges, commitChanges, commitChanges, getAdapters, getCachedUI, getChildAdapter, getChildAdapter, getCurationState, getDatabase, getDataInput, getDefaultStyle, getFilename, getInput, getInputType, getName, getNameAdapter, getNumberOfChildAdapters, getSpecies, isComposite, loadNewSpeciesFromLink, operationIsSupported, rollbackAnnotations, rollbackAnnotations, setCuration, setCurationNumber, setCurationState, setDatabase, setDataInput, setDataLoadListener, setInput, setInputType, setLocation, setName, setPadLeft, setPadRight, setRegion, setSpecies, setStyle
 
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, removeProgressListener
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

DRIVER_CLASS

public static java.lang.String DRIVER_CLASS

JDBC_URL

public static java.lang.String JDBC_URL

CHADO_DB

public static java.lang.String CHADO_DB

USERNAME

public static java.lang.String USERNAME

PASSWORD

public static java.lang.String PASSWORD

stateInfo

protected java.util.Properties stateInfo
The current driver properties set by the GUI in the most recent call to setStateInformation.


SUPPORTED_OPS

protected org.bdgp.io.IOOperation[] SUPPORTED_OPS
Array containing the list of IO operations supported by this adapter; currently the adapter supports read-only access to a Chado database.

Constructor Detail

ChadoAdapter

public ChadoAdapter()
Method Detail

hasLinkData

public boolean hasLinkData()
Return true - this means that the features potentially have synteny data associated with them and then can be used in the synteny viewer this follows the game model of embedding links in the features

Specified by:
hasLinkData in interface ApolloDataAdapterI
Overrides:
hasLinkData in class AbstractApolloAdapter

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
Overrides:
getStateInformation in class AbstractApolloAdapter

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
Overrides:
setStateInformation in class AbstractApolloAdapter

getStyle

public Style getStyle()
A chado database can set its own style. Override the superclass method to get style from the ChadoDatabase configuration file.

Specified by:
getStyle in interface ApolloDataAdapterI
Overrides:
getStyle in class AbstractApolloAdapter

getCurationSet

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

Specified by:
getCurationSet in interface ApolloDataAdapterI
Overrides:
getCurationSet in class AbstractApolloAdapter
Throws:
ApolloAdapterException

commitChanges

public void commitChanges(CurationSet curation)
                   throws ApolloAdapterException
Writes back curation set via jdbc, using the curations sets transactions

Specified by:
commitChanges in interface ApolloDataAdapterI
Overrides:
commitChanges in class AbstractApolloAdapter
Throws:
ApolloAdapterException

addToCurationSet

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

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
Overrides:
getSequence in class AbstractApolloAdapter
Throws:
ApolloAdapterException

getSequence

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

getSequence

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

getSequences

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

getSequences

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

getRawAnalysisResults

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

getType

public java.lang.String getType()
Description copied from class: AbstractApolloAdapter
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
Overrides:
getType in class AbstractApolloAdapter

getSupportedOperations

public org.bdgp.io.IOOperation[] getSupportedOperations()
Description copied from interface: org.bdgp.io.DataAdapter
Returns a list of all operations supported by this data adapter


init

public void init()
Description copied from class: AbstractApolloAdapter
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
Overrides:
init in class AbstractApolloAdapter

getUI

public org.bdgp.io.DataAdapterUI getUI(org.bdgp.io.IOOperation op)
Description copied from interface: org.bdgp.io.VisualDataAdapter
Returns a user interface for the requested IOOperation. Most VisualDataAdapters will return a different user interface for each supported IOOperation.


getSequenceList

protected void getSequenceList(java.lang.String featType,
                               java.util.Vector uniquenames,
                               java.util.Vector descriptions)
                        throws ApolloAdapterException
Read a list of sequence IDs and descriptions into two parallel Vectors. The sequence IDs must be values from the chado column feature.uniquename, but the descriptions can be any unique human-readable string that adequately describes the corresponding sequence.

Parameters:
featType - The type of sequence to retrive from the feature table (e.g., 'assembly', 'super-contig')
uniquenames - Vector that will hold the sequence IDs (values from the chado column feature.uniquename)
descriptions - Vector that will hold the human-readable descriptions for the sequences named in uniquenames
Throws:
ApolloAdapterException

getActiveDatabase

public ChadoDatabase getActiveDatabase()
Returns active database. if active database has not been set, return default database


setDbPassForDefaultDb

public void setDbPassForDefaultDb(java.lang.String pass)
Created to modify the password from the command line

Parameters:
pass - : Default Db new password

setDbLoginForDefaultDb

public void setDbLoginForDefaultDb(java.lang.String login)
Created to modify the login/username from the command line

Parameters:
login - : Default Db new login/username.

setFlatFileWriteMode

public void setFlatFileWriteMode(boolean flatFileWriteMode)
Used to set the flat file write mode flag from the command line.

Parameters:
login - : Default Db new login/username.

getGFFSource

public java.lang.String getGFFSource()

setGFFSource

public void setGFFSource(java.lang.String gffSource)

setDbPassForDb

public void setDbPassForDb(java.lang.String chadoDb,
                           java.lang.String pass)
                    throws java.lang.Exception
Set password to pass for the chadoDB identified by chadoDb Created to modify the password from the command line

Parameters:
chadoDb -
pass -
Throws:
java.lang.Exception

setDbPassAndActiveForDb

public void setDbPassAndActiveForDb(java.lang.String chadoDb,
                                    java.lang.String pass)
                             throws java.lang.Exception
Set password to pass for the chadoDB identified by chadoDb and set this DB as active Created to modify the password from the command line

Parameters:
chadoDb -
pass -
Throws:
java.lang.Exception