コード例 #1
0
def create_input_transition_nodes(cursor, starting_species_list, operon_id, input_transition_id_dict):
    """Create input transition nodes list from the corresponding operon_id.

    Argument(s):
        cursor - sqlite3 cursor object
        starting_species_list - a list of species activating an operon
        operon_id - sbider based operon id
        input_transition_id_dict - dictionary mapping input transitions to corresponding species

    Return:
        A tuple of input transition nodes list (with abbreviation) and
        input transition id list.
        For example:
        ( [ ("ope_1-1", "pLux-->gfp", "sbol_image_path_1"), ("ope_2-1", "pLambda-->gfp", "sbol_image_path_2"), ... ],
          ["1-1", "2-1", ...] )

    """

    activated_it_ids = determine_operon_activated_input_transition(cursor, starting_species_list, operon_id,
                                                                   input_transition_id_dict)

    it_node_abbrev_list = []
    activated_it_id_list = []
    for activated_it_id in activated_it_ids:
        it_node = db.db_select(cursor, "InputTransition", "*", ["it_id"], ["="], [activated_it_id], [""])
        it_node = list(it_node.fetchone())
        it_node_abbrev = add_node_id_abbreviation(it_node, "it_", 0)
        it_node_abbrev_list.append(it_node_abbrev)
        activated_it_id_list.append(activated_it_id)

    return it_node_abbrev_list, activated_it_id_list
コード例 #2
0
def get_node1_list_from_node2_id(cursor, node1_node2_relationship_table,
                                 node2_id, node2_id_type, node1_table_name,
                                 node1_id_type):
    """Query the database to find all node1's from node2's id.
        It's possible to have multiple node1's map to node2.

    Argument(s):
        cursor - sqlite3 cursor object
        node1_node2_relationship_table - table_name relating node1 and node2
        node2_id - string representation of node1_id
        node2_id_type - node2_id type being used in the sbider database
        node1_table_name - table_name where node information exists
        node1_id_type - node1_id type being used in the sbider database

    Return:
        A list of nodes representing all node1's related to node2.
 
    """

    node_id = db.db_select(cursor, node1_node2_relationship_table,
                           [node1_id_type], [node2_id_type], ["="],
                           ["'" + node2_id + "'"], [""])

    node_id_list = node_id.fetchall()
    node_id_list = list_of_lists(node_id_list)

    node_list = []
    for node_info in node_id_list:
        node_ = get_node_from_id(cursor, node1_table_name, node_info[0],
                                 node1_id_type)
        node_ = list(node_)
        node_list.append(node_)
    return node_list
コード例 #3
0
def get_node_list_from_other_node_id(cursor, node_other_node_relationship_table, other_node_id, other_node_id_type,
                                node_table_name, node_id_type):
    node_id = db.db_select(cursor, node_other_node_relationship_table,  
                                     [node_id_type], 
                                     [other_node_id_type], 
                                     ["="], 
                                     ["'" + other_node_id + "'"], 
                                     [""])
    
    #print "node_id:", node_id
    
    node_id_list = node_id.fetchall()
    node_id_list = list_of_lists(node_id_list)
    
    #print "node_id_list:", node_id_list
    
    node_list = []
    for node_id in node_id_list:
        #print "node_id:", node_id
        
        node = get_node_from_id(cursor, node_table_name, node_id[0], node_id_type)

        #print "node:", node
        
        node = list(node)
        node_list.append(node)
    return node_list
コード例 #4
0
def get_node1_list_from_node2_id(cursor, node1_node2_relationship_table, node2_id, node2_id_type,
                                 node1_table_name, node1_id_type):
    """Query the database to find all node1's from node2's id.
        It's possible to have multiple node1's map to node2.

    Argument(s):
        cursor - sqlite3 cursor object
        node1_node2_relationship_table - table_name relating node1 and node2
        node2_id - string representation of node1_id
        node2_id_type - node2_id type being used in the sbider database
        node1_table_name - table_name where node information exists
        node1_id_type - node1_id type being used in the sbider database

    Return:
        A list of nodes representing all node1's related to node2.
 
    """

    node_id = db.db_select(cursor, node1_node2_relationship_table,
                           [node1_id_type],
                           [node2_id_type],
                           ["="],
                           ["'" + node2_id + "'"],
                           [""])

    node_id_list = node_id.fetchall()
    node_id_list = list_of_lists(node_id_list)

    node_list = []
    for node_info in node_id_list:
        node_ = get_node_from_id(cursor, node1_table_name, node_info[0], node1_id_type)
        node_ = list(node_)
        node_list.append(node_)
    return node_list
