Team:UCSD Software/Documentation

From 2014.igem.org


Tutorial



    

API Documentation

Download and view the documentation on github here. A text version of the documentation is shown below:
Help on module Gen_Network:

NAME
    Gen_Network - //Title: SBML Network Generator

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/Gen_Network.py

DESCRIPTION
    //Description: 
        Translate entire network model to SBML and store network file 
        in current working directory  
    
    *************************************************
    @author: Fernando Contreras
    @email: f2contre@gmail.com
    @project: SBiDer
    @institution: University of California, San Diego
    *************************************************

FUNCTIONS
    create_whole_network_sbml()


Help on module SBML_Network:

NAME
    SBML_Network - //Title: SBML Network Constructor.

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/SBML_Network.py

DESCRIPTION
    //Description: 
        Each class generates a corresponding SBML description of the input information 
        and appends the information to a list which is then written to file
    
    *************************************************
    @author: Fernando Contreras
    @email: f2contre@gmail.com
    @project: SBiDer
    @institution: University of California, San Diego
    *************************************************

CLASSES
    CloseModel
    IntermediateStep
    Model
    QualitativeSpecies
    Transitions
    
    class CloseModel
     |  Require class, need to append closing SBML statements for network model
     |  
     |  Methods defined here:
     |  
     |  __init__(self, model_name)
     |      @Parameter:
     |          model_name: model object, instantiated using Model class
    
    class IntermediateStep
     |  Require class, need to append necessary SBML statements for network model
     |  
     |  Methods defined here:
     |  
     |  __init__(self, model_name)
     |      @Parameter:
     |          model_name: model object, instantiated using Model class
    
    class Model
     |  Creates a model object. When instantiated the class appends all the URLs 
     |  necessary to understand our network model
     |  
     |  Methods defined here:
     |  
     |  __init__(self, id='SBider_Network')
     |  
     |  writeSBML(self, filename)
     |      @Parameters: 
     |          filename: desired file name for network file 
     |          type: string 
     |      
     |      @Method:
     |          Write SBML formatted network model text file. File is then stored in 
     |          the current working directory.
    
    class QualitativeSpecies
     |  Qualitative species, such as operons and chemical species, constructor
     |  
     |  Methods defined here:
     |  
     |  __init__(self, id, compartment, name='NONE', maxLevel='1', constant='false', miriam_id='NONE')
     |      @Parameters:
     |          id: node id 
     |          compartment: node compartment, for example, operons belong in the plasmid compartment
     |          name: node name, default=NONE because operons don't have a name 
     |          maxLevel: node threshold, default = 1 because a logic model was implemented 
     |          constant: denotes node passivity, if constant = True then the node does not interact with 
     |          network. Thus, the node does not transfer information.
     |          miriam_id: Minimal Information Required in the Annotation of Models id. This allows for 
     |          a standarized citation of literature references 
     |      
     |      @Method:
     |          Translate all the inputed information to SBML and append to list
     |  
     |  appendToQualSpecies(self, model_name)
    
    class Transitions
     |  Input and output transition constructor; transitions denote the operon's input 
     |  and output reaction in our network.
     |  
     |  Methods defined here:
     |  
     |  input_transition(self, model_name, trans_id, input_id_boolean_tuple, operon_id, trans_logic)
     |      @Parameters:
     |          node_name: name of node object, instantiated using the Node class 
     |          trans_id: transition id 
     |          input_id_boolean_tuple: tuple of the form (input chemical species, repressor boolean)
     |              input chemical species: chemical species involved in reaction 
     |              repressor boolean: denotes whether a chemical species is a repressor (True or False)
     |              Can input a list if multiple operators are involved, such is the case for an AND gate 
     |          operon_id: operon id 
     |          trans_logic: transition logic denotes the Boolean logic of a reaction ('AND', 'OR', 'NOT')
     |          
     |      @Method:
     |          Translate all the inputed information to SBML and append to list
     |  
     |  output_transition(self, model_name, trans_id, output_id, operon_id)
     |      @Parameters:
     |          node_name: name of node object, instantiated using the Node class 
     |          trans_id: transition id 
     |          output_id: single variable input which denotes the id of an operon's output
     |          operon_id: operon id 
     |          
     |      @Method:
     |          Translate all the inputed information to SBML and append to list


