apollo.dataadapter.chado.jdbc
Class PureJDBCTransactionWriter

java.lang.Object
  extended by apollo.dataadapter.chado.jdbc.PureJDBCTransactionWriter
Direct Known Subclasses:
JdbcChadoWriter

public class PureJDBCTransactionWriter
extends java.lang.Object

An alternative to JDBCTransactionWriter that:

Version:
$Revision: 1.37 $ $Date: 2009-06-25 17:26:50 $ $Author: gk_fan $
Author:
Jonathan Crabtree

Field Summary
protected  ChadoAdapter adapter
           
protected  boolean copyOnWrite
           
protected  JdbcChadoAdapter jdbcAdapter
           
protected  boolean logApolloTransactions
           
protected static org.apache.log4j.Logger logger
           
protected  boolean logSql
           
protected  boolean noCommit
           
protected  boolean useCDS
           
 
Constructor Summary
PureJDBCTransactionWriter(ChadoAdapter adapter, JdbcChadoAdapter jdbcAdapter, boolean copyOnWrite, boolean noCommit, boolean useCDS)
           
 
Method Summary
protected  boolean addComment(long annotId, Comment comment)
          Add a comment to the database
protected  boolean addComment(SeqFeatureI feature, AddTransaction t)
          Comment strings look like this: Only one EST supports this alternative transcript::DATE:Mon Feb 26 18:08:49 CET 2007::TS:1172509728919 With the author in the pub table
protected  void addComments(AnnotatedFeatureI annot)
          Add all comments from an AnnotatedFeatureI object
protected  boolean addDbXref(long featureId, DbXref dbx)
           
protected  boolean addDbXref(SeqFeatureI feature, AddTransaction t)
           
protected  void addDbxrefs(AnnotatedFeatureI annot)
          Add all dbxrefs from an AnnotatedFeatureI object
protected  java.lang.Long addExon(SeqFeatureI exon, java.lang.String author, java.util.Date date, java.lang.Long transId, int exonNum, apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature, boolean checkExons)
          Add an exon to a transcript, inserting the exon into the database if it does not already exist.
protected  java.lang.Long addGene(SeqFeatureI gene, java.lang.String author, java.util.Date date, apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature, boolean checkExons)
          Add a gene to the chado database.
protected  java.lang.Long addSequenceEdit(SequenceEdit seqEdit, java.lang.String author, java.util.Date date)
           
protected  boolean addSynonym(long annotId, java.lang.String name)
          Add a synonym to the database
protected  boolean addSynonym(SeqFeatureI feature, AddTransaction t)
           
protected  void addSynonyms(AnnotatedFeatureI annot)
          Add all synonyms from an AnnotatedFeatureI object
protected  java.lang.Long addTopLevelAnnot(SeqFeatureI annot, java.lang.String author, java.util.Date date, apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature)
          Add a top level annotation to the chado database.
protected  java.lang.Long addTranscript(Transcript transcript, java.lang.String author, java.util.Date date, java.lang.Long geneId, long transcriptRank, apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature, boolean checkExons)
          Add a transcript to the chado database.
protected  boolean commitAddTransaction(java.lang.String transId, AddTransaction t, boolean checkExons)
           
protected  boolean commitDeleteTransaction(java.lang.String transId, DeleteTransaction dt)
           
protected  boolean commitTransaction(java.lang.String transId, int numTransactions, Transaction t, boolean checkExons)
           
 boolean commitTransactions(TransactionManager tm)
          Write a set of transactions to the database using adapter
protected  boolean commitUpdateParentTransaction(java.lang.String transId, UpdateParentTransaction t)
           
protected  boolean commitUpdateTransaction(java.lang.String transId, UpdateTransaction ut)
           
protected  boolean deleteCDS(long featureId)
           
protected  boolean deleteComment(long annotId, Comment comment)
           
protected  boolean deleteDbXref(long annotId, DbXref dbXref)
           