コード例 #5
0
def determine_operon_activated_input_transition(cursor, starting_species_list, operon_id, input_transition_id_dict):
    """Determining which input transition is activating an operon.

    Argument(s):
        cursor - sqlite3 cursor object
        starting_species_list - a list of species activating an operon
        operon_id - sbider based operon id
        id_id_dict - dictionary mapping input transitions to corresponding species

    Return:
        A list of transitions that activate the operon (from operon_id).
        For example: ["it_1", "it_2", ...]

    """
    starting_species_set = set(tuple(starting_species_list))
    it_trans_id_list = db.db_select(cursor, "OperonInputTransition", ["it_id"], ["ope_id"], ["="],
                                    ["'" + operon_id + "'"], [""])
    it_trans_id_list = it_trans_id_list.fetchall()
    it_trans_id_list = list_of_lists(it_trans_id_list)
    it_trans_id_list = merge_list_of_lists(it_trans_id_list)

    activated_it_id_list = []
    for it_trans_id in it_trans_id_list:

        activating_species_set = set(input_transition_id_dict[it_trans_id])

        if starting_species_set.issuperset(activating_species_set):
            activated_it_id_list.append(it_trans_id)
    return activated_it_id_list
コード例 #6
0
def get_input_transition_species_dictionary(cursor):
    """
    Retrieves all rows pertaining to the sbider inputTranstion
    table using these values the dictionary is created.

    Argument(s):
        cursor - sqlite3 cursor object instance

    Return:
        A dictionary mapping input transition id to a species id list.
    """

    input_transitions_species_dict = {}
    input_transition_species_list = db.db_select(cursor,
                                                 "InputTransitionSpecies",
                                                 ["it_id", "spe_id"])
    input_transition_species_list = input_transition_species_list.fetchall()
    inserted_it_ids = []
    for it_id, spe_id in input_transition_species_list:
        if it_id not in inserted_it_ids:
            input_transitions_species_dict[it_id] = [spe_id]
            inserted_it_ids.append(it_id)
        else:
            input_transitions_species_dict[it_id].append(spe_id)
    return input_transitions_species_dict
コード例 #7
0
def determine_operon_activated_input_transition(cursor, starting_species_list, operon_id):
    """Determining which input transition is activating the operon."""
    starting_species_set = set(tuple(starting_species_list))
    
    ###print "starting_species_set:", starting_species_set
    
    it_trans_id_list = db.db_select(cursor, "OperonInputTransition",  ["it_id"], ["ope_id"], ["="], ["'" + operon_id + "'"], [""])
    it_trans_id_list = it_trans_id_list.fetchall()
    it_trans_id_list = list_of_lists(it_trans_id_list)

    ###print "it_trans_id_list:", it_trans_id_list

    it_trans_id_list = merge_list_of_lists(it_trans_id_list)

    ###print "it_trans_id_list:", it_trans_id_list

    it_id_dict = get_input_transition_species_dictionary(cursor)

    for it_trans_id in it_trans_id_list:

        ###print "Searching it_trans_list:", it_trans_id
        print "it_id_dict[it_trans_id]:", it_id_dict[it_trans_id]
        
        activating_species_set = set(it_id_dict[it_trans_id])
        
        print "activating_species_set:", activating_species_set
        
        if starting_species_set.issuperset(activating_species_set):
            return it_trans_id
    return None