Help on module SBML_Nodes:

NAME
    SBML_Nodes - //Title: SBML Node Constructor.

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/SBML_Nodes.py

DESCRIPTION
    //Description: 
        Each class generates a corresponding SBML description of the input information.
    
    *************************************************
    @author: Fernando Contreras
    @email: f2contre@gmail.com
    @project: SBiDer
    @institution: University of California, San Diego
    *************************************************

CLASSES
    Nodes
    QualitativeSpecies
    Transitions
    
    class Nodes
     |  Place, passive component of Petri Net model, and transition, active component 
     |  of Petri Net model, file constructor.When instantiated, a qualitative species 
     |  list and a transitions list are created. Data is then stored according to 
     |  SBML standards.
     |  
     |  Methods defined here:
     |  
     |  __init__(self)
     |      Instantiate qualitative species and transitions list objects
     |  
     |  writeQualSpecies(self, filename)
     |      @Parameters: filename
     |          type: string 
     |          description: desired file name for a particular qualitative species
     |          SBML text file(i.e. operon or chemical species)
     |      @Method:
     |          Write SBML text file for a qualitative species stored in the qualitative 
     |          species list object. File is then stored in the current working directory.
     |  
     |  writeTransition(self, filename)
     |      @Parameters: filename
     |          type: string 
     |          description: desired file name for a particular transition SBML text 
     |          file(i.e. input transition or output transition)
     |      @Method:
     |          Write SBML text file for a transition stored in the transition list 
     |          object. File is then stored in the current working directory.
    
    class QualitativeSpecies
     |  Qualitative species, such as operons and chemical species, constructor
     |  
     |  Methods defined here:
     |  
     |  __init__(self, id, compartment, name='NONE', maxLevel='1', constant='false', miriam_id='NONE')
     |      @Parameters:
     |          id: node id 
     |          compartment: node compartment, for example, operons belong in the plasmid compartment
     |          name: node name, default=NONE because operons don't have a name 
     |          maxLevel: node threshold, default = 1 because a logic model was implemented 
     |          constant: denotes node passivity, if constant = True then the node does not interact with 
     |          network. Thus, the node does not transfer information.
     |          miriam_id: Minimal Information Required in the Annotation of Models id. This allows for 
     |          a standarized citation of literature references 
     |      
     |      @Method:
     |          Translate all the inputed information to SBML and append to list
     |  
     |  appendToQualSpecies(self, node_name)
    
    class Transitions
     |  Input and output transition constructor; transitions denote the operon's input 
     |  and output reaction in our network.
     |  
     |  Methods defined here:
     |  
     |  input_transition(self, node_name, trans_id, input_id_boolean_tuple, operon_id, trans_logic)
     |      @Parameters:
     |          node_name: name of node object, instantiated using the Node class 
     |          trans_id: transition id 
     |          input_id_boolean_tuple: tuple of the form (input chemical species, repressor boolean)
     |              input chemical species: chemical species involved in reaction 
     |              repressor boolean: denotes whether a chemical species is a repressor (True or False)
     |              Can input a list if multiple operators are involved, such is the case for an AND gate 
     |          operon_id: operon id 
     |          trans_logic: transition logic denotes the Boolean logic of a reaction ('AND', 'OR', 'NOT')
     |          
     |      @Method:
     |          Translate all the inputed information to SBML and append to list
     |  
     |  output_transition(self, node_name, trans_id, output_id, operon_id)
     |      @Parameters:
     |          node_name: name of node object, instantiated using the Node class 
     |          trans_id: transition id 
     |          output_id: single variable input which denotes the id of an operon's output
     |          operon_id: operon id 
     |          
     |      @Method:
     |          Translate all the inputed information to SBML and append to list


Help on module helper:

NAME
    helper - Useful helper functions.

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/helper.py

DESCRIPTION
    ******************************************************************************
    @author: Huwate(Kwat) Yeerna, University of California, San Diego
             Joaquin Reina, University of California, San Diego
    ******************************************************************************

