PianaInsertSQL
index
../../../../piana/code/PianaDB/PianaInsertSQL.py

 File       : PianaInsertSQL.py
 Author     : R. Aragues & D. Jaeggi
 Creation   : 2003
 Contents   : subclasses for generating insert sql statements
 Called from: PianaDBaccess
 
=======================================================================================================
 
This class is used in the same way as PianaSelectSQL
 
Each of the subclasses creates an sql query string that can be used to insert information into Piana
 
This is done this way to generalize as much as possible the interaction of users with the database pianaDB.
 
A user that needs to insert information into pianaDB will not create the SQL statement himself, but will
use one of these classes, together with method insert_db_content() of class PianaDB
 
class PianaDBaccess integrates into a single and clear interface all the access to piana databases

 
Modules
       
PianaGlobals
sys

 
Classes
       
PianaInsertSQL
CreateIndice
DeleteElementsFromTempTable
DeleteExternalDatabase
DeleteInteraction
DeleteInteractionMethod
DeleteInteractionProteinSource
DeleteInteractionScores
DeleteRecords
DeleteTempTableIdentifier
DropIndice
InsertBlastResult
InsertCog
InsertElementsFromTempTable
InsertExternalDatabaseInformationType
InsertGeneralizedProteinExternalID
InsertGo
InsertGo_term2term_distance
InsertInteraction
InsertInteractionFeatures
InsertInteractionMethod
InsertInteractionProteinSource
InsertInteractionScores
InsertNewExternalDatabase
InsertNewProteinIdType
InsertProtein
InsertProteinAttributeRelationship
InsertProteinCathRelationship
InsertProteinCode2
InsertProteinDBAliRelationship
InsertProteinExternalID
InsertProteinPdbCode
InsertProteinPianaCounter
InsertProteinScopRelationship
InsertProteinSimilarity
InsertReactome
InsertSequence
InsertSpecies
InsertTemporalTable
MultipleInsert
UpdateENUMcolumn
UpdateSourceDBID
UpdateSourceDBIDfromTempTable
UpdateSourceDBSet
UpdateSpeciesKingdom
UpdateTableColumn

 
class CreateIndice(PianaInsertSQL)
    Generates sql statement to insert information on a Buffer Element Object
 
  Static methods defined here:
get_sqlquery(table, indice_name, columns)
"columns" must be a tuple with the name of the columns

 
class DeleteElementsFromTempTable(PianaInsertSQL)
     Static methods defined here:
get_sqlquery(identifier, table, conditions)

 
class DeleteExternalDatabase(PianaInsertSQL)
    Generates sql statement to delete an external database from databases table
 
  Static methods defined here:
get_sqlquery(databaseName=None)

 
class DeleteInteraction(PianaInsertSQL)
    Generates sql statement to delete an interaction entry from table interaction
 
  Static methods defined here:
get_sqlquery(interactionPiana_value)

 
class DeleteInteractionMethod(PianaInsertSQL)
    Generates sql statement to delete an interaction entry from table interactionMethod
 
It can be used to delete a particular interactionPiana or just those entries that belong to a specific source db or those with a method ID
 
  - if interactionPiana_value 'not None' --> delete entries where interactionPiana = interactionPiana_value
 
  - if sourceDBID_value 'not None' -->  delete entries where sourceDBID = sourceDBID_value
 
  - if methodID_value 'not None' -->  delete entries where methodID = methodID_value
 
Only one argument can be 'not None'
 
  Static methods defined here:
get_sqlquery(interactionPiana_value=None, sourceDBID_value=None, methodID_value=None)

 
class DeleteInteractionProteinSource(PianaInsertSQL)
    Generates sql statement to delete an interaction protein source entry from table interactionProteinSource
 
It can be used to delete a particular interactionPiana or just those entries that belong to a specific source db
 
  - if interactionPiana_value 'not None' --> delete entries where interactionPiana = interactionPiana_value
 
  - if sourceDBID_value 'not None' -->  delete entries where sourceDBID = sourceDBID_value
 
Only one argument can be 'not None'
 
  Static methods defined here:
get_sqlquery(interactionPiana_value=None, sourceDBID_value=None)

 
class DeleteInteractionScores(PianaInsertSQL)
    Generates sql statement to delete an interaction scores entry from table interactionScores
 