コード例 #8
0
def create_input_transition_nodes(cursor, starting_species_list, operon_id,
                                  input_transition_id_dict):
    """Create input transition nodes list from the corresponding operon_id.

    Argument(s):
        cursor - sqlite3 cursor object
        starting_species_list - a list of species activating an operon
        operon_id - sbider based operon id
        input_transition_id_dict - dictionary mapping input transitions to corresponding species

    Return:
        A tuple of input transition nodes list (with abbreviation) and
        input transition id list.
        For example:
        ( [ ("ope_1-1", "pLux-->gfp", "sbol_image_path_1"), ("ope_2-1", "pLambda-->gfp", "sbol_image_path_2"), ... ],
          ["1-1", "2-1", ...] )

    """

    activated_it_ids = determine_operon_activated_input_transition(
        cursor, starting_species_list, operon_id, input_transition_id_dict)

    it_node_abbrev_list = []
    activated_it_id_list = []
    for activated_it_id in activated_it_ids:
        it_node = db.db_select(cursor, "InputTransition", "*", ["it_id"],
                               ["="], [activated_it_id], [""])
        it_node = list(it_node.fetchone())
        it_node_abbrev = add_node_id_abbreviation(it_node, "it_", 0)
        it_node_abbrev_list.append(it_node_abbrev)
        activated_it_id_list.append(activated_it_id)

    return it_node_abbrev_list, activated_it_id_list
コード例 #9
0
def determine_operon_activated_input_transition(cursor, starting_species_list,
                                                operon_id,
                                                input_transition_id_dict):
    """Determining which input transition is activating an operon.

    Argument(s):
        cursor - sqlite3 cursor object
        starting_species_list - a list of species activating an operon
        operon_id - sbider based operon id
        id_id_dict - dictionary mapping input transitions to corresponding species

    Return:
        A list of transitions that activate the operon (from operon_id).
        For example: ["it_1", "it_2", ...]

    """
    starting_species_set = set(tuple(starting_species_list))
    it_trans_id_list = db.db_select(cursor, "OperonInputTransition", ["it_id"],
                                    ["ope_id"], ["="], ["'" + operon_id + "'"],
                                    [""])
    it_trans_id_list = it_trans_id_list.fetchall()
    it_trans_id_list = list_of_lists(it_trans_id_list)
    it_trans_id_list = merge_list_of_lists(it_trans_id_list)

    activated_it_id_list = []
    for it_trans_id in it_trans_id_list:

        activating_species_set = set(input_transition_id_dict[it_trans_id])

        if starting_species_set.issuperset(activating_species_set):
            activated_it_id_list.append(it_trans_id)
    return activated_it_id_list