FUNCTIONS
    activated(inp_dic, ope, spe)
        Check if there is an activation signal for a operon.
        :param inp_dic: dictionary of operon and their activation requirement.
        :param ope: operon whose activation signal is checked.
        :param spe: species that may induce activation signal for the operon.
        :return: True only if species match any of the activation requirement of an operon, False otherwise.
    
    contain_all_elements(list_of_lists, lst)
        Check if a list that matches the specified list.
        :param list_of_lists: list whose inner lists are checked.
        :param lst: list matched
        :return: True only if the list_of_lists contain a list that matches lst.
    
    contain_an_element(lst1, lst2)
        Check if at least on of the elements is a list is in another list.
        :param lst1: list that may contain at least one element from anther list.
        :param lst2: list whose elements are searched for in another list.
        :return: True only if at least an element from lst2 in found in lst1.
    
    format_values(value_list)
        Create a list by adding elements of a list in a standard expression.
        :param value_list: list whose elements with non-standard expression are reformatted and added to the new list.
        :return: a new list with elements in standard expression.
    
    get_matching_list_and_index(list_of_lists, lst)
        Get a matching list within a list of lists that matches a specified list.
        :param list_of_lists: list whose inner lists are checked to see if any of them match the specified list.
        :param lst: list checked.
        :return: list within list_of_lists that matches the specified list.
    
    list_is_type(lst, typ)
        Check if all elements of a list are the specified type.
        :param lst: list whose elements are checked.
        :param typ: type specified.
        :return: True only if all elements of the list is the specified type, False otherwise.
    
    match_any_list(list_of_lists, lst)
        Check if a list matches any of the lists within a list of lists.
        :param list_of_lists: list of lists that contain potential matching lists.
        :param lst: list matched.
        :return: True only is at least a list within the list of lists matches the specified list.
    
    promoter_activation(inp_dic, rep_dic, ope, spe, memory_spe, indirect_flag)
        Check if a promoter is activated.
        :param inp_dic: dictionary of operon and their activation requirement.
        :param rep_dic: dictionary of operon and their repression requirement.
        :param ope: operon whose activation is checked.
        :param spe: species that can activate or repress an operon.
        :param memory_spe: species that can activate or repress an operon.
        :param indirect_flag: Boolean flag for checking indirect activation of an operon
        :return: True if the operon is activated.
    
    remove_duplicated_lists_within_a_list_of_lists(list_of_lists)
        Create a list that contains unique lists within another list.
        :param list_of_lists: list that contains duplicated lists.
        :return: list that contains unique lists from the list.
    
    remove_duplicates_within_list(lst)
        Create a list with only unique elements form another list.
        :param lst: list whose unique elements will be stored in a new list.
        :return: a list that contains non-duplicated elements from the parameter list.
    
    remove_parentheses(sequence)
        Remove the outermost parentheses of a string, and return the element right after the closing parentheses.
        :param sequence:
        :return:
    
    repressed(rep_dic, ope, spe)
        Check if there is an repression signal for a operon.
        :param rep_dic: dictionary of operon and their repression requirement.
        :param ope: operon whose repression signal is checked.
        :param spe: species that may induce repression signal for the operon.
        :return: True only if species match any of the repression requirement of an operon, False otherwise.
    
    reverse_index(sequence, element)
        Find the last occurring index of an element in a sequence.
        :param sequence: list checked.
        :param element: element searched.
        :return: index of the last occurring index of an element.
    
    split_by(sequence, element)
        Split a sequence by the first occurring index of a specified element, and return the the resulting two-halves of
        the sequence in a dictionary.
        :param sequence: sequence that is split.
        :param element: element whose first occurring index splits the sequence.
        :return: dictionary that contains the split two halves of the sequence.
    
    uniquely_merge_list_of_lists(list_of_lists)
        Create a list that contain unique elements from lists within itself.
        :param list_of_lists: list that contains lists
        :return: list that contains unique elements from lists within the list.
    
    uniquely_merge_multi_dimensional_list_of_lists(multi_dimensional_list_of_lists)
        Create a list that contain unique elements from lists within itself.
        :param multi_dimensional_list_of_lists: list that contains lists
        :return: list that contains unique elements from lists within the list.


Help on module node:

NAME
    node - Subtitle

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/node.py

DESCRIPTION
    Descriptive paragraph
    
    ******************************************************************************
    @author: Huwate(Kwat) Yeerna, University of California, San Diego
    ******************************************************************************

