disbi.result module

Class for getting the joined table with data based on a list of experiments.

class disbi.result.DataResult(requested_experiments, experiment_meta_model)[source]

Bases: object

Constructs the datatable based on the request from the filter view.

DB_FUNCTION_ZERO = 'divide_without_zeroerr'
DB_PRECISION = "'9.9999EEEE'"
add_foldchange(exps_for_fc, fetch_as='ordereddict')[source]

Add the fold change to a base table.

construct_SELECT_AS(exp)[source]

Construct part of a SQL statement for alias DB columns with their display name.

Parameters:exp (Experiment) – The experiment.
Returns:str – The partial statement for aliasing the columns.
construct_base_table()[source]

Construct the SQL statement for creating the base table.

Returns:str – The SQL statement for creating the base table.
construct_exptable(exp)[source]

Construct the subquery for producing selection of all data points mapping to one experiment.

Only data points which foreign key matches the experiment will be selected. Data points for which an exclude column evaluates to False will be excluded.

Parameters:exp (disbimodels.Experiment) – The experiment for which the data is selected.
Returns:str – A SQL statement for the selection of the datapoints.
construct_result_table(biomodels)[source]

Construct the SQL statement for getting the result table.

For each biological model, the respective experiments will be filtered. For those experiments a subquery is constructed, that is then LEFT JOINed into the prejoined backbone table. Only rows that have at least one data point are preserved.

Parameters:biomodels (list) – List of Biological models.
Returns:str – The SQL statement for the result table.
create_base_table(table_name)[source]

Create the base table and write it to the DB.

Parameters:table_name (str) – The name under which the table should be created.
Returns:None – This is a procedure.
get_colnames(model)[source]

Get a list of all DB columns with di_show=True.

Parameters:model (models.Model) – The model for which the fields are retrieved.
Returns:list – A list of strings with the DB column names.
get_display_names(exp)[source]

Get the display names for the columns of a MeasurementModel of an experiment.

Parameters:exp (Experiment) – The experiment.
Returns:tuple – A tuple of strings containing the display names suffixed by the experiment id.
get_exp_columns(wanted_exps)[source]

Get column of respective experiment.

get_foldchange(exps_for_fc)[source]

Get only the fold change column.

get_notnull_column(exp)[source]

Get a column that can not be NULL and will be shown.

Parameters:exp (Experiment) – The experiment for which the column should be retrieved.
Returns:models.Field
The first field that will be shown and is neither
NULL or blank.
Raises:NotFoundError
get_or_create_base_table(fetch_as='ordereddict')[source]

Retrieve the base table from the DB. Create it if it does not exist.

Returns:The values fetched from the DB.
get_show_columns(model)[source]

Get a list of DB columns that should be shown in the result table.

Parameters:model (models.Model) – A Django model with custom DISBI options.
Returns:list – List of strings containing the DB column names of the fields to be shown.
wrap_in_func(func, *cols)[source]

Pass column names as arguments to DB function.