コード例 #10
0
def get_whole_network(cursor):
    """Whole network data prep for json."""

    species_nodes_list = db.db_select(cursor, "Species", ["spe_id", "name", "type"])
    species_nodes_list = species_nodes_list.fetchall()
    species_nodes_list = list_of_lists(species_nodes_list)
    species_nodes_list_abbrev = add_node_list_id_abbreviation(species_nodes_list, "spe_", 0)

    input_transition_nodes_list = db.db_select(cursor, "InputTransition", ["it_id", "logic"])
    input_transition_nodes_list = input_transition_nodes_list.fetchall()
    input_transition_nodes_list = list_of_lists(input_transition_nodes_list)
    input_transition_nodes_list_abbrev = add_node_list_id_abbreviation(input_transition_nodes_list, "it_", 0)

    operon_nodes_list = db.db_select(cursor, "Operon", ["ope_id", "name"])
    operon_nodes_list = operon_nodes_list.fetchall()
    operon_nodes_list = list_of_lists(operon_nodes_list)
    operon_nodes_list_abbrev = add_node_list_id_abbreviation(operon_nodes_list, "ope_", 0)

    output_transition_nodes_list = db.db_select(cursor, "OutputTransition", ["ot_id"])
    output_transition_nodes_list = output_transition_nodes_list.fetchall()
    output_transition_nodes_list = list_of_lists(output_transition_nodes_list)
    output_transition_nodes_list_abbrev = add_node_list_id_abbreviation(output_transition_nodes_list, "ot_", 0)

    species_input_transition_edge_list = db.db_select(cursor, "InputTransitionSpecies", ["spe_id", "it_id"])
    species_input_transition_edge_list = species_input_transition_edge_list.fetchall()
    species_input_transition_edge_list = list_of_lists(species_input_transition_edge_list)
    species_input_transition_edge_list_abbrev = add_edge_list_id_abbreviation(species_input_transition_edge_list,
                                                                              "spe_", "it_")

    input_transition_operon_edge_list = db.db_select(cursor, "OperonInputTransition", ["it_id", "ope_id"])
    input_transition_operon_edge_list = input_transition_operon_edge_list.fetchall()
    input_transition_operon_edge_list = list_of_lists(input_transition_operon_edge_list)
    input_transition_operon_edge_list_abbrev = add_edge_list_id_abbreviation(input_transition_operon_edge_list,
                                                                             "it_", "ope_")

    operon_output_transition_edge_list = db.db_select(cursor, "OperonOutputTransition", ["ope_id", "ot_id"])
    operon_output_transition_edge_list = operon_output_transition_edge_list.fetchall()
    operon_output_transition_edge_list = list_of_lists(operon_output_transition_edge_list)
    operon_output_transition_edge_list_abbrev = add_edge_list_id_abbreviation(operon_output_transition_edge_list,
                                                                              "ope_", "ot_")

    output_transition_species_edge_list = db.db_select(cursor, "OutputTransitionSpecies", ["ot_id", "spe_id"])
    output_transition_species_edge_list = output_transition_species_edge_list.fetchall()
    output_transition_species_edge_list = list_of_lists(output_transition_species_edge_list)
    output_transition_species_edge_list_abbrev = add_edge_list_id_abbreviation(output_transition_species_edge_list,
                                                                               "ot_", "spe_")

    all_edges = species_input_transition_edge_list_abbrev + input_transition_operon_edge_list_abbrev + \
                operon_output_transition_edge_list_abbrev + output_transition_species_edge_list_abbrev

    return (species_nodes_list_abbrev, input_transition_nodes_list_abbrev, operon_nodes_list_abbrev,
            output_transition_nodes_list_abbrev, all_edges)
コード例 #11
0
def get_sbml_operons():
    '''
    Access operon table to retrieve all relevant operon information
    
    @Output: dictionary = {operon id: operon name}
        key = operon id: string type
        value = operon name: string type 
    '''
    devices = sd.db_select(cursor,'operon',['ope_id','name'])
    devices = devices.fetchall()
    return dict(devices)
コード例 #12
0
def get_input_transition_species_dictionary(cursor):
    input_transitions_species_dict = {}
    input_transition_species_list = db.db_select(cursor, "InputTransitionSpecies", ["it_id", "spe_id"])
    it_id_list = []
    for it_id, spe_id in input_transition_species_list:
        if it_id not in it_id_list:
            input_transitions_species_dict[it_id] = [spe_id]
            it_id_list.append(it_id)
        else:
            input_transitions_species_dict[it_id].append(spe_id)
    return input_transitions_species_dict
コード例 #13
0
def get_sbml_species():
    '''
    Access chemical species table and retrieve all relevant species information 
    
    @Output: dictionary = {species id: species name}
        key = species id 
        value = species name  
    '''
    species  = sd.db_select(cursor,'species',['spe_id', 'name'])
    species = species.fetchall()
    return dict(species)
コード例 #14
0
def get_sbml_input_logic():
    ''' 
    Access the input transition logic table and acquire 
    input transition Boolean logic
    
    @Output: dictionary = {it_id: logic}
        key = input transition id 
        value = associated Boolean logic  
    '''
    in_logic = sd.db_select(cursor, 'InputTransition',['it_id','logic'])
    in_logic = in_logic.fetchall()
    return dict(in_logic)
コード例 #15
0
def get_sbml_output_operon_edges():
    ''' 
    Access the output transition-operon relationship table and acquire 
    output transition-operon edges
    
    @Output: dictionary = {ot_id: ope_id}
        key = output transition id 
        value = operon id 
    '''
    operon_out_trans = sd.db_select(cursor, 'OperonOutputTransition',['ot_id','ope_id'])
    operon_out_trans = operon_out_trans.fetchall()
    return dict(operon_out_trans)