It can be used to delete a particular interactionPiana or just those entries that belong to a specific source db
 
  - if interactionPiana_value 'not None' --> delete entries where interactionPiana = interactionPiana_value
 
  - if sourceDBID_value 'not None' -->  delete entries where sourceDBID = sourceDBID_value
 
 
Only one argument can be 'not None'
 
  Static methods defined here:
get_sqlquery(interactionPiana_value=None, sourceDBID_value=None)

 
class DeleteRecords(PianaInsertSQL)
    Generates sql statement that deletes those records in a database table with a column with a determined value
 
  Static methods defined here:
get_sqlquery(table, field, value)

 
class DeleteTempTableIdentifier(PianaInsertSQL)
     Static methods defined here:
get_sqlquery()
#def get_sqlquery(identifier):

 
class DropIndice(PianaInsertSQL)
    Generates the sql statement to drop an index in the database
 
  Static methods defined here:
get_sqlquery(table, indice_name)

 
class InsertBlastResult(PianaInsertSQL)
    Generates sql statement to insert blast result on table blastResults
 
  Static methods defined here:
get_sqlquery(sequenceID_A, sequenceID_B, score, bit_score, start_A, end_A, start_B, end_B, identities, similarity, gaps, program, filter, buffer=None)

 
class InsertCog(PianaInsertSQL)
    Generates sql statement to insert information on table cog
 
  Static methods defined here:
get_sqlquery(cogID_value, cogDescription_value, cogFunction_value, cogSource_value, buffer=None)

 
class InsertElementsFromTempTable(PianaInsertSQL)
     Static methods defined here:
get_sqlquery(table, columns, identifier)

 
class InsertExternalDatabaseInformationType(PianaInsertSQL)
    Generates sql statement to insert a new type of information extracted from an external database
 
  Static methods defined here:
get_sqlquery(databaseName, information_type, buffer=None)

 
class InsertGeneralizedProteinExternalID(PianaInsertSQL)
    Generates sql statement to insert protein ids on generalized table proteinExternalId
 
  Static methods defined here:
get_sqlquery(table_name, externalId_type, externalId_column, code_value, proteinPiana_value, codeSource_value, isPrimary_value=0, buffer=None)

 
class InsertGo(PianaInsertSQL)
    Generates sql statement to insert information on table go
 
  Static methods defined here:
get_sqlquery(goID_value, go_name_value, go_acc_value, go_term_type_value, go_distance2root_value, goSource_value, buffer=None)

 
class InsertGo_term2term_distance(PianaInsertSQL)
    Generates sql statement to insert distance between two terms
 
  Static methods defined here:
get_sqlquery(term1_id_value, term2_id_value, distance_value, buffer=None)

 
class InsertInteraction(PianaInsertSQL)
    Generates sql statement to insert information on table interaction
 
  Static methods defined here:
get_sqlquery(interactionPiana_value, proteinPianaA_value, isSourceA_value, proteinPianaB_value, isSourceB_value, sourceDBID_value, interactionConfidence_value, buffer=None)

 
class InsertInteractionFeatures(PianaInsertSQL)
    Generates sql statement to insert information on table interactionMethod
 
  Static methods defined here:
get_sqlquery(pubmedID_value, interactionPiana_value, sourceDBID_value)

 
class InsertInteractionMethod(PianaInsertSQL)
    Generates sql statement to insert information on table interactionMethod
 
  Static methods defined here:
get_sqlquery(methodID_value, interactionPiana_value, sourceDBID_value)

 
class InsertInteractionProteinSource(PianaInsertSQL)
    Generates sql statement to insert information on table interactionProteinSource
 
  Static methods defined here:
get_sqlquery(interactionPiana_value=None, proteinPianaSource_value=None, sourceDBID_value=None)

 
class InsertInteractionScores(PianaInsertSQL)
    Generates sql statement to insert information on table interactionScores
 
  Static methods defined here:
get_sqlquery(interactionPiana_value, sourceDBID_value, equiv_nscore_value, equiv_nscore_transferred_value, equiv_fscore_value, equiv_pscore_value, equiv_hscore_value, array_score_value, array_score_transferred_value, experimental_score_value, experimental_score_transferred_value, database_score_value, database_score_transferred_value, textmining_score_value, textmining_score_transferred_value, combined_score_value)

 
class InsertNewExternalDatabase(PianaInsertSQL)
    Generates sql statement to insert a new external database
 
  Static methods defined here:
