Query support

A key component of Enterobase is the ability to perform queries to select strains that meet certain criteria. This can be done via:

  • The query dialog box
  • The API

Query dialog box

The query dialog box is generated using html code followed by extensive javascript at the start of the edit_strain_metadata.html template ( see Template Hierarchy). which is created by species/views.py:search_strains.

The details of the grid and the search box are provided by the extensive javascript starting at ‘{% block windowready %}’ in edit_strain_metadata.html

The inforation to populate all the dropdowns in the query box is then obtained by using a series of call_restful_JSON calls starying with a call to the URL /get_experiment_details which is handled by main/views.py/get_experiment_details() right at the end of the javascript.

The javascript function submitQuery() is then used to submit the query consolidating the query information before moving to submitQuery2() which uses /get_data_for_exierment to

Scheme specific query code

All schemes/pipeline jobs must identify the query method that is used to query the associated data. It is identified by the “query_method” parameter in the param column of the schemes table. These data are used in initialisation code at the end of query_functions.py to populate the query_function_handle multilevel dictionary with information about what function to call for each species/scheme combination.

Selecting data to be displayed and transfer of data from client to server

The query dialogbox is used to generate the info as to what strains are to be displayed which is passed to the code in ExtraFuncs/query_functions.py in SQL format. This is then used to collate the data from a combination of sources such as:

  • Strain data from the strains table
  • Experimental data from one of:
    • Assembly data from the assemblies table.
    • Nomenclature data from NServ using the __nserv_q procedure
    • Miscellaneous experimental data from the other_data column of the entry of the assembly_llokup table entry associated with the job that was run to produce the result
    • AMR analysis data from the amr_analysis table using the process_amr_analysis_query procedure

The SQL query associated with the query is modified as required to be able to select the requested strains, and the raw data from the various sources is converted to JSON to be returned to the client. The code for querying the experimental data takes two forms of queries:

  • A simple list of assembly ids such that teh associated experiemtal data can be returned. One occasion when this is used is when the user has already selected a set of strains, and then switches to a different set of associated experimental data.
  • A full SQL query of the experimental data which is used to select the strains that meet the criteria. this will be combined (AND or OR) with the accompanying query on the strain metadata.