コード例 #16
0
def get_sbml_miriam_ids():
    '''
    Access plasmid table and plasmid-operon relationship table to retrieve 
    the miriam ids of each operon
    
    @Output: dictionary = {operon id: miriam id}
        operon id: string type 
        miriam id: string type 
    '''
    devices = sd.db_select(cursor,'plasmid',['pla_id', 'PMID'])
    devices = devices.fetchall()
    plasmid_operon = sd.db_select(cursor,'plasmidoperon',['ope_id','pla_id'])
    plasmid_operon = plasmid_operon.fetchall()
    plasmid_miriam  = dict(devices)
    operon_miriam  =  {}
    for operon in plasmid_operon:
        operon_id = operon[0]
        plasmid_id = operon[1]
        if plasmid_id in plasmid_miriam:
            operon_miriam[operon_id] = plasmid_miriam[plasmid_id]
    return operon_miriam        
コード例 #17
0
def get_node_from_id(cursor, node_table_name, node_id, node_id_type):


    node_cursor = db.db_select(cursor, node_table_name, "*", [node_id_type], ["="], [node_id], [""])


    node = node_cursor.fetchone()


    node = list(node)


    return node
コード例 #18
0
def create_input_transition_node(cursor, operon_id, starting_species_list):
    """Create input transition nodes from the corresponding operon_id."""    

    activated_it_id = determine_operon_activated_input_transition(cursor, starting_species_list, operon_id)

    ###print "activated_it_id:",activated_it_id

    it_node = db.db_select(cursor, "InputTransition", "*", ["it_id"], ["="], [activated_it_id], [""])
    it_node = list(it_node.fetchone())
    
    it_node_abbrev = add_node_id_abbreviation(it_node, "it_", 0)
    
    ###print "it_node_abbrev:", it_node_abbrev

    return it_node_abbrev, activated_it_id
コード例 #19
0
def create_input_transition_nodes(cursor, starting_species_list, operon_id, it_id_dict):
    """Create input transition nodes from the corresponding operon_id."""

    activated_it_ids = determine_operon_activated_input_transition(cursor, starting_species_list, operon_id, it_id_dict)


    it_node_abbrev_list = []
    activated_it_id_list = []
    for activated_it_id in activated_it_ids:
        it_node = db.db_select(cursor, "InputTransition", "*", ["it_id"], ["="], [activated_it_id], [""])
        it_node = list(it_node.fetchone())
        it_node_abbrev = add_node_id_abbreviation(it_node, "it_", 0)
        it_node_abbrev_list.append(it_node_abbrev)
        activated_it_id_list.append(activated_it_id)


    return it_node_abbrev_list, activated_it_id_list
コード例 #20
0
def get_node_from_id(cursor, node_table_name, node_id, node_id_type):
    """Query the database using the node_id for node.

    Argument(s):
        cursor - sqlite3 cursor object
        node_table_name - table_name where node information exists
        node_id - string representation of node_id
        node_id_type - the type of node being used from the sbider database.

    Return:
        A tuple of information representing the node.

    """

    node_cursor = db.db_select(cursor, node_table_name, "*", [node_id_type], ["="], [node_id], [""])
    node_ = node_cursor.fetchone()
    node_ = list(node_)
    return node_
コード例 #21
0
def get_node_from_id(cursor, node_table_name, node_id, node_id_type):
    """Query the database using the node_id for node.

    Argument(s):
        cursor - sqlite3 cursor object
        node_table_name - table_name where node information exists
        node_id - string representation of node_id
        node_id_type - the type of node being used from the sbider database.

    Return:
        A tuple of information representing the node.

    """

    node_cursor = db.db_select(cursor, node_table_name, "*", [node_id_type],
                               ["="], [node_id], [""])
    node_ = node_cursor.fetchone()
    node_ = list(node_)
    return node_
コード例 #22
0
def get_node_from_id(cursor, node_table_name, node_id, node_id_type):
    
    ###print "node_table_name:", node_table_name
    ###print "node_id:", node_id
    ###print "node_id_type:", node_id_type
    
    node_cursor = db.db_select(cursor, node_table_name,"*", [node_id_type], ["="], [node_id], [""] )
    
    #print "node_cursor:", node_cursor
    
    node = node_cursor.fetchone()
    
    #print "node:", node
    
    node = list(node)
    
    ###print "node:", node
    
    return node
