apollo.dataadapter.chado.jdbc
Class JdbcChadoAdapter

java.lang.Object
  extended by apollo.dataadapter.chado.jdbc.JdbcChadoAdapter
Direct Known Subclasses:
PostgresChadoAdapter, SybaseChadoAdapter

public abstract class JdbcChadoAdapter
extends java.lang.Object

Abstract superclass that encapsulates vendor-independent routines for interacting with Chado-compliant relational databases. Used by apollo.dataadapter.chado.ChadoAdapter to implement the database access layer of an Apollo/Chado adapter.

Version:
$Revision: 1.205 $ $Date: 2009-02-24 16:58:44 $ $Author: gk_fan $
Author:
Jonathan Crabtree
See Also:
ChadoAdapter

Field Summary
protected  java.lang.String chadoDb
          Schema/database name of the Chado database instance.
protected  SchemaVersion chadoVersion
          Chado schema version - should this be merged with chado instance?
protected static java.util.HashMap fkcMap
           
protected  java.lang.String jdbcUrl
          JDBC URL of a Chado-compliant database (or of a server/DBMS that hosts such a database.)
protected static org.apache.log4j.Logger logger
           
protected  java.lang.String organismLike
          Used by getAllChadoSequencesByType if not null.
protected  java.lang.String password
          Database password
protected static java.util.HashMap pkcMap
           
protected static java.lang.String sqlLogPath
          Path to a file where all SQL statements are logged.
protected  java.sql.Connection transactionConnection
          Used to ensure that the same JDBC Connection is used for all write operations that are part of a single transaction.
protected static java.lang.String txnLogPath
          Path to a file where all committed Apollo transactions are logged
protected  java.lang.String username
          Database username.
 
Constructor Summary
JdbcChadoAdapter()
           
 
Method Summary
protected  void _addExonsToTranscript(Transcript t, java.util.Vector exons)
          Add a set of apollo.datamodel.Exons to an instance of apollo.datamodel.Transcript.
protected  void _addFeatures(FeatureSet fs, java.util.Vector features)
          An alternative to _makeFeatureSet.
protected  void _addFeaturesToFeatureSet(FeatureSet fs, java.util.Vector feats)
          Add a set of apollo.datamodel.SeqFeatureIs to an instance of apollo.datamodel.FeatureSet
protected  int _addTranscriptsToGene(AnnotatedFeature gene, java.util.Vector transcripts)
          Add a set of apollo.datamodel.Transcripts to an instance of apollo.datamodel.Gene.
protected  Exon _makeExon(int low, int high, int strand)
          Factory method for Exons.
protected  FeatureSet _makeFeatureSet(java.util.Vector features, java.lang.String name, java.lang.String type, int strand)
          Helper method for addSearchHits;
protected  Transcript _makeNewTranscript(Transcript t, apollo.dataadapter.chado.jdbc.ChadoCds cds)
          Create a new instance of apollo.datamodel.Transcript based on an existing template.
protected  SeqFeature _makeSeqFeature(java.lang.Integer low, java.lang.Integer high, java.lang.String type, java.lang.Integer strand)
           
protected  SeqFeature _makeSeqFeature(int low, int high, java.lang.String type, int strand)
          Factory method for SeqFeatures.
protected  void addGenePredictionResults(java.sql.Connection c, ChadoProgram[] programs, StrandedFeatureSet parentFeatSet, apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc, SequenceI refSeq)
          Retrieve gene predictions and add them to parentFeatSet as SeqFeatures.
protected  void addGenePredictionResults(java.sql.Connection c, ChadoProgram[] programs, StrandedFeatureSet parentFeatSet, apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc, SequenceI refSeq, java.lang.String scoreColumn)
          Retrieve gene predictions and add them to parentFeatSet as SeqFeatures.
protected  void addGenePredictionResults(java.sql.Connection c, java.lang.String[] programStr, StrandedFeatureSet parentFeatSet, apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc, SequenceI refSeq)
          Deprecated. use chadoProgram array instead of string array
protected  void addOneLevelAnnotations(java.sql.Connection c, SequenceI refSeq, StrandedFeatureSet sfs, apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc, boolean getFeatProps, boolean getSynonyms, boolean getDbXRefs)
          add annotations with only one level, like transposons (for now) and annotated tiling paths, promoters & what not.
protected  long addPrimaryKeyColumnValue(java.lang.String tableName, java.util.HashMap columnValues)
           
protected  void addProteinAlignments(java.sql.Connection c, java.lang.String programStr, StrandedFeatureSet sfs, apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc)
          Retrieve a set of protein alignments from Chado and convert them into instances of apollo.datmodel.FeaturePair.