CLASSES
    __builtin__.object
        Node
    
    class Node(__builtin__.object)
     |  Methods defined here:
     |  
     |  __init__(self, value)
     |  
     |  __repr__(self, level=0)
     |  
     |  append_child(self, obj)
     |  
     |  get_all_leaf(self)
     |  
     |  get_path_from_all_leaf(self)
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)


Help on module sbider_database:

NAME
    sbider_database - Subtitle

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/sbider_database.py

DESCRIPTION
    Descriptive paragraph
    
    ******************************************************************************
    @author: Huwate(Kwat) Yeerna, University of California, San Diego
             Joaquin Reina, University of California, San Diego
    ******************************************************************************

FUNCTIONS
    db_close(connection, cursor)
        Close a database.
    
    db_create_table(cursor)
        Make tables for sbider.db
    
    db_custom(cursor, sql_command)
        Do whatever.
    
    db_delete(cursor, table_name)
        Delete table contents.
    
    db_drop_all_table(cursor)
        Drop all tables.
    
    db_drop_table(cursor, table_name)
        Drop a table.
    
    db_get_operon_id_from_name(cursor, operon_name)
    
    db_get_operon_name_from_id(cursor, operon_id)
    
    db_get_plasmid_id_from_name(cursor, plasmid_name)
    
    db_get_plasmid_name_from_id(cursor, plasmid_id)
    
    db_get_species_id_from_name(cursor, species_name)
    
    db_get_species_name_from_id(cursor, species_id)
    
    db_insert(cursor, table_name, table_header_list, insert_data_list)
        Insert into a table.
        
        Args:
            table_name, that table that you wish to insert into
            cols, the columns that you want to insert into
            new_row, the values that correspond to the columns
        
        Examples:
            ex 1. Inserting into plasmid table and filling in all the columns.
    
    db_open(database_file)
        Connect to a database or create a database if it does not already
        exist.
    
    db_print_all_table(cursor)
        Print all tables.
    
    db_print_table(cursor, table_name)
        Print a table.
    
    db_select(cursor, table_name, table_header_list, where_columns=None, where_options=None, where_values=None, where_bools=None, group=None, having_columns=None, having_bools=None, having_values=None)
        Select from a table.
        
        Argument(s):
            table_name: table you wish to pull data from
            col_names: list of numbers indexing the table columns
            w_col: column names for where clause
            w_opt: operator for where clause
            w_var: variable for where clause 
            w_bool: boolean for where clause
            group: group name for GROUP BY clause
            h_col: group specifier
        
        Return:
    
    db_update(cursor, table_name, table_header_list, update_data_list, where_column='', where_option='', where_value='')
        Update.
    
    get_all_input_transition_species(cursor, input_transition_id)
        Obtain all species an input transition takes.
    
    get_all_output_transition_species(cursor, input_transition_id)
        Obtain all species an output transition produces.
    
    make_input_ope_id_spe_id_dic(cursor)
        Make operon input species dictionary.
    
    make_ope_id_rep_spe_id_dic(cursor)
        Make operon input not dictionary.
    
    make_ope_id_spe_id_dics(cursor)
    
    make_output_ope_id_spe_id_dic(cursor)
        Make operon output species dictionary.
    
    make_pla_name_spe_name_dics(cursor)
        Make operon input and output species dictionary.
    
    make_plasmid_species_name_dictionary(cursor, operon_id_plasmid_name_dictionary, operon_species_dictionary)
    
    make_sql_delete_command(table_name)
    
    make_sql_drop_command(table_name)
    
    make_sql_insert_command(table_name, table_header_list, insert_data_list)
        Make SQL insert command.
    
    make_sql_select_command(table_name, table_header_list, where_columns=None, where_options=None, where_values=None, where_bools=None, group=None, having_columns=None, having_bools=None, having_values=None)
        Make SQL select command.
        
        @param table_header_list - list of columns to be selected
        @param where_columns - column names for where clause
        @param where_options - operator for where clause
        @param where_values - variable for where clause
        @param where_bools - boolean for where clause
        @param group - group name for GROUP BY clause
        @param having_columns
    
    make_sql_update_command(table_name, table_header_list, update_data_list, where_column='', where_option='', where_value='')
        Makes SQL update command
        @param table_name - Updating table
        @param table_header_list - Selected columns
        @param where_columns - Where column names
        @param where_options - List of operators
        @param where_values - variable for where clause 
        @param where_bools - boolean for where clause