コード例 #23
0
def get_sbml_output_species_edges():
    '''
    Access the output transition-chemical species relationship table and acquire 
    output species-transition edges
    
    @Output: dictionary = {ot_id: [spe_id]}
        key = output transition id 
        value = list of associated output chemical species
    '''
    OUT = sd.db_select(cursor,'outputtransitionspecies', ['ot_id','spe_id'])
    OUT = OUT.fetchall()
    output_trans_species = {}
    for trans in OUT:
        output_trans_id = trans[0]
        species_id = trans[1]
        if output_trans_id not in output_trans_species:
            output_trans_species[output_trans_id] = []
            output_trans_species[output_trans_id].append(species_id)
        else:
            output_trans_species[output_trans_id].append(species_id)
    return output_trans_species
コード例 #24
0
def determine_operon_activated_input_transition(cursor, starting_species_list, operon_id, it_id_dict):
    """Determining which input transition is activating the operon."""
    starting_species_set = set(tuple(starting_species_list))
    it_trans_id_list = db.db_select(cursor, "OperonInputTransition", ["it_id"], ["ope_id"], ["="],
                                    ["'" + operon_id + "'"], [""])
    it_trans_id_list = it_trans_id_list.fetchall()
    it_trans_id_list = list_of_lists(it_trans_id_list)
    it_trans_id_list = merge_list_of_lists(it_trans_id_list)


    activated_it_id_list = []
    for it_trans_id in it_trans_id_list:



        activating_species_set = set(it_id_dict[it_trans_id])



        if starting_species_set.issuperset(activating_species_set):
            activated_it_id_list.append(it_trans_id)
    return activated_it_id_list
コード例 #25
0
def get_input_transition_species_dictionary(cursor):
    """
    Retrieves all rows pertaining to the sbider inputTranstion
    table using these values the dictionary is created.

    Argument(s):
        cursor - sqlite3 cursor object instance

    Return:
        A dictionary mapping input transition id to a species id list.
    """

    input_transitions_species_dict = {}
    input_transition_species_list = db.db_select(cursor, "InputTransitionSpecies", ["it_id", "spe_id"])
    input_transition_species_list = input_transition_species_list.fetchall()
    inserted_it_ids = []
    for it_id, spe_id in input_transition_species_list:
        if it_id not in inserted_it_ids:
            input_transitions_species_dict[it_id] = [spe_id]
            inserted_it_ids.append(it_id)
        else:
            input_transitions_species_dict[it_id].append(spe_id)
    return input_transitions_species_dict
コード例 #26
0
def get_sbml_input_species_edges():
    '''
    Access the input transition-chemical species relationship table and acquire 
    input species-transition edges
    
    @Output: dictionary = {it_id: [(spe_id, repressor_boolean)]}
        key = input transition id 
        value = list of associated input chemical species
            tuple = (chemical species, associated repressor boolean). If 
            chemical species is a repressor then repressor_boolean is 'True'
    '''
    IN = sd.db_select(cursor,'inputtransitionspecies', ['it_id','spe_id','repression'])
    IN = IN.fetchall()
    input_trans_species = {}
    for trans in IN:
        input_trans_id = trans[0]
        species_id = trans[1]
        repressor_bool  = trans[2]
        if input_trans_id not in input_trans_species:
            input_trans_species[input_trans_id] = []
            input_trans_species[input_trans_id].append((species_id,repressor_bool))
        else:
            input_trans_species[input_trans_id].append((species_id,repressor_bool))
    return input_trans_species