protected  boolean deleteExon(long exonId, long transcriptId)
          Delete an exon from the database (defaults to not checking if it is a shared exon
protected  boolean deleteExon(long exonId, long transcriptId, boolean checkExon)
          Delete an exon from the database
protected  boolean deleteGene(long featureId)
           
protected  boolean deletePolypeptide(long featureId)
           
protected  boolean deleteSynonym(long annotId, java.lang.String name)
          Delete a synonym from the database
protected  boolean deleteTranscript(long featureId)
           
protected  boolean deleteTranscript(long featureId, boolean checkExons)
           
protected  void fatalError(java.lang.String error)
           
protected  apollo.dataadapter.chado.jdbc.ChadoCds getCdsCoordinatesFromTranscript(Transcript transcript, int tfmin, int tfmax)
          Figure out chado CDS coordinates and sequence based on the Apollo transcript.
protected  java.lang.String getChadoCdsName(ApolloNameAdapterI nameAdapter, java.lang.String name)
           
protected  long getChadoFeatureId(SeqFeatureI feature)
           
protected  long getChadoIdForFeature(SeqFeatureI f)
          Retrieve the chado primary key value for a given feature, or -1 if the feature does not exist in the database.
protected  int getChadoIsAnalysis(SeqFeatureI feat)
          Determine what value to place in the chado feature.is_analysis column for an Apollo feature.
protected  int getChadoLocgroup(long feature_id, apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature)
           
protected  int getChadoLocgroup(SeqFeatureI feat, apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature)
          Compute the chado featureloc.locgroup for an Apollo feature.
protected  java.lang.String getChadoPeptideName(ApolloNameAdapterI nameAdapter, java.lang.String name, SeqFeatureI pfeat)
           
protected  java.lang.Long getChadoPrimaryDbxrefId(SeqFeatureI feat)
          Determine what to put in the feature.dbxref_id column for an Apollo feature.
protected  java.lang.Long getChadoRelationshipCvTermId(java.lang.String cvName)
           
protected  java.lang.String getChadoResidues(SeqFeatureI feat)
          Determine what value to place in the chado feature.residues column for an Apollo feature.
protected  AnnotatedFeatureI getSeqEditRefFeature(SequenceEdit seqEdit)
           
protected  void logTransactionList(java.util.List tlist)
           
protected  boolean updateCdsFeatureLocation(long featureId, Transcript transcript, RangeI oldLocn)
          Update the location of a transcript's CDS and polypeptide.
protected  boolean updateFeatureLocation(long featureId, RangeI oldLocn, apollo.dataadapter.chado.jdbc.ChadoFeatureLoc newLoc)
          Update the location of a gene-related feature, e.g.
protected  boolean updateFeatureName(long featureId, java.lang.String newName, boolean isName)
          Update the name
protected  boolean updateFeatureType(long featureId, java.lang.String newType)
          Update the type
protected  boolean updateOwner(long annotId, java.lang.String newStatus, java.lang.String oldStatus)
           
protected  boolean updateStatus(long annotId, java.lang.String statusTerm, java.lang.String newStatus, java.lang.String oldStatus)
           
 
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

adapter

protected ChadoAdapter adapter

jdbcAdapter

protected JdbcChadoAdapter jdbcAdapter

copyOnWrite

protected boolean copyOnWrite

noCommit

protected boolean noCommit

logApolloTransactions

protected boolean logApolloTransactions

logSql

protected boolean logSql

useCDS

protected boolean useCDS
Constructor Detail

PureJDBCTransactionWriter

public PureJDBCTransactionWriter(ChadoAdapter adapter,
                                 JdbcChadoAdapter jdbcAdapter,
                                 boolean copyOnWrite,
                                 boolean noCommit,
                                 boolean useCDS)
Parameters:
adapter - ChadoAdapter to use for writing changes
jdbcAdapter - JdbcChadoAdapter to use for writing changes
copyOnWrite - Whether to keep a copy of the old object(s) when writing changes.
noCommit - Whether to run in 'no commit' mode.
Method Detail

commitTransactions

public boolean commitTransactions(TransactionManager tm)
Write a set of transactions to the database using adapter

Parameters:
tm - TransactionManager that contains the uncommitted transactions to write.
Returns:
Whether the commit succeeded.

logTransactionList

protected void logTransactionList(java.util.List tlist)

commitTransaction

protected boolean commitTransaction(java.lang.String transId,
                                    int numTransactions,
                                    Transaction t,
                                    boolean checkExons)
Parameters:
checkExons - whether to check database for exons in addExon

getChadoFeatureId

protected long getChadoFeatureId(SeqFeatureI feature)
Returns:
The chado feature_id or -1 if it could not be determined.

commitUpdateParentTransaction

protected boolean commitUpdateParentTransaction(java.lang.String transId,
                                                UpdateParentTransaction t)

commitAddTransaction

protected boolean commitAddTransaction(java.lang.String transId,
                                       AddTransaction t,
                                       boolean checkExons)
Parameters:
checkExons - whether to check database for exons in addExon

addTopLevelAnnot

protected java.lang.Long addTopLevelAnnot(SeqFeatureI annot,
                                          java.lang.String author,
                                          java.util.Date date,
                                          apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature)
Add a top level annotation to the chado database.

Parameters:
annot - Apollo feature that represents the top level annotation
author - Author string from the Apollo transaction.
date - Date from the Apollo transaction.
srcFeature - Chado feature on which the gene is located. May be null.
Returns:
The chado feature.feature_id of the gene feature.

addGene

protected java.lang.Long addGene(SeqFeatureI gene,
                                 java.lang.String author,
                                 java.util.Date date,
                                 apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature,
                                 boolean checkExons)
Add a gene to the chado database.

Parameters:
gene - Apollo feature that represents the gene.
author - Author string from the Apollo transaction.
date - Date from the Apollo transaction.
srcFeature - Chado feature on which the gene is located. May be null.
checkExons - whether to check database for exons in addExon
Returns:
The chado feature.feature_id of the gene feature.

addTranscript

protected java.lang.Long addTranscript(Transcript transcript,
                                       java.lang.String author,
                                       java.util.Date date,
                                       java.lang.Long geneId,
                                       long transcriptRank,
                                       apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature,
                                       boolean checkExons)
Add a transcript to the chado database.

Parameters:
transcript - Apollo feature that represents the transcript/mRNA.
author - Author string from the Apollo transaction.
date - Date from the Apollo transaction.
geneId - Chado feature.feature_id of the gene to which the transcript belongs.
transcriptRank - Rank of the transcript with respect to the gene.
srcFeature - Chado feature on which the transcript is located. May be null.
checkExons - whether to check database for exons in addExon
Returns:
The chado feature.feature_id of the transcript feature.

addExon

protected java.lang.Long addExon(SeqFeatureI exon,
                                 java.lang.String author,
                                 java.util.Date date,
                                 java.lang.Long transId,
                                 int exonNum,
                                 apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature,
                                 boolean checkExons)
Add an exon to a transcript, inserting the exon into the database if it does not already exist.

Parameters:
exon - Apollo feature that represents the exon.
author - Author string from the Apollo transaction.
date - Date from the Apollo transaction.
transId - Chado feature.feature_id of the transcript to which the exon belongs.
exonNum - Index of the exon in the transcript (counting from 0, as per chado feature_relationship.rank)
srcFeature - Chado feature on which the exon is located. May be null.
checkExons - whether to check database for exons in addExon
Returns:
The chado feature.feature_id of the exon feature.

addSynonym

protected boolean addSynonym(SeqFeatureI feature,
                             AddTransaction t)

addComment

protected boolean addComment(SeqFeatureI feature,
                             AddTransaction t)
Comment strings look like this: Only one EST supports this alternative transcript::DATE:Mon Feb 26 18:08:49 CET 2007::TS:1172509728919 With the author in the pub table


addDbxrefs

protected void addDbxrefs(AnnotatedFeatureI annot)
Add all dbxrefs from an AnnotatedFeatureI object

Parameters:
annot - - annotation to store dbxrefs from

addDbXref

protected boolean addDbXref(SeqFeatureI feature,
                            AddTransaction t)

addDbXref

protected boolean addDbXref(long featureId,
                            DbXref dbx)

deleteDbXref

protected boolean deleteDbXref(long annotId,
                               DbXref dbXref)

addSequenceEdit

protected java.lang.Long addSequenceEdit(SequenceEdit seqEdit,
                                         java.lang.String author,
                                         java.util.Date date)

getChadoLocgroup

protected int getChadoLocgroup(SeqFeatureI feat,
                               apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature)
Compute the chado featureloc.locgroup for an Apollo feature.

Parameters:
feat - Apollo feature.
srcFeature - Chado feature on which feat is located (determines locgroup).

getChadoLocgroup

protected int getChadoLocgroup(long feature_id,
                               apollo.dataadapter.chado.jdbc.ChadoFeature srcFeature)

getChadoPrimaryDbxrefId

protected java.lang.Long getChadoPrimaryDbxrefId(SeqFeatureI feat)
Determine what to put in the feature.dbxref_id column for an Apollo feature.

Parameters:
feat - Apollo feature.

getChadoIsAnalysis

protected int getChadoIsAnalysis(SeqFeatureI feat)
Determine what value to place in the chado feature.is_analysis column for an Apollo feature.

Parameters:
feat - Apollo feature.

getChadoResidues

protected java.lang.String getChadoResidues(SeqFeatureI feat)
Determine what value to place in the chado feature.residues column for an Apollo feature.

Parameters:
feat - Apollo feature

getChadoRelationshipCvTermId

protected java.lang.Long getChadoRelationshipCvTermId(java.lang.String cvName)

commitDeleteTransaction

protected boolean commitDeleteTransaction(java.lang.String transId,
                                          DeleteTransaction dt)

deleteExon

protected boolean deleteExon(long exonId,
                             long transcriptId)
Delete an exon from the database (defaults to not checking if it is a shared exon

Parameters:
exonId - - feature.feature_id of the exon
transcriptId - - feature.feature_id of the parent transcript
Returns:
whether the exon was successfully deleted

deleteExon

protected boolean deleteExon(long exonId,
                             long transcriptId,
                             boolean checkExon)
Delete an exon from the database

Parameters:
exonId - - feature.feature_id of the exon
transcriptId - - feature.feature_id of the parent transcript
checkExon - - check to see that this exon is not shared before deletion
Returns:
whether the exon was successfully deleted

deleteTranscript

protected boolean deleteTranscript(long featureId)

deleteTranscript

protected boolean deleteTranscript(long featureId,
                                   boolean checkExons)

deleteCDS

protected boolean deleteCDS(long featureId)

deletePolypeptide

protected boolean deletePolypeptide(long featureId)

deleteGene

protected boolean deleteGene(long featureId)

commitUpdateTransaction

protected boolean commitUpdateTransaction(java.lang.String transId,
                                          UpdateTransaction ut)

updateCdsFeatureLocation

protected boolean updateCdsFeatureLocation(long featureId,
                                           Transcript transcript,
                                           RangeI oldLocn)
Update the location of a transcript's CDS and polypeptide.

Parameters:
featureId - Chado feature id that corresponds to transcript
transcript - Apollo transcript whose peptide has changed
oldLocn - The range of the old CDS feature location. MAY BE NULL.

updateFeatureLocation

protected boolean updateFeatureLocation(long featureId,
                                        RangeI oldLocn,
                                        apollo.dataadapter.chado.jdbc.ChadoFeatureLoc newLoc)
Update the location of a gene-related feature, e.g. exon, transcript, or gene


updateFeatureName

protected boolean updateFeatureName(long featureId,
                                    java.lang.String newName,
                                    boolean isName)
Update the name


updateFeatureType

protected boolean updateFeatureType(long featureId,
                                    java.lang.String newType)
Update the type


fatalError

protected void fatalError(java.lang.String error)

getChadoIdForFeature

protected long getChadoIdForFeature(SeqFeatureI f)
Retrieve the chado primary key value for a given feature, or -1 if the feature does not exist in the database. TODO - move this into the name adapter; could be different for different sites/dbs. see earlier comments


getCdsCoordinatesFromTranscript

protected apollo.dataadapter.chado.jdbc.ChadoCds getCdsCoordinatesFromTranscript(Transcript transcript,
                                                                                 int tfmin,
                                                                                 int tfmax)
Figure out chado CDS coordinates and sequence based on the Apollo transcript. In Apollo the CDS feature coordinates are genomic coordinates corresponding to the 1st base of the start codon and the 1st base of the stop codon, respectively


addSynonyms

protected void addSynonyms(AnnotatedFeatureI annot)
Add all synonyms from an AnnotatedFeatureI object

Parameters:
annot - - annotation to store synonyms from

addSynonym

protected boolean addSynonym(long annotId,
                             java.lang.String name)
Add a synonym to the database

Parameters:
annotId - - Chado ID for owner annotation
name - - Synonym
Returns:
true if successful

deleteSynonym

protected boolean deleteSynonym(long annotId,
                                java.lang.String name)
Delete a synonym from the database

Parameters:
annotId - - Chado ID for owner annotation
name - - Synonym
Returns:
true if successful

addComments

protected void addComments(AnnotatedFeatureI annot)
Add all comments from an AnnotatedFeatureI object

Parameters:
annot - - annotation to store comments from

addComment

protected boolean addComment(long annotId,
                             Comment comment)
Add a comment to the database

Parameters:
annotId - - Chado ID for owner annotation
comment - - Comment object
Returns:
true if successful

deleteComment

protected boolean deleteComment(long annotId,
                                Comment comment)

updateStatus

protected boolean updateStatus(long annotId,
                               java.lang.String statusTerm,
                               java.lang.String newStatus,
                               java.lang.String oldStatus)

updateOwner

protected boolean updateOwner(long annotId,
                              java.lang.String newStatus,
                              java.lang.String oldStatus)

getChadoCdsName

protected java.lang.String getChadoCdsName(ApolloNameAdapterI nameAdapter,
                                           java.lang.String name)

getChadoPeptideName

protected java.lang.String getChadoPeptideName(ApolloNameAdapterI nameAdapter,
                                               java.lang.String name,
                                               SeqFeatureI pfeat)

getSeqEditRefFeature

protected AnnotatedFeatureI getSeqEditRefFeature(SequenceEdit seqEdit)