Help on module sbider_grapher:

NAME
    sbider_grapher - Subtitle

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/sbider_grapher.py

DESCRIPTION
    Descriptive paragraph
    
    ******************************************************************************
    @author: Joaquin Reyna, University of California, San Diego
             Huwate(Kwat) Yeerna, University of California, San Diego
    ******************************************************************************

FUNCTIONS
    add_edge_id_abbreviation(edge, abbrev1, abbrev2, index1=0, index2=0)
    
    add_edge_list_id_abbreviation(edge_list, abbrev1, abbrev2, index1=0, index2=0)
    
    add_node_id_abbreviation(node_, abbrev, index)
        Adds an id abbreviation to a node.
        
        Argument(s):
            node - list representing node information.
            abbrev - string abbreviation.
            index - integer indicating which value to abbreviate.
        
        Return:
            A node with the abbreviation added to the given index.
            For example: [ "abbreviation_node_id", "node_field_2", "node_field_3", ...]
    
    add_node_list_id_abbreviation(node_list, abbrev, id_index)
        Adds an id abbreviation to a list of nodes.
        
        Argument(s):
            node_list - list containing nodes.
            abbrev - string abbreviation.
            index - integer indicating which value to abbreviate.
        
        Return:
            A node_list the abbreviation added to the given index
            of every node.
            For example: [ [ "abbreviation_node_id_1", "node_field_2", "node_field_3", ...],
                           [ "abbreviation_node_id_2", "node_field_2", "node_field_3", ...], ...]
    
    add_node_values_to_nxgraph(nxgraph, node_list)
        Extracts the node id and enters it into nxGraph.
    
    create_input_species_nodes(cursor, it_id)
        Create species nodes from the corresponding it_id.
    
    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", ...] )
    
    create_json_network_file(json_file_path, species_nodes_list, input_transitions_nodes_list, operon_nodes_list, output_transitions_nodes_list, source_id_target_id_list)
        Writes the whole network json.
        :param json_file_path:
        :param species_nodes_list:
        :param input_transitions_nodes_list:
        :param operon_nodes_list:
        :param output_transitions_nodes_list:
        :param source_id_target_id_list:
    
    create_json_network_string(species_nodes_list, input_transitions_nodes_list, operon_nodes_list, output_transitions_nodes_list, source_id_target_id_list, path_json_highlighter)
    
    create_json_whole_network_file(file_name, cursor)
        Generates the whole network json.
    
    create_operon_node(cursor, operon_id)
        Create an operon node from the corresponding operon_id.
        
        Argument(s):
            cursor - sqlite 3 cursor object.
            operon_id - sbider based operon id
        
        Return:
            A tuple with operon node information as a tuple
            (id abbrevation included) and the corresponding
            operon id.
            For example: ( ("ope_1-1", "pLux-->gfp", "sbol_image_path_1"), "1-1" )
    
    create_output_species_nodes(cursor, ot_id)
        Create species nodes from the corresponding ot_id.
    
    create_output_transition_node(cursor, operon_id)
        Create output transition nodes from the corresponding operon_id.
        
        Argument(s):
            cursor - sqlite3 cursor object
            operon_id - sbider based operon id
        
        Return:
            A list of tuples with operon node information.
    
    create_subnetwork_json_string(cursor, list_of_operon_paths)
        Generates the subnetwork json.
    
    create_subnetwork_path(cursor, starting_species_list, operon_path, it_trans_dict)
        Creating a subnetwork path.
        :rtype : object
        :param cursor:
        :param starting_species_list: 
        :param operon_path: 
        :param it_trans_dict:
    
    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", ...]
    
    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.
    
    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.
    
    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.
    
    get_path_json_array(cursor, starting_species_list, operon_paths_list)
        Generate json array for node highlighting.
    
    get_subnetwork(cursor, list_of_operon_paths)
    
    get_whole_network(cursor)
        Whole network data prep for json.
    
    list_of_lists(list_of_tups)
        Creates a list of lists from a list of tuples.
        
        Return:
            A list with list values.
    
    list_of_tuples(list_of_lsts)
        Creates a list of tuples from a list of lists.
        
        Return:
            A list with tuple values.
    
    merge_list_of_lists(list_of_lsts)
        ALREADY EXISTS IN THE HELPER!!
    
    nx_node_coordinates_dictionary(node_id_list, edge_list)
        Creates a dictionary of node coordinates using spring layout from networkx.
        
        Argument(s):
            node_id_list - ids of nodes for positioning
            edge_list - all edges between nodes stored in a tuple as follows,
                        (source_node_id, target_node_id)
        
        Return:
            A dictionary mapping
    
    resize_network(total_subnetwork_nodes, total_whole_nodes=540)
        Resize the network.
    
    unique_node_list(nodes_list)
        Removal of duplicate nodes from the node_list.
        
        Argument(s):
            node_list - list of node information stored as list (list of lists).
        
        Return:
            A list of unique nodes.
            For example:
            [ ["node_id_1", "node_field_2", "node_field_3"], ["node_id_2", "node_field_2", "node_field_3", ...], ...]