コード例 #27
0
def get_whole_network(cursor):
    """Whole network data prep for json."""

    species_nodes_list = db.db_select(cursor, "Species",
                                      ["spe_id", "name", "type"])
    species_nodes_list = species_nodes_list.fetchall()
    species_nodes_list = list_of_lists(species_nodes_list)
    species_nodes_list_abbrev = add_node_list_id_abbreviation(
        species_nodes_list, "spe_", 0)

    input_transition_nodes_list = db.db_select(cursor, "InputTransition",
                                               ["it_id", "logic"])
    input_transition_nodes_list = input_transition_nodes_list.fetchall()
    input_transition_nodes_list = list_of_lists(input_transition_nodes_list)
    input_transition_nodes_list_abbrev = add_node_list_id_abbreviation(
        input_transition_nodes_list, "it_", 0)

    operon_nodes_list = db.db_select(cursor, "Operon", ["ope_id", "name"])
    operon_nodes_list = operon_nodes_list.fetchall()
    operon_nodes_list = list_of_lists(operon_nodes_list)
    operon_nodes_list_abbrev = add_node_list_id_abbreviation(
        operon_nodes_list, "ope_", 0)

    output_transition_nodes_list = db.db_select(cursor, "OutputTransition",
                                                ["ot_id"])
    output_transition_nodes_list = output_transition_nodes_list.fetchall()
    output_transition_nodes_list = list_of_lists(output_transition_nodes_list)
    output_transition_nodes_list_abbrev = add_node_list_id_abbreviation(
        output_transition_nodes_list, "ot_", 0)

    species_input_transition_edge_list = db.db_select(
        cursor, "InputTransitionSpecies", ["spe_id", "it_id"])
    species_input_transition_edge_list = species_input_transition_edge_list.fetchall(
    )
    species_input_transition_edge_list = list_of_lists(
        species_input_transition_edge_list)
    species_input_transition_edge_list_abbrev = add_edge_list_id_abbreviation(
        species_input_transition_edge_list, "spe_", "it_")

    input_transition_operon_edge_list = db.db_select(cursor,
                                                     "OperonInputTransition",
                                                     ["it_id", "ope_id"])
    input_transition_operon_edge_list = input_transition_operon_edge_list.fetchall(
    )
    input_transition_operon_edge_list = list_of_lists(
        input_transition_operon_edge_list)
    input_transition_operon_edge_list_abbrev = add_edge_list_id_abbreviation(
        input_transition_operon_edge_list, "it_", "ope_")

    operon_output_transition_edge_list = db.db_select(
        cursor, "OperonOutputTransition", ["ope_id", "ot_id"])
    operon_output_transition_edge_list = operon_output_transition_edge_list.fetchall(
    )
    operon_output_transition_edge_list = list_of_lists(
        operon_output_transition_edge_list)
    operon_output_transition_edge_list_abbrev = add_edge_list_id_abbreviation(
        operon_output_transition_edge_list, "ope_", "ot_")

    output_transition_species_edge_list = db.db_select(
        cursor, "OutputTransitionSpecies", ["ot_id", "spe_id"])
    output_transition_species_edge_list = output_transition_species_edge_list.fetchall(
    )
    output_transition_species_edge_list = list_of_lists(
        output_transition_species_edge_list)
    output_transition_species_edge_list_abbrev = add_edge_list_id_abbreviation(
        output_transition_species_edge_list, "ot_", "spe_")

    all_edges = species_input_transition_edge_list_abbrev + input_transition_operon_edge_list_abbrev + \
                operon_output_transition_edge_list_abbrev + output_transition_species_edge_list_abbrev

    return (species_nodes_list_abbrev, input_transition_nodes_list_abbrev,
            operon_nodes_list_abbrev, output_transition_nodes_list_abbrev,
            all_edges)