protected  void addSearchHits(java.sql.Connection c, ChadoProgram[] programs, boolean setTargetSeqs, boolean getTargetSeqsSeparately, boolean lazyTgtSeqs, boolean getTargetSeqDescriptions, boolean joinWithFeatureProp, SequenceI refSeq, StrandedFeatureSet sfs, java.lang.String scoreColumn, boolean setAlignSeqs, apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc)
          Retrieve a set of search hits (e.g.
 boolean beginTransaction()
          Begin a transaction using the current JDBC Connection.
 boolean chadoFeatureExists(java.sql.Connection conn, java.lang.String seqType, java.lang.String seqId)
          Check whether a particular feature exists in a given Chado database.
 boolean chadoFeatureExists(java.sql.Connection conn, java.lang.String seqType, java.lang.String seqId, java.lang.StringBuilder realSeqId)
          Check whether a particular feature exists in a given Chado database.
 void commitChanges(CurationSet curationSet)
           
 boolean commitTransaction()
          Commit a transaction using the current JDBC Connection.
 java.lang.String computeMD5Checksum(java.lang.String seq)
           
protected  void copyAnnotatedGenesIntoResultTier(StrandedFeatureSet annotations, StrandedFeatureSet results, java.lang.String tierType, SequenceI refSeq)
          A method that copies all the annotated protein-coding genes into a result tier.
 boolean decrementGeneTranscriptRanks(java.lang.Long geneFeatureId, long newTranscriptRank)
           
 boolean decrementTranscriptExonRanks(java.lang.Long transFeatureId, long newExonRank)
           
 boolean deleteFeatureDbXrefRow(long featureId, long dbXrefId)
           
 boolean deleteFeaturepropRow(java.lang.Long featurePropId)
           
 boolean deleteFeatureRelationshipRow(java.lang.Long subjectId, java.lang.Long objectId, java.lang.Long typeId)
           
 boolean deleteFeatureSynonymRow(java.lang.Long featureId, java.lang.Long synonymId, java.lang.Integer pubId)
           
protected  int deleteReferencingRows(java.lang.String tableName, long rowId)
           
 boolean deleteRow(java.lang.String tableName, long rowId)
          Recursive delete of a row and all the rows that reference it via a foreign key constraint.
 boolean deleteSynonymRowIfNoLongerNeeded(java.lang.Long synonymId)
           
protected  boolean deleteUnreferencedRow(java.lang.String tableName, long rowId)
          Delete a row known not to be referenced by any other (e.g., because deleteReferencingRows has already been called on the row)
 java.sql.ResultSet executeLoggedSelectQuery(java.lang.String method, java.sql.Connection c, java.lang.String sql)
          Execute a single SQL query and return the corresponding ResultSet.
protected  java.sql.ResultSet executeLoggedSelectQuery(java.lang.String method, java.lang.String sql)
          Alternate form of executeLoggedSelectQuery that uses getConnection() instead of an expicitly-passed Connection object.
 int executeLoggedUpdate(java.lang.String method, java.sql.Connection c, java.lang.String sql, java.lang.String[] colNames, java.lang.Object[] colVals, java.util.Map unquotedColValues)
          Execute an SQL update statement (update, insert, or delete) and return the number of rows affected.
 void getAllChadoSequencesByType(java.lang.String featType, java.util.Vector seqUniqueNames, java.util.Vector seqDescrs)
          Retrieve the id (Chado uniquename) and description of every Chado sequence of a particular type.
protected  java.lang.String getAnalysisFeatureIdentityField()
          The analysisfeature table has a column named 'identity' in the standard Chado release.
protected abstract  java.lang.Object getBooleanValue(boolean val)
           
protected  java.util.Hashtable getCDSFeatures(java.sql.Connection c, long srcSeqId, SequenceI refSeq, StrandedFeatureSet sfs, apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLocImp)
          Front end to the main getCDSFeatures
protected  java.util.Hashtable getCDSFeatures(java.sql.Connection c, long srcSeqId, SequenceI refSeq, StrandedFeatureSet sfs, apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLocImp, ChadoProgram[] chadoPrgs)
          Front end to the main getCDSFeatures
protected  java.util.Hashtable getCDSFeatures(java.sql.Connection c, long srcSeqId, SequenceI refSeq, StrandedFeatureSet sfs, java.lang.String sql)
          Retrieve all CDS features feature-loc'ed to a Chado sequence.
 java.util.List getCdsPolypeptideIds(java.lang.Long cdsFeatureId)
           
 ChadoInstance getChadoInstance()
           
 java.lang.String getChadoProgramWhereClause(ChadoProgram[] programs, java.lang.String analysisfeatureAlias, java.lang.String analysisAlias)
          Construct a where clause that will constrain a query on analysisfeature and/or analysis to exactly those rows in the analysis table that are specified by a list of ChadoProgram objects.
protected  SchemaVersion getChadoVersion()
           
protected abstract  java.lang.String getClobLengthFunction()
           
protected  java.sql.Connection getConnection()
          Returns the current database connection, if one exists and is valid.
 java.sql.Connection getConnectionUsedForLastTransaction()
          Retrieve the JDBC Connection used to initiate the most recent transaction.
protected  java.sql.Connection getConnectionWithException()
          A variant of getConnection that throws an SQLException in the case of an SQL error.
 CurationSet getCurationSet(ChadoAdapter adapter, java.lang.String seqType, java.lang.String seqId)
           
 CurationSet getCurationSetInRange(ChadoAdapter adapter, java.lang.String seqType, Region region)
           
 java.lang.Long getDbId(java.lang.String name)
           
 java.lang.Long getDbXrefId(long dbId, java.lang.String accession, java.lang.String version)
           
 java.lang.Long getExonRank(java.lang.Long exonFeatureId, java.lang.Long transFeatureId)
           
 java.util.List getFeatNamesByType(java.lang.String featType)
          This is a stripped down version of getAllChadoSequencesByType.
 java.lang.Long getFeatureDbXrefId(long featureId, long dbXrefId)
           
protected  long getFeatureId(java.sql.Connection c, java.lang.String featType, java.lang.String featName)
          Retrieve the Chado feature.feature_id for a specified feature.
 long getFeatureId(java.lang.String featName)
          Retrieve the Chado feature.feature_id for a specified feature.
protected  long getFeatureIdBySynonym(java.sql.Connection c, java.lang.String featType, java.lang.String synonym, java.lang.StringBuilder realSeqId)
          Get feature.feature_id by searching against synonyms.
 java.lang.Long getFeatureRelationshipId(java.lang.Long subjectId, java.lang.Long objectId, java.lang.Long typeId)
           
protected  java.lang.String getFeatureType(java.lang.String alignType, java.lang.String program, java.lang.String programversion, java.lang.String targetSp, java.lang.String sourcename, java.lang.String featProp)
          Tigr and fb assign feature type differently - config!
protected  TableColumn[] getForeignKeyConstraints(java.lang.String tableName)
          Returns an array of the chado columns that reference a given table.
protected static java.util.HashMap getForeignKeyReferenceMapping()
           
 java.util.List getGeneTranscriptIds(java.lang.Long geneFeatureId)
           
protected  java.sql.Connection getNewConnection()
          Opens and return a new Connection to the database specified in the arguments to init.
 long getNextPrimaryKeyId(java.lang.String tableName)
          Run a SELECT(MAX()) + 1 query to get the next available primary key value for a chado table.
 java.lang.Long getNullCVTermId(java.lang.String name)
           
protected  java.lang.String getPrimaryKeyColumn(java.lang.String tableName)
          Returns the name of the (single) primary key column for a chado table.
protected static java.util.HashMap getPrimaryKeyColumnMapping()
           
protected  java.util.List getReferencingRowIds(java.lang.String refTable, java.lang.String refCol, long rowId)
          TODO - this is actually a generic method; all it's doing is evaluating a single equijoin (modulo quoting) and returning the row ids
 java.util.List getRelatedFeatureIds(java.lang.Long featureId, boolean isSubject, java.lang.String relTypeName, java.lang.String relFeatType)
           
 java.lang.Long getRelatedFeatureRank(java.lang.Long subjectId, java.lang.Long objectId, java.lang.String relTypeName)
           
protected  java.lang.Long getRelationshipCVTermId(java.lang.String name)
           
protected  int getSeqLengthForFeatureId(java.sql.Connection c, long seqFeatId)
          Retrieve the Chado feature.seqlen for a specified feature.
protected  SequenceI getSequence(long featureId)
          Retrieve a sequence from Chado and convert it into an instance of apollo.dataadapter.Sequence.
protected  SequenceI getSequence(long featureId, boolean isLazy, java.lang.String uniquename, int seqLength)
           
 java.lang.Long getSynonymId(java.lang.String name, java.lang.Long typeId)
           
 java.util.List getTranscriptCdsIds(java.lang.Long transFeatureId)
           
 java.util.List getTranscriptExonIds(java.lang.Long transFeatureId)
           
 java.util.List getTranscriptPolypeptideIds(java.lang.Long transFeatureId)
           
 java.lang.Long getTranscriptRank(java.lang.Long transFeatureId, java.lang.Long geneFeatureId)
           
 boolean hasOpenTransaction()
           
 boolean incrementGeneTranscriptRanks(java.lang.Long geneFeatureId, long newTranscriptRank)
           
 boolean incrementTranscriptExonRanks(java.lang.Long transFeatureId, long newExonRank)
           
 void init(java.lang.String jdbcUrl, java.lang.String chadoDb, java.lang.String username, java.lang.String password, java.lang.String organismLike)
          This method must be called before calling any of the other methods of this class (or those of its subclasses.) This will typically be done by an instance of apollo.dataadapter.chado.ChadoAdaptor.
 void initWithException(java.lang.String jdbcUrl, java.lang.String chadoDb, java.lang.String username, java.lang.String password, java.lang.String organismLike)
          This method must be called before calling any of the other methods of this class (or those of its subclasses.) This will typically be done by an instance of apollo.dataadapter.chado.ChadoAdaptor.
 java.lang.Long insertDbRowIfNeeded(java.lang.String name)
           
 java.lang.Long insertDbXrefRowIfNeeded(long dbId, java.lang.String accession, java.lang.String version, java.lang.String description)
           
 java.lang.Long insertFeatureDbXrefRow(long featureId, long dbXrefId, boolean isCurrent)
           
 java.lang.Long insertFeaturelocRow(java.lang.Long featureId, java.lang.Long srcFeatureId, java.lang.Integer fmin, java.lang.Integer fmax, boolean fmin_partial, boolean fmax_partial, java.lang.Integer strand, java.lang.Integer phase, java.lang.String residueInfo, int locgroup, long rank)
           
 java.lang.Long insertFeaturepropPubRow(java.lang.Long featPropId, java.lang.Long pubId)
           
 java.lang.Long insertFeaturepropRow(java.lang.Long featureId, java.lang.Long typeId, java.lang.String value, long rank)
           
 java.lang.Long insertFeaturepropRow(java.lang.Long featureId, java.lang.Long typeId, java.lang.String value, long rank, boolean checkNextRank)
           
 java.lang.Long insertFeatureRelationshipRow(java.lang.Long subjectId, java.lang.Long objectId, java.lang.Long typeId, java.lang.String value, java.lang.Long rank)
           
 java.lang.Long insertFeatureRow(java.lang.Long dbxrefId, long organismId, java.lang.String name, java.lang.String uniquename, java.lang.String residues, java.lang.Long seqlen, java.lang.Long typeId, java.lang.Integer isAnalysis, java.util.Date createDate)
           
 java.lang.Long insertFeatureSynonymRow(java.lang.Long synId, java.lang.Long featId, java.lang.Integer pubId, boolean is_current, boolean is_internal)
           
 java.lang.Long insertPubRowIfNeeded(java.lang.String pubUniquename, long pubTypeId)
           
 boolean insertRow(java.lang.String tableName, java.util.Map colValues, java.util.Map unquotedColValues)
          Generic method to insert a single row into a named table.
 java.lang.Long insertSynonymRowIfNeeded(java.lang.String name, java.lang.Long typeId, java.lang.String synonym_sgml)
           
protected  boolean integersTheSame(java.lang.Integer i1, java.lang.Integer i2)
           
 boolean isSharedExon(long exonId)
          Check to see if this is a shared exon (more than one transcript has it
protected  void loadClass(java.lang.String jdbcDriverClass)
          This method can be called by the subclass before calling getConnection, in order to load any needed JDBC driver classes with a Class.forName().
protected  boolean longsTheSame(java.lang.Long l1, java.lang.Long l2)
           
 boolean rollbackTransaction()
          Roll back a transaction using the current JDBC Connection.
 void setChadoInstance(ChadoInstance instance)
           
 void setPropertyScheme(PropertyScheme ps)
          need property scheme to check if type is a synteny link
protected  boolean stringsTheSame(java.lang.String s1, java.lang.String s2)
           
 boolean updateFeatureDbXrefRow(apollo.dataadapter.chado.jdbc.ChadoFeatureDbXref dbFeatDbXref, long featureId, long dbXrefId, boolean isCurrent)
           
 boolean updateFeaturelocRow(long featurelocId, apollo.dataadapter.chado.jdbc.ChadoFeatureLoc dbLoc, long featureId, java.lang.Long srcFeatureId, java.lang.Integer fmin, java.lang.Integer fmax, boolean fmin_partial, boolean fmax_partial, java.lang.Integer strand, java.lang.Integer phase, java.lang.String residueInfo, int locgroup, int rank)
           
 boolean updateFeaturepropRow(long featurepropId, apollo.dataadapter.chado.jdbc.ChadoFeatureProp dbFeatprop, long featureId, long typeId, java.lang.String value, int rank)
           
 boolean updateFeatureRelationshipRanks(java.lang.Long featureId, boolean isSubject, java.lang.String relTypeName, java.lang.String relFeatType, long newRank, boolean increment)
           
 boolean updateFeatureRow(long featureId, apollo.dataadapter.chado.jdbc.ChadoFeature dbFeat, java.lang.Long dbxrefId, long organismId, java.lang.String name, java.lang.String uniquename, java.lang.String residues, long typeId, boolean isAnalysis, boolean isObsolete)
           
 boolean updateRow(java.lang.String tableName, long id, java.util.Map colValues, java.util.Map unquotedColValues)
          Generic method to update a single row.
 void validateConnectionAndSequence(java.lang.String seqType, java.lang.String seqId)
          Check that the current connection information and the supplied sequence id are both valid.
 void validateConnectionAndSequence(java.lang.String seqType, java.lang.String seqId, java.lang.StringBuilder realSeqId)
          Check that the current connection information and the supplied sequence id are both valid.
protected  java.lang.String zeroPad(int n, int width)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

sqlLogPath

protected static java.lang.String sqlLogPath
Path to a file where all SQL statements are logged.


txnLogPath

protected static java.lang.String txnLogPath
Path to a file where all committed Apollo transactions are logged


jdbcUrl

protected java.lang.String jdbcUrl
JDBC URL of a Chado-compliant database (or of a server/DBMS that hosts such a database.)


chadoDb

protected java.lang.String chadoDb
Schema/database name of the Chado database instance.


username

protected java.lang.String username
Database username.


password

protected java.lang.String password
Database password


organismLike

protected java.lang.String organismLike
Used by getAllChadoSequencesByType if not null.


chadoVersion

protected SchemaVersion chadoVersion
Chado schema version - should this be merged with chado instance?


transactionConnection

protected java.sql.Connection transactionConnection
Used to ensure that the same JDBC Connection is used for all write operations that are part of a single transaction.


pkcMap

protected static java.util.HashMap pkcMap

fkcMap

protected static java.util.HashMap fkcMap
Constructor Detail

JdbcChadoAdapter

public JdbcChadoAdapter()
Method Detail

init

public void init(java.lang.String jdbcUrl,
                 java.lang.String chadoDb,
                 java.lang.String username,
                 java.lang.String password,
                 java.lang.String organismLike)
This method must be called before calling any of the other methods of this class (or those of its subclasses.) This will typically be done by an instance of apollo.dataadapter.chado.ChadoAdaptor.

Parameters:
jdbcUrl - JDBC URL of a Chado-compliant database (or of a server/DBMS that hosts such a database.)
chadoDb - Schema/database name of the Chado database instance.
username - Database username.
password - Database password.
organismLike - Only sequences that match this string are retrieved by getAllChadoSequencesByType.

initWithException

public void initWithException(java.lang.String jdbcUrl,
                              java.lang.String chadoDb,
                              java.lang.String username,
                              java.lang.String password,
                              java.lang.String organismLike)
                       throws java.sql.SQLException
This method must be called before calling any of the other methods of this class (or those of its subclasses.) This will typically be done by an instance of apollo.dataadapter.chado.ChadoAdaptor.

Parameters:
jdbcUrl - JDBC URL of a Chado-compliant database (or of a server/DBMS that hosts such a database.)
chadoDb - Schema/database name of the Chado database instance.
username - Database username.
password - Database password.
organismLike - Only sequences that match this string are retrieved by getAllChadoSequencesByType.
Throws:
java.sql.SQLException

executeLoggedSelectQuery

public java.sql.ResultSet executeLoggedSelectQuery(java.lang.String method,
                                                   java.sql.Connection c,
                                                   java.lang.String sql)
Execute a single SQL query and return the corresponding ResultSet. Used for all select queries to ensure that the SQL is logged.

Parameters:
method - - name of the calling method
c - - JDBC Connection
sql - - query to run

executeLoggedUpdate

public int executeLoggedUpdate(java.lang.String method,
                               java.sql.Connection c,
                               java.lang.String sql,
                               java.lang.String[] colNames,
                               java.lang.Object[] colVals,
                               java.util.Map unquotedColValues)
Execute an SQL update statement (update, insert, or delete) and return the number of rows affected. Uses a PreparedStatement to allow bound parameters to be used.

Parameters:
method - - name of the calling method
c - - JDBC Connection
sql - - query to run
colNames - - names of the affected columns (if applicable)
colVals - - values corresponding to colNames
unquotedColValues - - Map whose keys list the column names that should NOT be passed as bound parameters.
Returns:
The number of rows inserted or updated.

executeLoggedSelectQuery

protected java.sql.ResultSet executeLoggedSelectQuery(java.lang.String method,
                                                      java.lang.String sql)
Alternate form of executeLoggedSelectQuery that uses getConnection() instead of an expicitly-passed Connection object.


setPropertyScheme

public void setPropertyScheme(PropertyScheme ps)
need property scheme to check if type is a synteny link


getChadoVersion

protected SchemaVersion getChadoVersion()

zeroPad

protected java.lang.String zeroPad(int n,
                                   int width)

setChadoInstance

public void setChadoInstance(ChadoInstance instance)

getChadoInstance

public ChadoInstance getChadoInstance()

validateConnectionAndSequence

public void validateConnectionAndSequence(java.lang.String seqType,
                                          java.lang.String seqId)
                                   throws ApolloAdapterException
Check that the current connection information and the supplied sequence id are both valid. Used by the GUI to determine whether it should display an error dialog or proceed to loading the sequence and sequence annotations.

Parameters:
seqType - Name of a sequence type found in the current chado database's cvterm.name column.
seqId - A sequence identifier found in the current chado database's feature.uniquename column.
Throws:
ApolloAdapterException

validateConnectionAndSequence

public void validateConnectionAndSequence(java.lang.String seqType,
                                          java.lang.String seqId,
                                          java.lang.StringBuilder realSeqId)
                                   throws ApolloAdapterException
Check that the current connection information and the supplied sequence id are both valid. Used by the GUI to determine whether it should display an error dialog or proceed to loading the sequence and sequence annotations.

Parameters:
seqType - Name of a sequence type found in the current chado database's cvterm.name column.
seqId - A sequence identifier found in the current chado database's feature.uniquename column.
realSeqId - StringBuilder that gets updated with actual feature.uniquename (used for synonym lookups).
Throws:
ApolloAdapterException

loadClass

protected void loadClass(java.lang.String jdbcDriverClass)
This method can be called by the subclass before calling getConnection, in order to load any needed JDBC driver classes with a Class.forName().

Parameters:
jdbcDriverClass - The name of the Java class for which to do a Class.forName().

getConnection

protected java.sql.Connection getConnection()
Returns the current database connection, if one exists and is valid. If not, opens and returns a new database connection, using the connection parameters supplied in the arguments to init.

Returns:
A JDBC Connection object or null if a connection could not be opened.

getConnectionWithException

protected java.sql.Connection getConnectionWithException()
                                                  throws java.sql.SQLException
A variant of getConnection that throws an SQLException in the case of an SQL error.

Throws:
java.sql.SQLException

getNewConnection

protected java.sql.Connection getNewConnection()
                                        throws java.sql.SQLException
Opens and return a new Connection to the database specified in the arguments to init.

Throws:
java.sql.SQLException

getFeatureIdBySynonym

protected long getFeatureIdBySynonym(java.sql.Connection c,
                                     java.lang.String featType,
                                     java.lang.String synonym,
                                     java.lang.StringBuilder realSeqId)
Get feature.feature_id by searching against synonyms. Updates the synonym StringBuilder object to feature.uniquename which is expected elsewhere.

Parameters:
c - - Connection object to the database
featType - - Chado cvterm.name
synonym - - Synonym to be searched
realSeqId - - StringBuilder that gets updated with the actual id for the feature
Returns:
The feature_id of the specified chado feature or -1 if it could not be determined.

getFeatureId

protected long getFeatureId(java.sql.Connection c,
                            java.lang.String featType,
                            java.lang.String featName)
Retrieve the Chado feature.feature_id for a specified feature.

Parameters:
featType - chado cvterm.name
featName - chado feature.uniquename
Returns:
The feature_id of the specified chado feature or -1 if it could not be determined.

getSeqLengthForFeatureId

protected int getSeqLengthForFeatureId(java.sql.Connection c,
                                       long seqFeatId)
Retrieve the Chado feature.seqlen for a specified feature.

Parameters:
c - JDBC connection to use
seqFeatId - chado feature.feature_id
Returns:
The seqlen of the specified chado feature or -1 if it could not be determined.

getFeatureId

public long getFeatureId(java.lang.String featName)
Retrieve the Chado feature.feature_id for a specified feature.

Parameters:
featName - chado feature.uniquename
Returns:
The feature_id of the specified chado feature or -1 if it could not be determined.

chadoFeatureExists

public boolean chadoFeatureExists(java.sql.Connection conn,
                                  java.lang.String seqType,
                                  java.lang.String seqId)
Check whether a particular feature exists in a given Chado database. Note that this method may return false if the feature exists but is unreadable by the current user (i.e., the specified username may not have SELECT permissions on every feature in the database.)

Parameters:
conn - JDBC Connection to a Chado-compliant relational database.
seqType - Name of a sequence type found in the current chado database's cvterm.name column.
seqId - A sequence identifier found in the current chado database's feature.uniquename column.
Returns:
Whether the specified Chado feature can be found

chadoFeatureExists

public boolean chadoFeatureExists(java.sql.Connection conn,
                                  java.lang.String seqType,
                                  java.lang.String seqId,
                                  java.lang.StringBuilder realSeqId)
Check whether a particular feature exists in a given Chado database. Note that this method may return false if the feature exists but is unreadable by the current user (i.e., the specified username may not have SELECT permissions on every feature in the database.)

Parameters:
conn - JDBC Connection to a Chado-compliant relational database.
seqType - Name of a sequence type found in the current chado database's cvterm.name column.
seqId - A sequence identifier found in the current chado database's feature.uniquename column.
realSeqId - StringBuilder object that will get populated with feature.uniquename.
Returns:
Whether the specified Chado feature can be found

getAllChadoSequencesByType

public void getAllChadoSequencesByType(java.lang.String featType,
                                       java.util.Vector seqUniqueNames,
                                       java.util.Vector seqDescrs)
                                throws ApolloAdapterException
Retrieve the id (Chado uniquename) and description of every Chado sequence of a particular type.

Parameters:
featType - Name of a sequence type found in the current chado database's cvterm.name column.
seqUniqueNames - Vector to be populated with the Chado uniquenames for the sequences.
seqDescrs - Vector to be populated with human-readable sequence descriptions.
Throws:
ApolloAdapterException

getFeatNamesByType

public java.util.List getFeatNamesByType(java.lang.String featType)
This is a stripped down version of getAllChadoSequencesByType. It just returns a list of feat names, no descriptions. The problem with the other method is it's slow on postgres (outer join) and queries for descriptions that are not present in fly & rice - so this is the zippier/simpler alternative


getSequence

protected SequenceI getSequence(long featureId)
Retrieve a sequence from Chado and convert it into an instance of apollo.dataadapter.Sequence. Subsequent calls to this method with the same values of featureId and revComp are guaranteed to return the same cached object returned by the first call.

Parameters:
featureId - Chado feature.feature_id.
Returns:
The Apollo equivalent of the specified Chado sequence.

getSequence

protected SequenceI getSequence(long featureId,
                                boolean isLazy,
                                java.lang.String uniquename,
                                int seqLength)

getNullCVTermId

public java.lang.Long getNullCVTermId(java.lang.String name)

getRelationshipCVTermId

protected java.lang.Long getRelationshipCVTermId(java.lang.String name)

getCDSFeatures

protected java.util.Hashtable getCDSFeatures(java.sql.Connection c,
                                             long srcSeqId,
                                             SequenceI refSeq,
                                             StrandedFeatureSet sfs,
                                             apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLocImp,
                                             ChadoProgram[] chadoPrgs)
                                      throws apollo.dataadapter.chado.jdbc.RelationshipCVException
Front end to the main getCDSFeatures

Parameters:
c -
srcSeqId -
refSeq -
sfs -
featLocImp -
chadoPrgs -
Returns:
Throws:
RelationshipCVException
See Also:
getCDSFeatures(Connection, long, SequenceI, StrandedFeatureSet, String)

getCDSFeatures

protected java.util.Hashtable getCDSFeatures(java.sql.Connection c,
                                             long srcSeqId,
                                             SequenceI refSeq,
                                             StrandedFeatureSet sfs,
                                             apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLocImp)
                                      throws apollo.dataadapter.chado.jdbc.RelationshipCVException
Front end to the main getCDSFeatures

Parameters:
c -
srcSeqId -
refSeq -
sfs -
featLocImp -
Returns:
Throws:
RelationshipCVException
See Also:
getCDSFeatures(Connection, long, SequenceI, StrandedFeatureSet, String)

getCDSFeatures

protected java.util.Hashtable getCDSFeatures(java.sql.Connection c,
                                             long srcSeqId,
                                             SequenceI refSeq,
                                             StrandedFeatureSet sfs,
                                             java.lang.String sql)
                                      throws apollo.dataadapter.chado.jdbc.RelationshipCVException
Retrieve all CDS features feature-loc'ed to a Chado sequence.

Parameters:
c - JDBC connection to the database.
srcSeqId - Chado feature_id of the sequence whose CDS features are to be returned.
refSeq - Apollo Sequence that corresponds to Chado sequence srcSeqId
sfs - StrandedFeatureSet to which CDS features should be added when running in debug mode.
sql - Sql string wich retrieves the cds, according to featlocimp and chadoprogram[]
Returns:
A Hashtable mapping transcript.uniquename to a Vector of ChadoCds objects
Throws:
apollo.dataadapter.chado.jdbc.RelationshipCVException

addOneLevelAnnotations

protected void addOneLevelAnnotations(java.sql.Connection c,
                                      SequenceI refSeq,
                                      StrandedFeatureSet sfs,
                                      apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc,
                                      boolean getFeatProps,
                                      boolean getSynonyms,
                                      boolean getDbXRefs)
add annotations with only one level, like transposons (for now) and annotated tiling paths, promoters & what not. this also includes seq errors (if configured for in chado-adpater.xml) - indels & substitions - which get special treatment -> they end up as SequenceEdit features hanging off of genomic


addSearchHits

protected void addSearchHits(java.sql.Connection c,
                             ChadoProgram[] programs,
                             boolean setTargetSeqs,
                             boolean getTargetSeqsSeparately,
                             boolean lazyTgtSeqs,
                             boolean getTargetSeqDescriptions,
                             boolean joinWithFeatureProp,
                             SequenceI refSeq,
                             StrandedFeatureSet sfs,
                             java.lang.String scoreColumn,
                             boolean setAlignSeqs,
                             apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc)
Retrieve a set of search hits (e.g. pairwise alignments) from Chado and convert them into instances of apollo.datamodel.FeaturePair.

Parameters:
c - JDBC connection to the database.
programStr - Retrieve search hits (Chado analysisfeatures) whose Chado analysis.program matches this string.
srcRank - Chado featureloc.rank of the source sequence.
tgtRank - Chado featureloc.rank of the target sequence.
setTargetSeqs - Whether to call setRefSequence on the target Apollo features
getTargetSeqsSeparately - Whether to get the the target seqs in the main query or retrieve them with a separate query. If most or all of the hits go to 1 or just a handful of sequences, then it makes sense to retrieve separately (tigr is of this ilk). If most of the hits are to separate seqs its better to retrieve in query (flybase is of this ilk).
getTargetSeqDescriptions - if true retrieve description for target sequence. descriptions are retrieved by joining with featureprop. only useful if retrieving target seqs to begin with, if setTargetSeqs = true
joinWithFeatureProp - Whether to join the analysis features with featureprop.
refSeq - Apollo Sequence that corresponds to Chado sequence srcSeqId
sfs - StrandedFeatureSet to which the search hits should be added.
scoreColumn - analysisfeature column to use for primary feature score(setScore)
setAlignSeqs - If true set explicit query and hit seqs (once we have cigars i suspect we will need a flag for cigar vs explicit aligns
featLoc - Has srcfeature_id to use for featureloc as well as where clause for range (needed for non-redundant featlocs) and range padding maybe all the params here could be lumped into a SearchHitsParams object? programs should be changed to how one level results does it - ChadoProgram[] with programversion and sourcename and getChadoProgramWhereClause

addProteinAlignments

protected void addProteinAlignments(java.sql.Connection c,
                                    java.lang.String programStr,
                                    StrandedFeatureSet sfs,
                                    apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc)
Retrieve a set of protein alignments from Chado and convert them into instances of apollo.datmodel.FeaturePair.

Parameters:
c - JDBC connection to the database.
srcSeqId - Chado feature_id of the sequence whose protein alignments are to be returned.
programStr - Retrieve search hits (Chado analysisfeatures) whose Chado analysis.program matches this string.
sfs - StrandedFeatureSet to which the protein alignment features should be added.

addGenePredictionResults

protected void addGenePredictionResults(java.sql.Connection c,
                                        java.lang.String[] programStr,
                                        StrandedFeatureSet parentFeatSet,
                                        apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc,
                                        SequenceI refSeq)
Deprecated. use chadoProgram array instead of string array

Translates String[] programStr to ChadoProgram[] programStr and calls addGenePredictionResults (..., ChadoProgram[]...)

Parameters:
c - JDBC connection to the database.
programStr - Retrieve predictions (Chado analysisfeatures) whose Chado analysis.program matches this string. (eg genscan, piecegenie) Can do multiple programs "in ('piecegenie','genscan')" or "= 'genscan'"
parentFeatSet - StrandedFeatureSet to which the gene prediction features should be added.
featLoc - Has srcfeature_id to use for featureloc as well as where clause for range (needed for non-redundant featlocs) and range padding This was made for flybase - will probably need some tweeking if tigr or some other db needs to use this.
See Also:
#addGenePredictionResults(Connection, ChadoProgram[], StrandedFeatureSet, FeatureLocImplementation)

addGenePredictionResults

protected void addGenePredictionResults(java.sql.Connection c,
                                        ChadoProgram[] programs,
                                        StrandedFeatureSet parentFeatSet,
                                        apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc,
                                        SequenceI refSeq)
Retrieve gene predictions and add them to parentFeatSet as SeqFeatures. By default the score column is 'significance'.

Parameters:
c - JDBC connection to the database.
programStr - Retrieve predictions (Chado analysisfeatures) whose Chado analysis.program matches this program (chadoProgram.getName). (eg genscan, piecegenie) Can do multiple programs "in ('piecegenie','genscan')" or "= 'genscan'"
parentFeatSet - StrandedFeatureSet to which the gene prediction features should be added.
featLoc - Has srcfeature_id to use for featureloc as well as where clause for range (needed for non-redundant featlocs) and range padding This was made for flybase - will probably need some tweeking if tigr or some other db needs to use this.
See Also:
ChadoProgram

addGenePredictionResults

protected void addGenePredictionResults(java.sql.Connection c,
                                        ChadoProgram[] programs,
                                        StrandedFeatureSet parentFeatSet,
                                        apollo.dataadapter.chado.jdbc.FeatureLocImplementation featLoc,
                                        SequenceI refSeq,
                                        java.lang.String scoreColumn)
Retrieve gene predictions and add them to parentFeatSet as SeqFeatures.

Parameters:
c - JDBC connection to the database.
programStr - Retrieve predictions (Chado analysisfeatures) whose Chado analysis.program matches this program (chadoProgram.getName). (eg genscan, piecegenie) Can do multiple programs "in ('piecegenie','genscan')" or "= 'genscan'"
parentFeatSet - StrandedFeatureSet to which the gene prediction features should be added.
featLoc - Has srcfeature_id to use for featureloc as well as where clause for range (needed for non-redundant featlocs) and range padding This was made for flybase - will probably need some tweeking if tigr or some other db needs to use this.
scoreColumn - analysisfeature column to use for primary feature
See Also:
ChadoProgram

copyAnnotatedGenesIntoResultTier

protected void copyAnnotatedGenesIntoResultTier(StrandedFeatureSet annotations,
                                                StrandedFeatureSet results,
                                                java.lang.String tierType,
                                                SequenceI refSeq)
A method that copies all the annotated protein-coding genes into a result tier. This can be useful if the curators wish to refer back to the version of the annotation that was most recently loaded into Apollo.


getChadoProgramWhereClause

public java.lang.String getChadoProgramWhereClause(ChadoProgram[] programs,
                                                   java.lang.String analysisfeatureAlias,
                                                   java.lang.String analysisAlias)
                                            throws apollo.dataadapter.chado.jdbc.JdbcChadoAdapter.AnalysisException
Construct a where clause that will constrain a query on analysisfeature and/or analysis to exactly those rows in the analysis table that are specified by a list of ChadoProgram objects.

Parameters:
programs - Array of ChadoProgram objects that specifies the analysis rows to include.
analysisfeatureAlias - Alias of the analysisfeature table, if the query includes it.
analysisAlias - Alias of the analysis table, if the query includes it.
Returns:
Throws:
AnalysisException
apollo.dataadapter.chado.jdbc.JdbcChadoAdapter.AnalysisException

getConnectionUsedForLastTransaction

public java.sql.Connection getConnectionUsedForLastTransaction()
Retrieve the JDBC Connection used to initiate the most recent transaction.


beginTransaction

public boolean beginTransaction()
Begin a transaction using the current JDBC Connection.

Returns:
Whether the operation succeeded.

hasOpenTransaction

public boolean hasOpenTransaction()

commitTransaction

public boolean commitTransaction()
Commit a transaction using the current JDBC Connection.

Returns:
Whether the operation succeeded.

rollbackTransaction

public boolean rollbackTransaction()
Roll back a transaction using the current JDBC Connection.

Returns:
Whether the operation succeeded.

deleteRow

public boolean deleteRow(java.lang.String tableName,
                         long rowId)
Recursive delete of a row and all the rows that reference it via a foreign key constraint.

Parameters:
tableName - chado table from which the row is to be deleted
rowId - chado feature_id of the row to be deleted
Returns:
Whether the delete succeeded

deleteReferencingRows

protected int deleteReferencingRows(java.lang.String tableName,
                                    long rowId)
Returns:
Total number of rows deleted.

getReferencingRowIds

protected java.util.List getReferencingRowIds(java.lang.String refTable,
                                              java.lang.String refCol,
                                              long rowId)
TODO - this is actually a generic method; all it's doing is evaluating a single equijoin (modulo quoting) and returning the row ids

Parameters:
refTable -
refCol -
rowId -
Returns:
List of Long row ids (primary key values)

deleteUnreferencedRow

protected boolean deleteUnreferencedRow(java.lang.String tableName,
                                        long rowId)
Delete a row known not to be referenced by any other (e.g., because deleteReferencingRows has already been called on the row)

Parameters:
tableName - chado table from which the row is to be deleted
rowId - chado feature_id of the row to be deleted
Returns:
Whether the delete succeeded.

integersTheSame

protected boolean integersTheSame(java.lang.Integer i1,
                                  java.lang.Integer i2)

longsTheSame

protected boolean longsTheSame(java.lang.Long l1,
                               java.lang.Long l2)

stringsTheSame

protected boolean stringsTheSame(java.lang.String s1,
                                 java.lang.String s2)

updateFeatureRow

public boolean updateFeatureRow(long featureId,
                                apollo.dataadapter.chado.jdbc.ChadoFeature dbFeat,
                                java.lang.Long dbxrefId,
                                long organismId,
                                java.lang.String name,
                                java.lang.String uniquename,
                                java.lang.String residues,
                                long typeId,
                                boolean isAnalysis,
                                boolean isObsolete)

updateFeaturepropRow

public boolean updateFeaturepropRow(long featurepropId,
                                    apollo.dataadapter.chado.jdbc.ChadoFeatureProp dbFeatprop,
                                    long featureId,
                                    long typeId,
                                    java.lang.String value,
                                    int rank)
Parameters:
dbFeatprop - ChadoFeatureProp giving the *current* database contents

updateFeaturelocRow

public boolean updateFeaturelocRow(long featurelocId,
                                   apollo.dataadapter.chado.jdbc.ChadoFeatureLoc dbLoc,
                                   long featureId,
                                   java.lang.Long srcFeatureId,
                                   java.lang.Integer fmin,
                                   java.lang.Integer fmax,
                                   boolean fmin_partial,
                                   boolean fmax_partial,
                                   java.lang.Integer strand,
                                   java.lang.Integer phase,
                                   java.lang.String residueInfo,
                                   int locgroup,
                                   int rank)
Parameters:
dbLoc - ChadoFeatureLoc giving the *current* database contents

getPrimaryKeyColumn

protected java.lang.String getPrimaryKeyColumn(java.lang.String tableName)
Returns the name of the (single) primary key column for a chado table.


getForeignKeyConstraints

protected TableColumn[] getForeignKeyConstraints(java.lang.String tableName)
Returns an array of the chado columns that reference a given table.


getPrimaryKeyColumnMapping

protected static java.util.HashMap getPrimaryKeyColumnMapping()

getForeignKeyReferenceMapping

protected static java.util.HashMap getForeignKeyReferenceMapping()

getNextPrimaryKeyId

public long getNextPrimaryKeyId(java.lang.String tableName)
Run a SELECT(MAX()) + 1 query to get the next available primary key value for a chado table. Note that this is the preferred method to obtain new ids in Sybase (since the primary key columns are not defined as Sybase IDENTITY types, at least in the current TIGR implementation).


addPrimaryKeyColumnValue

protected long addPrimaryKeyColumnValue(java.lang.String tableName,
                                        java.util.HashMap columnValues)

insertRow

public boolean insertRow(java.lang.String tableName,
                         java.util.Map colValues,
                         java.util.Map unquotedColValues)
Generic method to insert a single row into a named table. The insert will fail if the caller does not provide a value for each non-nullable column in the table.

Parameters:
tableName - Name of the chado table into which to insert.
colValues - Map from column name to column value. May be null.
unquotedColValues - Map from column name to column value. May be null.
Returns:
Whether the insert succeeded.

updateRow

public boolean updateRow(java.lang.String tableName,
                         long id,
                         java.util.Map colValues,
                         java.util.Map unquotedColValues)
Generic method to update a single row. Only updates the supplied column values.

Parameters:
tableName - Name of the chado table to update.
colValues - Map from column name to column value. May be null.
unquotedColValues - Map from column name to column value. May be null.
Returns:
Whether the update succeeded.

computeMD5Checksum

public java.lang.String computeMD5Checksum(java.lang.String seq)

insertFeatureRow

public java.lang.Long insertFeatureRow(java.lang.Long dbxrefId,
                                       long organismId,
                                       java.lang.String name,
                                       java.lang.String uniquename,
                                       java.lang.String residues,
                                       java.lang.Long seqlen,
                                       java.lang.Long typeId,
                                       java.lang.Integer isAnalysis,
                                       java.util.Date createDate)

insertFeatureRelationshipRow

public java.lang.Long insertFeatureRelationshipRow(java.lang.Long subjectId,
                                                   java.lang.Long objectId,
                                                   java.lang.Long typeId,
                                                   java.lang.String value,
                                                   java.lang.Long rank)

deleteFeatureRelationshipRow

public boolean deleteFeatureRelationshipRow(java.lang.Long subjectId,
                                            java.lang.Long objectId,
                                            java.lang.Long typeId)

insertFeaturelocRow

public java.lang.Long insertFeaturelocRow(java.lang.Long featureId,
                                          java.lang.Long srcFeatureId,
                                          java.lang.Integer fmin,
                                          java.lang.Integer fmax,
                                          boolean fmin_partial,
                                          boolean fmax_partial,
                                          java.lang.Integer strand,
                                          java.lang.Integer phase,
                                          java.lang.String residueInfo,
                                          int locgroup,
                                          long rank)

insertFeaturepropRow

public java.lang.Long insertFeaturepropRow(java.lang.Long featureId,
                                           java.lang.Long typeId,
                                           java.lang.String value,
                                           long rank,
                                           boolean checkNextRank)

insertFeaturepropRow

public java.lang.Long insertFeaturepropRow(java.lang.Long featureId,
                                           java.lang.Long typeId,
                                           java.lang.String value,
                                           long rank)

deleteFeaturepropRow

public boolean deleteFeaturepropRow(java.lang.Long featurePropId)

insertPubRowIfNeeded

public java.lang.Long insertPubRowIfNeeded(java.lang.String pubUniquename,
                                           long pubTypeId)

insertFeaturepropPubRow

public java.lang.Long insertFeaturepropPubRow(java.lang.Long featPropId,
                                              java.lang.Long pubId)

insertSynonymRowIfNeeded

public java.lang.Long insertSynonymRowIfNeeded(java.lang.String name,
                                               java.lang.Long typeId,
                                               java.lang.String synonym_sgml)

deleteSynonymRowIfNoLongerNeeded

public boolean deleteSynonymRowIfNoLongerNeeded(java.lang.Long synonymId)

getSynonymId

public java.lang.Long getSynonymId(java.lang.String name,
                                   java.lang.Long typeId)

insertFeatureSynonymRow

public java.lang.Long insertFeatureSynonymRow(java.lang.Long synId,
                                              java.lang.Long featId,
                                              java.lang.Integer pubId,
                                              boolean is_current,
                                              boolean is_internal)

deleteFeatureSynonymRow

public boolean deleteFeatureSynonymRow(java.lang.Long featureId,
                                       java.lang.Long synonymId,
                                       java.lang.Integer pubId)

getDbId

public java.lang.Long getDbId(java.lang.String name)

insertDbRowIfNeeded

public java.lang.Long insertDbRowIfNeeded(java.lang.String name)

getDbXrefId

public java.lang.Long getDbXrefId(long dbId,
                                  java.lang.String accession,
                                  java.lang.String version)

insertDbXrefRowIfNeeded

public java.lang.Long insertDbXrefRowIfNeeded(long dbId,
                                              java.lang.String accession,
                                              java.lang.String version,
                                              java.lang.String description)

getFeatureDbXrefId

public java.lang.Long getFeatureDbXrefId(long featureId,
                                         long dbXrefId)

updateFeatureDbXrefRow

public boolean updateFeatureDbXrefRow(apollo.dataadapter.chado.jdbc.ChadoFeatureDbXref dbFeatDbXref,
                                      long featureId,
                                      long dbXrefId,
                                      boolean isCurrent)
Parameters:
dbFeatDbXref - ChadoFeatureDbXref giving the *current* database contents
featureId - New feature_id
dbXrefId - New dbxref_id
isCurrent - New value for is_current
Returns:
Returns true if the update succeeded or was not necessary.

insertFeatureDbXrefRow

public java.lang.Long insertFeatureDbXrefRow(long featureId,
                                             long dbXrefId,
                                             boolean isCurrent)

deleteFeatureDbXrefRow

public boolean deleteFeatureDbXrefRow(long featureId,
                                      long dbXrefId)

getRelatedFeatureIds

public java.util.List getRelatedFeatureIds(java.lang.Long featureId,
                                           boolean isSubject,
                                           java.lang.String relTypeName,
                                           java.lang.String relFeatType)
Parameters:
featureId - chado feature_id of the original feature
isSubject - whether featureId is the subject in the feature_relationship
relTypeName - relationship cvterm.name
Returns:
A List of (Long) feature_ids of features related to featureId

getRelatedFeatureRank

public java.lang.Long getRelatedFeatureRank(java.lang.Long subjectId,
                                            java.lang.Long objectId,
                                            java.lang.String relTypeName)

updateFeatureRelationshipRanks

public boolean updateFeatureRelationshipRanks(java.lang.Long featureId,
                                              boolean isSubject,
                                              java.lang.String relTypeName,
                                              java.lang.String relFeatType,
                                              long newRank,
                                              boolean increment)

getFeatureRelationshipId

public java.lang.Long getFeatureRelationshipId(java.lang.Long subjectId,
                                               java.lang.Long objectId,
                                               java.lang.Long typeId)

incrementTranscriptExonRanks

public boolean incrementTranscriptExonRanks(java.lang.Long transFeatureId,
                                            long newExonRank)

decrementTranscriptExonRanks

public boolean decrementTranscriptExonRanks(java.lang.Long transFeatureId,
                                            long newExonRank)

incrementGeneTranscriptRanks

public boolean incrementGeneTranscriptRanks(java.lang.Long geneFeatureId,
                                            long newTranscriptRank)

decrementGeneTranscriptRanks

public boolean decrementGeneTranscriptRanks(java.lang.Long geneFeatureId,
                                            long newTranscriptRank)

getGeneTranscriptIds

public java.util.List getGeneTranscriptIds(java.lang.Long geneFeatureId)

getTranscriptCdsIds

public java.util.List getTranscriptCdsIds(java.lang.Long transFeatureId)

getTranscriptExonIds

public java.util.List getTranscriptExonIds(java.lang.Long transFeatureId)

getCdsPolypeptideIds

public java.util.List getCdsPolypeptideIds(java.lang.Long cdsFeatureId)

getTranscriptPolypeptideIds

public java.util.List getTranscriptPolypeptideIds(java.lang.Long transFeatureId)

getExonRank

public java.lang.Long getExonRank(java.lang.Long exonFeatureId,
                                  java.lang.Long transFeatureId)

getTranscriptRank

public java.lang.Long getTranscriptRank(java.lang.Long transFeatureId,
                                        java.lang.Long geneFeatureId)

isSharedExon

public boolean isSharedExon(long exonId)
Check to see if this is a shared exon (more than one transcript has it

Parameters:
exonId - - feature.feature_id of the exon
Returns:
true if this is a shared exon

getCurationSet

public CurationSet getCurationSet(ChadoAdapter adapter,
                                  java.lang.String seqType,
                                  java.lang.String seqId)
Parameters:
adapter - ChadoAdapter on whose behalf the database accesses are to be performed.
seqType - cvterm type_id of the sequence identified by seqId
seqId - Chado feature_id of the sequence to be displayed/annotated in Apollo.

getCurationSetInRange

public CurationSet getCurationSetInRange(ChadoAdapter adapter,
                                         java.lang.String seqType,
                                         Region region)

commitChanges

public void commitChanges(CurationSet curationSet)

getFeatureType

protected java.lang.String getFeatureType(java.lang.String alignType,
                                          java.lang.String program,
                                          java.lang.String programversion,
                                          java.lang.String targetSp,
                                          java.lang.String sourcename,
                                          java.lang.String featProp)
Tigr and fb assign feature type differently - config!


getAnalysisFeatureIdentityField

protected java.lang.String getAnalysisFeatureIdentityField()
The analysisfeature table has a column named 'identity' in the standard Chado release. In the TIGR Sybase port of Chado this column had to be renamed, since 'identity' is a reserved word in Sybase. The Sybase adapter overrides this method to return the appropriate column name.


getBooleanValue

protected abstract java.lang.Object getBooleanValue(boolean val)
Returns:
The Java object that represents the "true" or "false" value for chado columns of type boolean.

getClobLengthFunction

protected abstract java.lang.String getClobLengthFunction()
Returns:
The name of a function that can be used to compute the length (in characters) of a CLOB (Character Large OBject) or TEXT value.

_addTranscriptsToGene

protected int _addTranscriptsToGene(AnnotatedFeature gene,
                                    java.util.Vector transcripts)
Add a set of apollo.datamodel.Transcripts to an instance of apollo.datamodel.Gene.

Parameters:
gene - Gene to which the transcripts should be added.
transcripts - A Vector of apollo.datamodel.Transcript objects. Cleared after the transcripts are added.
Returns:
The number of transcripts added.

_addExonsToTranscript

protected void _addExonsToTranscript(Transcript t,
                                     java.util.Vector exons)
Add a set of apollo.datamodel.Exons to an instance of apollo.datamodel.Transcript.

Parameters:
t - Transcript to which the exons should be added.
exons - A Vector of apollo.datamodel.Exon objects. Cleared after the exons are added.

_addFeaturesToFeatureSet

protected void _addFeaturesToFeatureSet(FeatureSet fs,
                                        java.util.Vector feats)
Add a set of apollo.datamodel.SeqFeatureIs to an instance of apollo.datamodel.FeatureSet

Parameters:
t - FeatureSet to which the subfeatures should be added.
exons - A Vector of apollo.datamodel.SeqFeatureI objects. Cleared after the features are added.

_makeNewTranscript

protected Transcript _makeNewTranscript(Transcript t,
                                        apollo.dataadapter.chado.jdbc.ChadoCds cds)
Create a new instance of apollo.datamodel.Transcript based on an existing template.

Parameters:
t - A template Transcript on which to base the new object.
cds - ChadoCds that specifies the coding region of the new transcript.
Returns:
A new Transcript whose coding region is described by cds.

_makeFeatureSet

protected FeatureSet _makeFeatureSet(java.util.Vector features,
                                     java.lang.String name,
                                     java.lang.String type,
                                     int strand)
Helper method for addSearchHits;

Parameters:
features -
name -
type -
strand -
Returns:

_addFeatures

protected void _addFeatures(FeatureSet fs,
                            java.util.Vector features)
An alternative to _makeFeatureSet.

Parameters:
fs -
features -

_makeSeqFeature

protected SeqFeature _makeSeqFeature(int low,
                                     int high,
                                     java.lang.String type,
                                     int strand)
Factory method for SeqFeatures.

Parameters:
low -
high -
type -
strand -
Returns:

_makeSeqFeature

protected SeqFeature _makeSeqFeature(java.lang.Integer low,
                                     java.lang.Integer high,
                                     java.lang.String type,
                                     java.lang.Integer strand)

_makeExon

protected Exon _makeExon(int low,
                         int high,
                         int strand)
Factory method for Exons.

Parameters:
low -
high -
strand -
Returns: