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'
add_foldchange(exps_for_fc, fetch_as='ordereddict')[source]

Add the fold change to a base table.


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 the SQL statement for creating the base table.

Returns:str – The SQL statement for creating the base table.

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 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 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 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 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 column of respective experiment.


Get only the fold change column.


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

Parameters:exp (Experiment) – The experiment for which the column should be retrieved.
The first field that will be shown and is neither
NULL or blank.

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

Returns:The values fetched from the DB.

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.