コード例 #28
0
def get_whole_network(cursor):
    """Whole network data prep for json."""
    
    #*****Gathering all nodes
    species_nodes_list = db.db_select(cursor, "Species", ["spe_id", "name", "type"])
    species_nodes_list = species_nodes_list.fetchall()
    species_nodes_list = list_of_lists(species_nodes_list)
    species_nodes_list_abbrev = add_node_list_id_abbreviation(species_nodes_list, "spe_", 0)

    #print "species_nodes_list_abbrev:", species_nodes_list_abbrev

    input_transition_nodes_list = db.db_select(cursor, "InputTransition", ["it_id", "logic"])
    input_transition_nodes_list = input_transition_nodes_list.fetchall()
    input_transition_nodes_list = list_of_lists(input_transition_nodes_list)
    input_transition_nodes_list_abbrev = add_node_list_id_abbreviation(input_transition_nodes_list, "it_", 0)
          
    #print "input_transition_nodes_list:", input_transition_nodes_list

    operon_nodes_list = db.db_select(cursor,"Operon", ["ope_id", "name", "image"])
    operon_nodes_list = operon_nodes_list.fetchall()
    operon_nodes_list = list_of_lists(operon_nodes_list)
    operon_nodes_list_abbrev = add_node_list_id_abbreviation(operon_nodes_list, "ope_", 0)        
    
    #print "operon_nodes_list:", operon_nodes_list_abbrev

    output_transition_nodes_list = db.db_select(cursor, "OutputTransition", ["ot_id"])
    output_transition_nodes_list = output_transition_nodes_list.fetchall()
    output_transition_nodes_list = list_of_lists(output_transition_nodes_list)
    output_transition_nodes_list_abbrev = add_node_list_id_abbreviation(output_transition_nodes_list, "ot_", 0)
    
    species_nodes_list_abbrev, input_transition_nodes_list_abbrev, operon_nodes_list_abbrev, output_transition_nodes_list_abbrev
    
    #print "output_transition_nodes_list_abbrev:", output_transition_nodes_list_abbrev
    
    #********************************************Gathering all edges#********************************************#
    ##***********************************************************************************************************#
    ##***********************************************************************************************************#
    
    species_input_transition_edge_list = db.db_select(cursor,"InputTransitionSpecies", ["spe_id", "it_id"])
    species_input_transition_edge_list = species_input_transition_edge_list.fetchall()
    species_input_transition_edge_list = list_of_lists(species_input_transition_edge_list)
    species_input_transition_edge_list_abbrev = add_edge_list_id_abbreviation(species_input_transition_edge_list, 
                                                                                "spe_", "it_")
    #print_list_entries(species_input_transition_edge_list_abbrev)
    #print "species_input_transition_edge_list_abbrev:", species_input_transition_edge_list_abbrev
                                                                                 
    input_transition_operon_edge_list = db.db_select(cursor,"OperonInputTransition", ["it_id", "ope_id"])
    input_transition_operon_edge_list = input_transition_operon_edge_list.fetchall()
    input_transition_operon_edge_list = list_of_lists(input_transition_operon_edge_list)
    input_transition_operon_edge_list_abbrev = add_edge_list_id_abbreviation(input_transition_operon_edge_list,
                                                                                "it_", "ope_")
    #print_list_entries(input_transition_operon_edge_list_abbrev)
    #print "input_transition_operon_edge_list_abbrev:", input_transition_operon_edge_list_abbrev
    
    operon_output_transition_edge_list = db.db_select(cursor,"OperonOutputTransition", ["ope_id", "ot_id"])
    operon_output_transition_edge_list = operon_output_transition_edge_list.fetchall()
    operon_output_transition_edge_list = list_of_lists(operon_output_transition_edge_list)
    operon_output_transition_edge_list_abbrev = add_edge_list_id_abbreviation(operon_output_transition_edge_list,
                                                                                "ope_", "ot_")
    #print_list_entries(operon_output_transition_edge_list_abbrev)
    #print "operon_output_transition_edge_list_abbrev", operon_output_transition_edge_list_abbrev

    output_transition_species_edge_list = db.db_select(cursor,"OutputTransitionSpecies", ["ot_id", "spe_id"])
    output_transition_species_edge_list = output_transition_species_edge_list.fetchall()
    output_transition_species_edge_list = list_of_lists(output_transition_species_edge_list)
    output_transition_species_edge_list_abbrev = add_edge_list_id_abbreviation(output_transition_species_edge_list,
                                                                                "ot_", "spe_")
    #print_list_entries(output_transition_species_edge_list_abbrev)
    #print "output_transition_species_edge_list_abbrev:", output_transition_species_edge_list_abbrev
    
    all_edges = species_input_transition_edge_list_abbrev + input_transition_operon_edge_list_abbrev +    operon_output_transition_edge_list_abbrev + output_transition_species_edge_list_abbrev
    
    #print "all_edges:",all_edges
    
    return (species_nodes_list_abbrev, input_transition_nodes_list_abbrev, operon_nodes_list_abbrev,
            output_transition_nodes_list_abbrev, all_edges)