Help on module sbider_network_builder:

NAME
    sbider_network_builder - Subtitle

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/sbider_network_builder.py

DESCRIPTION
    Descriptive paragraph
    
    ******************************************************************************
    @author: Huwate(Kwat) Yeerna, University of California, San Diego
             Joaquin Reyna, University of California, San Diego
    ******************************************************************************

FUNCTIONS
    build_sbider_network(directory_path, user_query, indirect=False)


Help on module sbider_parser:

NAME
    sbider_parser - Subtitle

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/sbider_parser.py

DESCRIPTION
    Descriptive paragraph
    
    ******************************************************************************
    @author: Huwate(Kwat) Yeerna, University of California, San Diego
    ******************************************************************************

FUNCTIONS
    grammar_0(cursor, tokens)
        Grammar for 'grammar_0:= grammar_1 > grammar_1'.
        :param cursor:
        :param tokens:
        :return:
    
    grammar_1(cursor, tokens)
        Grammar for 'grammar_1:= grammar_2 or grammar_1 |
        grammar_2 and grammar_1 |
        grammar_2'.
        :param cursor:
        :param tokens:
        :return:
    
    grammar_2(cursor, tokens)
        Grammar for 'grammar_2:= (grammar_1) or grammar_1 |
        (grammar_1) and grammar_1 |
        (grammar_1) |
        interactor'.
        :param cursor:
        :param tokens:
        :return:
    
    grammar_and(tokens1, tokens2)
        Grammar for 'and'.
        :param tokens1:
        :param tokens2:
        :return:
    
    grammar_or(tokens1, tokens2)
        Grammar for 'or'.
        :param tokens1:
        :param tokens2:
        :return:
    
    grammar_output(tokens1, tokens2)
        Grammar for '='.
        :param tokens1:
        :param tokens2:
        :return:
    
    interactor(cursor, token)
        Grammar for 'interactor'.
        :param cursor:
        :param token:
        :return:
    
    parse_logic(cursor, logic_input)
        Parse a logic input into atomized and equivalent logic.
        :param cursor:
        :param logic_input:
        :return:


Help on module sbider_searcher:

NAME
    sbider_searcher - Subtitle

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/sbider_searcher.py

DESCRIPTION
    Descriptive paragraph
    
    ******************************************************************************
    @author: Huwate(Kwat) Yeerna, University of California, San Diego
             Joaquin Reina, University of California, San Diego
    ******************************************************************************

FUNCTIONS
    build_direct_sbider_path(input_dictionary, repressor_dictionary, output_dictionary, input_species_list, output_species_list, path_queue, final_operon_path_list, memory_operon, memory_species, activated_paths, indirect_flag)
    
    build_indirect_sbider_path(input_dictionary, repressor_dictionary, output_dictionary, input_species_list, output_species_list, path_queue, final_operon_path_list, memory_operon, memory_species, activated_paths)
    
    build_sbider_path_memory_tree(input_dictionary, activated_paths, start_operon)
    
    get_sbider_path(inp_dic, rep_dic, outp_dic, inp_spe, outp_spe, indirect_flag=False)
    
    search_sbider_path_memory(input_dictionary, activated_paths, from_operon)


