PianaGraphBuilder
index
../../../../piana/code/Graph/PianaGraph/PianaGraphBuilder.py

File       : PianaGraphBuilder.py
Author     : R. Aragues & D. Jaeggi
Creation   : 31.07.2003
Contents   : class for building a piana graph from a database
Called from: PianaGraph and piana.py
Comments :
=========================================================================
 
This class is used to populate a PianaGraph object with interactions and proteins from a piana database

 
Modules
       
Bio
MySQLdb
PianaGlobals
copy
os
re
sys
utilities

 
Classes
       
GraphBuilder.GraphBuilder
PianaGraphBuilder

 
class PianaGraphBuilder(GraphBuilder.GraphBuilder)
    Class that implements graph building methods specific to Piana
 
  Methods defined here:
__init__(self, piana_access_object, depth=0, hub_threshold=0, list_protein_codes=None, code_type_name=None, tax_id_value=0, list_source_dbs='all', inverse_dbs='no', list_source_methods='all', inverse_methods='no')
Initilisation operations specific to Piana: mainly finding out the internal id (ie proteinPiana) for
protein given as argument, and then calling the general __init__ of superclass GraphBuilder
 
"depth" valid values are described in superclass GraphBuilder. It refers to the depth the graph should have.
 
"list_protein_codes" are protein identifiers of type "code_type". These protein codes will be used to build the graph. All codes must be
of the same type (e.g swissprot)
 
"code_type_name" is an easy-to-remember  protein type name: establishes the type of protein identifiers that are being passed as argument.
 
   It is used to retrieve the internal proteinPiana from the database, which is as well the identifier used for node_ids of the graph. 
   Valid id_type are those defined in PianaGlobals.py. There is a direct correspondance between these types and the
   column names in the database
 
   valid "code_type_name" values are those in PianaGlobals.valid_protein_types
 
 
"tax_id_value" can be used to fix the species we want to work on: only proteinPianas from that species will be used to build the graph
(this doesn't mean that 'a posteriori' added proteins will be limited as well to that species... it only concerns proteins in list_protein_codes)
If the database has an interaction between a protein of this species and a protein of another species, both proteins will appear in the network
regardless of this paramter: to control which proteins appear in your output you should use output-species-name in your piana configuration file
 
     --> valid values are 0 or a taxonomy id as defined by NCBI taxonomy
            - 0: retrieves all proteinPianas for protein_codes, regardless of species
 
"list_source_dbs" can be used to set which interaction databases will be used to build the network: only interactions from databases in the list
will be added to the network
 
  -> "list_source_dbs" can be "all" or a list of interactions databases
 
   - "all": uses all interactions in the piana database
   - [db1, db2, ...]: uses only interactions from databases listed (for example, [dip, string, posas]
      -> valid database names are those defined in PianaGlobals.interaction_databases
 
"inverse_dbs" can be:
               no (databases in list_source_dbs will be used to build the network)
               yes (all databases except those in list_source_dbs will be used to build the network)
               
 
 "list_source_methods" can be used to set which interaction detection methods will be used to build the network: only interactions
 that were detected through methods in the list will be added to the network
 
  -> "list_source_methods" can be "all" or a list of interactions methods
 
   - "all": uses all interaction detection methods in the piana database
   - [method1, method2, ...]: uses only interactions from methods listed (for example, [y2h, immuno]
      -> valid method names are those defined in PianaGlobals.method_names
 
"inverse_methods" can be:
               no (methods in list_source_methods will be used to build the network)
               yes (all methods except those in list_source_methods will be used to build the network)
create_node_attribute(self, node_id)
Overrides method from GraphBuilder
 
returns a PianaGraphNodeAttribute for node_id
get_link_details(self, node_id)
Overrides method from GraphBuilder: this method specifies how specific nodes and edges look like in PianaGraph
 
Before calling this method we are only dealing with node_id. get_links will create the node objects from node_id and return
linkDetail objects (container for two node_id, one edge and attributes of all of them). This linkDetails objects are specific
to PianaGraph, but can be used by GraphBuilder without knowing their internal structure.
 
This method uses self.list_source_dbs to limit the interactions found to those that were retrieved from databases that appear
in the list of databases given by the user when initializing the builder
 
This method uses self.list_source_methods to limit the interactions found to those that were found with methods that appear
in the list of methods given by the user when initializing the builder
 
returns empty list if no link_details are found

Methods inherited from GraphBuilder.GraphBuilder:
build_graph(self)
The main graph building method. This is called by Graph.build_graph()
set_graph(self, graph_object)
Sets the graph to be built - this is called by Graph.build_graph()

Data and other attributes inherited from GraphBuilder.GraphBuilder:
LinkDetail = <class GraphBuilder.LinkDetail>
Internal class for storing and transmitting link details.
A LinkDetail must be composed of 2 nodes as a minimum.
Each node can have one attribute.
The link can also have any number of attributes.

 
Data
        verbose = 0
verbose_build = 0
verbose_build_shallow = 0
verbose_get_all_links = 0
verbose_has_edge = 0
verbose_insert_interaction = 0
verbose_species = 0