org.intermine.bio.dataconversion
Class ChadoDBConverter

java.lang.Object
  extended by org.intermine.dataconversion.DataConverter
      extended by org.intermine.dataconversion.DBConverter
          extended by org.intermine.bio.dataconversion.BioDBConverter
              extended by org.intermine.bio.dataconversion.ChadoDBConverter
Direct Known Subclasses:
GenomeDBConverter

public class ChadoDBConverter
extends BioDBConverter

DataConverter to read from a Chado database into items


Field Summary
protected static org.apache.log4j.Logger LOG
           
 
Constructor Summary
ChadoDBConverter(Database database, Model tgtModel, ItemWriter writer)
          Create a new ChadoDBConverter object.
 
Method Summary
 ChadoProcessor findProcessor(java.lang.Class<? extends ChadoProcessor> cls)
          Look at the list of completed processors and return the processor of the given type.
 java.util.Map<java.lang.Integer,OrganismData> getChadoIdToOrgDataMap()
          Return a map from chado organism_id to OrganismData object for all the organisms that we are processing
protected  java.util.Map<OrganismData,java.lang.Integer> getChadoOrganismIds(java.sql.Connection conn)
          Return a map from chado organism id to OrganismData for the organisms in the organism table in chado.
 java.util.List<ChadoProcessor> getCompletedProcessors()
           
protected  java.sql.Connection getConnection()
          Get the connection to use when processing.
 java.lang.String getDataSetTitle(int taxonId)
          Default implementation that makes a data set title based on the data source name.
 java.util.Set<OrganismData> getOrganismsToProcess()
          Return the OrganismData objects for the organisms listed in the source configuration.
 void process()
          Process the data from the Database and write to the ItemWriter.
 void setOrganisms(java.lang.String organisms)
          Set the taxon ids to use when creating the Organism Item for the new features.
 void setProcessors(java.lang.String processors)
          Set the class names of the ChadoProcessors to run.
 
Methods inherited from class org.intermine.bio.dataconversion.BioDBConverter
createSynonym, getChromosome, getDataSetItem, getDataSetItem, getDataSetItem, getDataSourceItem, getDataSourceItem, getDataSourceName, getOrganismItem, getSequenceOntologyRefId, makeLocation, setDataSourceName
 
Methods inherited from class org.intermine.dataconversion.DBConverter
getDatabase
 
Methods inherited from class org.intermine.dataconversion.DataConverter
addUniqueItemId, alias, createItem, getItemWriter, getModel, getUniqueItemId, newId, setStoreHook, store, store, store, store, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.log4j.Logger LOG
Constructor Detail

ChadoDBConverter

public ChadoDBConverter(Database database,
                        Model tgtModel,
                        ItemWriter writer)
                 throws java.sql.SQLException
Create a new ChadoDBConverter object.

Parameters:
database - the database to read from
tgtModel - the Model used by the object store we will write to with the ItemWriter
writer - an ItemWriter used to handle the resultant Items
Throws:
java.sql.SQLException - if we fail to get a database connection
Method Detail

setOrganisms

public void setOrganisms(java.lang.String organisms)
Set the taxon ids to use when creating the Organism Item for the new features. Only features from chado with these organisms will be processed.

Parameters:
organisms - a space separated list of the organism abbreviations or taxon ids to look up in the organism table eg. "Dmel Dpse"

setProcessors

public void setProcessors(java.lang.String processors)
Set the class names of the ChadoProcessors to run.

Parameters:
processors - a space separated list of the fully-qualified class names of module processors to run

getChadoIdToOrgDataMap

public java.util.Map<java.lang.Integer,OrganismData> getChadoIdToOrgDataMap()
Return a map from chado organism_id to OrganismData object for all the organisms that we are processing

Returns:
the Map

getConnection

protected java.sql.Connection getConnection()
Get the connection to use when processing.

Returns:
the Connection, or null while testing

process

public void process()
             throws java.lang.Exception
Process the data from the Database and write to the ItemWriter. Query from database and write items to the writer.

Specified by:
process in class DBConverter
Throws:
java.lang.Exception - if there is a problem while processing

getChadoOrganismIds

protected java.util.Map<OrganismData,java.lang.Integer> getChadoOrganismIds(java.sql.Connection conn)
                                                                     throws java.sql.SQLException
Return a map from chado organism id to OrganismData for the organisms in the organism table in chado. This is a protected method so that it can be overriden for testing

Parameters:
conn - the db connection
organismsToProcess2 -
Returns:
a Map from abbreviation to chado organism_id
Throws:
java.sql.SQLException - if the is a database problem

getOrganismsToProcess

public java.util.Set<OrganismData> getOrganismsToProcess()
Return the OrganismData objects for the organisms listed in the source configuration.

Returns:
the organismsToProcess

findProcessor

public ChadoProcessor findProcessor(java.lang.Class<? extends ChadoProcessor> cls)
Look at the list of completed processors and return the processor of the given type. If there is none or more than one, throw a RuntimeException

Parameters:
cls - the class
Returns:
the ChadoProcessor

getDataSetTitle

public java.lang.String getDataSetTitle(int taxonId)
Default implementation that makes a data set title based on the data source name. Return the DataSet title for a given taxon id.

Specified by:
getDataSetTitle in class BioDBConverter
Parameters:
taxonId - the taxon id
Returns:
the title

getCompletedProcessors

public java.util.List<ChadoProcessor> getCompletedProcessors()
Returns:
the completedProcessors