Help on module sbider_upload_database:

NAME
    sbider_upload_database

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/sbider_upload_database.py

FUNCTIONS
    check_species_name_in_database(cursor, species_name)
        Safely return species id or None.
    
    db_test()
    
    determine_and_insert(connection, cursor, component_keyword, component_data=[], parent_component_id='')
        Determine insertion method and insert into into the database.
    
    determine_parent_keyword(component_keyword)
        Determine which is your parent keyword.
    
    get_data_keyword(data_string)
        Get the keyword belonging to data_string.
    
    get_last_row_id(cursor, table_name)
        Get the last inserted rowid.
    
    insert_new_device(connection, cursor, device)
        Inserts a new device into the database.
        Argument(s):
            connection - sqlite3 connection object
            cursor - sqlite3 cursor object
            device_string - whole device as a string
    
    insert_new_input_transition(cursor, operon_id, logic)
        Insert new input transition.
    
    insert_new_input_transition_species(cursor, it_id, species_name, species_type, species_repression)
        Insert new input transition species.
    
    insert_new_operon(cursor, plasmid_id, operon_name, direction)
        Insert new operon.
    
    insert_new_output_transition(cursor, operon_id)
        Insert new output transition.
    
    insert_new_output_transition_species(cursor, ot_id, species_name, species_type)
        Insert new output transition species.
    
    insert_new_plasmid(cursor, plasmid_name, miriam_id)
        Insert new plasmid.
    
    main()
    
    make_input_transition_sbml_file(input_species_list, transition_id, operon_id, trans_logic)
    
    make_new_id(id_string)
        Convert old string id to old string id + 1.
    
    make_output_transition_sbml_file(output_species_list, transition_id, operon_id)
        make the sbml.
    
    make_sbol_file(output_species_list, promoter_list, prev_operon_direction, operon_id)
        Insert and make the sbol file.
    
    make_sbol_string_db_update(input_list, direction)
        Make an sbol string using uploading information.
    
    reset_db(original_db='sbider.db', test_db_file='sbider_test_2.db')
    
    select_last_inserted_table_id(cursor, table_name, table_id_type)
        Select the last inserted row.
    
    select_last_inserted_table_row(cursor, table_name)
        Select the last inserted row.
    
    write_sbol_file(operon_id, sbol_string)
        Write out sbol string to file.
    
    write_to_file(string_to_write, file_name)
        Write a file.


Help on module sbml_database:

NAME
    sbml_database - //Title: SBML Database Access

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/sbml_database.py

DESCRIPTION
    //Description: 
        Access SBiDer database and retrieve all necessary SBML information 
    
    *************************************************
    @author: Fernando Contreras
    @email: f2contre@gmail.com
    @project: SBiDer
    @institution: University of California, San Diego
    *************************************************

FUNCTIONS
    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
    
    get_sbml_input_operon_edges()
        Access the input transition-operon relationship table and acquire 
        input transition-operon edges
        
        @Output: dictionary = {it_id: ope_id}
            key = input transition id 
            value = operon id
    
    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'
    
    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
    
    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
    
    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
    
    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
    
    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

DATA
    con = 
    cursor = 
    cwd = '/Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web'
    database_path = '/Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/w...


Help on module sbml_update:

NAME
    sbml_update - //Title: SBML Node Generator

FILE
    /Users/jenhantao/Documents/UCSD_IGEM/CircuitNetwork/web/sbml_update.py

DESCRIPTION
    //Description: 
        Translate individual node information to SBML and store node file 
        in current working directory  
    
    *************************************************
    @author: Fernando Contreras
    @email: f2contre@gmail.com
    @project: SBiDer
    @institution: University of California, San Diego
    *************************************************

FUNCTIONS
    sbml_input_trans(trans_id, input_species_id_and_boolean_tuple, operon_id, trans_logic, filename)
        #construct input/output transition component of network SBML file
    
    sbml_operon(operon_id, operon_name, miriam_id, filename)
        #construct operon/chemical species component of network SBML file
    
    sbml_output_trans(trans_id, output_species_id, operon_id, filename)
    
    sbml_species(species_id, species_name, filename)