get_sqlquery(databaseName=None, databaseVersion=None, databaseFile=None, databaseDate=None, databaseDescription=None, databaseInteger=None)

 
class InsertNewProteinIdType(PianaInsertSQL)
    Generates sql statement to insert new protein Type Id into database
 
  Static methods defined here:
get_sqlquery(proteinTypeId=None, proteinTable=None, externalIdColumn=None, externalIdDescription=None)

 
class InsertProtein(PianaInsertSQL)
    Generates sql statement to insert information on table protein
 
  Static methods defined here:
get_sqlquery(proteinPiana_value, tax_id_value, sequenceID_value, sourceDBID, buffer=None)

 
class InsertProteinAttributeRelationship(PianaInsertSQL)
    Generates sql statement to insert information on protein attributes relationship tables
 
the tables must follow the structure:
 
(currently for tables:
 
proteinCog_table
proteinGo_table
proteinEC_table 
proteinSpecies_table 
proteinDescription_table 
proteinKeyword_table 
proteinFunction_table 
proteinSubcellularLocation_table
)
 
  Static methods defined here:
get_sqlquery(attribute_relationship_table, attribute_value, proteinPiana_value, attributeSource_value, buffer=None)

 
class InsertProteinCathRelationship(PianaInsertSQL)
    Generates sql statement to insert information of CATH to table proteinCath
 
  Static methods defined here:
get_sqlquery(cathID_value, res_start_value, res_end_value, segmentID_value, proteinPiana_value, source_value)

 
class InsertProteinCode2(PianaInsertSQL)
    Generates sql statement to insert protein information on tables that follow the structure:
 
code ID (external code, for example interProID) (string)
proteinPiana  (internal piana protein code)
description (description of codeID) (string)
codeSource  (name of origin of the data being inserted)
 
Instead of writing one class for each table, this class is designed to handle all these similar tables
 
current tables managed through this class are: interPro and pfam
 
  Static methods defined here:
get_sqlquery(table_name, code_value, proteinPiana_value, description_value, codeSource_value, buffer=None)

 
class InsertProteinDBAliRelationship(PianaInsertSQL)
    Generates sql statement to insert information of DBAli clustering of pibase patches to table proteinDBAliCluster
 
  Static methods defined here:
get_sqlquery(dbali_cluster_id_value, proteinPiana_value, clustering_method_value, patch_residues_value, protein_dbali_cluster_source)

 
class InsertProteinExternalID(PianaInsertSQL)
    Generates sql statement to insert protein ids on tables that follow the structure:
 