Testing

SBiDer Function Testing

Database

The database wrapper functions were tested by verifying correct table creation and droppage. Individual SQL Python wrapper functions were tested for proper input, update, and removal of table entries. Functions were tested on the SBiDer database itself to ensure future functional usage of the SBiDer API.

Logic Parser

The SBiDer logic parser required testing under multiple logic situations. The input necessary for parsing logic is specific due to the ability to make complex search queries. AND logic testing was done by verifying proper breakdown of the logic. OR logic testing was done by verifying that multiple queries were generated with the total number of queries equal to the total number of OR statements plus one.

Traversal: Direct and Indirect Algorithms

To ensure that the correct paths were generated a Python unit test was constructed to verify proper operon activation along a given path. We considered two options for our traversal: direct path and indirect path.

In the direct path the preceding operon produces the species necessary for the activation of the following operon. Iteration through a loop ensured that all paths discovered by the traversal algorithm were legitimate activatable paths. This was done by starting at the first operon of every path and checking whether the starting input species were enough to activate the first operon. That operon would then produce some species that would then have to activate the next operon. Assertions were made at this point to verify if the species taken as input for operon activation were those produced by the previous operon or initial input. If all operons were activated then that would mean that the path was a correct linear path.

As an example query Lara and araC are the starting input species and gfp is the final output species. The query has the following operon path: pLac_pBAD--->LuxR_luxI followed by pTet--->gfp. An assertion is done at operon pLac_pBAD--->LuxR_luxI to verify if Lara and arac activate it. The assertion is passed because pLac_pBAD--->LuxR_luxI is activated by Lara and arac and the operon produces the species AHL and luxR. One last assertion is done to verify if AHL and LuxR activate pTet--->gfp. This assertion is passed and so operon pTet--->gfp produces gfp, the desired final species.

The approach to verify the indirect traversal option was more involved due to path convergence. A Python unittest was created using two sets: one containing all inputs necessary for every operon in the path (set I), and one containing all of the outputs for every operon in the path plus the starting inputs (set O). If set I is a subset of set O, this verifies that the indirect operon path is constructed correctly and therefore activation will occur.

An example the same query will be reused here below. The indirect traversal has the following path: pCONST--->araC, pBAD--->T7-C, pT7--->gfp. pCONST--->araC uses a constitutive promoter (no input) and produces araC. pBAD--->T7-C takes as input arac and Lara and produces T7-C. pT7--->gfp takes as input T7 and produces gfp. Set I in this case contains arac, lara and T7. Set O in this case contains arac, Lara, T7 and gfp. Set I is a subset of set O so all of the input species necessary to activate the operons in the path are activated and the path is a correct path.

Traversal: Accounting for Repressor Species

The current SBiDer development only takes queries for activation of genetic devices. As a result operons may not be activated due to repression events. To verify this event it was necessary to manually trace and validate paths that had species products with repression interactions with operons that could potentially repress our system.

Complexity Analysis of the Search Algorithm

The complexity analysis was performed on the search algorithm, which have two methods of search: linear successive activation search (LSAS) and nonlinear successive activation search (NLSAS). Our complexity analysis concluded the complexity of LSAS and NLSAS to be O(mV^2) and O(m^2*V^4). respectively. Detailed complexity analysis can be found in the documentation section.

JSON Generation

The SBiDer network shown at the beginning of the SBiDer application as well as the subnetwork that resulted from the traversal output required JSON files with complete information. This information was captured using functions for data extraction and processing which were individually tested by running inputs and reviewing printing the resulting output with great care. Once the information was gathered, it was inserted into the JSON file generator. The JSON string was then taken and validated using the Online JSON Viewer. The image produced by the JSON converter was then displayed on CyNetShare using Cytoscape JS. In addition, the table generated by the JSON converter was validated against the database itself to ensure that the network was correctly reproduced.

SBML Generation

The SBML document was taken and validated using the Online SBML Validator (http://sbml.org/Facilities/Validator/). We ensured that our SBML documents were accurate.

SBOL Validation

We confirmed that the images we generated supported the SBOL standard by comparing the corresponding text file for each image to with images from the SBOL website. We ensured that the correct images were produced for all of the image.
Check out the test code on our GitHub branch.