codeID  (external code, for example uniprotEntry) (string)
proteinPiana  (internal piana protein code)
codeSource  (name of origin of the data being inserted)
isPrimary [optional] (indicates whether it is a primary code or not
 
Instead of writing one class for each table, this class is designed to handle all these similar tables. This is somehow
dangerous, since we are hardcoding the order of the fields of the tables. If the order is changed, this class
will not work... and we would need to de-generalize it to insert information separately in each table.
 
All protein identifier tables are managed through this class
 
  Static methods defined here:
get_sqlquery(table_name, code_value, proteinPiana_value, codeSource_value, isPrimary_value=None, buffer=None)

 
class InsertProteinPdbCode(PianaInsertSQL)
    Generates sql statement to insert protein information on tables that follow the structure:
 
code ID (external code, for example PDB ID) (string)
proteinPiana  (internal piana protein code)
chain ID (specific to codeID) (string)
codeSource  (name of origin of the data being inserted)
 
Instead of writing one class for each table, this class is designed to handle all these similar tables
 
current tables managed through this class are: pdb
 
  Static methods defined here:
get_sqlquery(table_name, code_value, proteinPiana_value, chain_value, codeSource_value, combined_pdb_chain, range_value=None, buffer=<type 'buffer'>)

 
class InsertProteinPianaCounter(PianaInsertSQL)
    Generates sql statement to generate the SQL statement that obtains a new proteinPiana identifier from proteinPianaCounter table
 
After getting the new proteinPiana identifier, the method calling this class must make sure that the counter in increased by 1
 
  Static methods defined here:
get_sqlquery(updated_value, updated_col)

 
class InsertProteinScopRelationship(PianaInsertSQL)
    Generates sql statement to insert information of SCOP to table proteinScop
 
  Static methods defined here:
get_sqlquery(cf_value, sf_value, fa_value, proteinPiana_value, source_value, buffer=None)

 
class InsertProteinSimilarity(PianaInsertSQL)
    Generates sql statement to insert  protein similarity information into table proteinSimilarity
 
  Static methods defined here:
get_sqlquery(proteinPianaA_value, proteinPianaB_value, source_db_value, buffer=None)

 
class InsertReactome(PianaInsertSQL)
    Generates sql statement to insert information on table reactome
 
  Static methods defined here:
get_sqlquery(reactome_id, reactomeDescription_value, reactomeSource_value)

 
class InsertSequence(PianaInsertSQL)
    Generates sql statement to insert information on sequence
 
Buffer cannot be used
 
  Static methods defined here:
get_sqlquery(sequenceID_value, sequence_value, sequenceMD5_value, sequenceLength_value, sequenceMW_value, sequenceIP_value, sourceDBID, buffer=None)

 
class InsertSpecies(PianaInsertSQL)
    Generates sql statement to insert information on table species
 
  Static methods defined here:
get_sqlquery(taxID_value, speciesName_value, speciesDescription_value, speciesSource_value, speciesKingdom_value=None, buffer=None)

 
class InsertTemporalTable(PianaInsertSQL)
    Generates sql statement to insert data in a temporal table:
 
"db_temp_buffer" As all data inserted in temporal table must be processed before the connection to the database is closed, it is mandatory to pass a
te buffer that contains the information about how to do the queries
 
"conditions" is a list of the name of the columns that will be used to update parent table
 
  Static methods defined here:
get_sqlquery(table_name, column_values, sourceDBID, db_temp_buffer, conditions, buffer=None)

 
class MultipleInsert(PianaInsertSQL)
    Generates sql statement to insert information on a Buffer Element Object
 
  Static methods defined here:
get_sqlquery(table, columns, values)
"columns" must be a tuple with the name of the columns
 
"values" must be a dictionary which keys are the tuples of values to be inserted

 
class PianaInsertSQL
    General class for generating Piana SQL INSERT queries. All SQL queries inserting data into piana should be extensions of this class
 
  Static methods defined here:
get_sqlquery()
Override this with the sql query that inserts the desired values

 
class UpdateENUMcolumn(PianaInsertSQL)
    Generates sql statement to update an ENUM datatype in a table in the database
 
  Static methods defined here:
get_sqlquery(table, column, list_enum)
"table" is the table that contains the ENUM column
 
"column" is the name of the column to update
 
"list" is the list with all the values of the ENUM Set

 
class UpdateSourceDBID(PianaInsertSQL)
    Generates sql statement to update SET datatype in a table in the database
 
Used to insert or remove and element in a sourceDBID SET datatype
 
  Static methods defined here:
get_sqlquery(table, field, value, conditions=[], type='insert')
Used to insert or remove an element in sourceDBID SET datatype
 
"type" can be  "insert"   to add a new element
               "remove"   to remove an element
 
"field" is the SourceDBID field name
 
"value" is the value to add/remove (it must be in its decimal value!)
 
"conditions" is a list of tuples of length 2, with the following format: (field_name,value)

 
class UpdateSourceDBIDfromTempTable(PianaInsertSQL)
     Static methods defined here:
get_sqlquery(identifier, table, conditions)

 
class UpdateSourceDBSet(PianaInsertSQL)
    Generates sql statement to update SET datatype in a table in the database
 
Used to insert or remove and element in a sourceDBID SET datatype
 
  Static methods defined here:
get_sqlquery(table, field, values)
Used to insert or remove an element in sourceDBID SET datatype
 
"field" is the SET field name
 
"values" must be a list of all current values to be in the SET datatype

 
class UpdateSpeciesKingdom(PianaInsertSQL)
    Generates sql statement to update the kingdom field in species table
 
  Static methods defined here:
get_sqlquery(taxID_value, speciesKingdom_value=None)

 
class UpdateTableColumn(PianaInsertSQL)
    Generates sql statement to insert information on table protein
 
  Static methods defined here:
get_sqlquery(proteinPiana=None, table=None, column=None, new_value=None)

 
Data
        verbose = 1