The views defined here form the logic behind what gets displayed through the HTML templates. These views get their arguments through Django’s URL pattern matching procedure. For a more in-depth explanation on how Django’s views work please see Writing Views.
- cpipilot.repository.views.search(request)¶
Takes in a query string, q, from the GET data given to this request by the HTML form in templates/base.html. At the moment this search function looks for entities of any type who’s selected ‘matching’ identifiers match with the search string. This method also has the option of limiting the type of entity being searched for by supplying a type string in the GET data. This type string in the GET data is supplied when the user must choose between multiple entity types that have been found (see Logic Description below). The search string is considered to match if it is found in any part of the following model’s selected ‘matching’ identifiers listed below:
- The gene’s HGNC symbol
- The target’s externalID
- The reagent’s externalID
- The experiment’s name
- The phenotype’s description
Logic Description:
If the search string is valid (longer than 2 characters), then the Django ORM is used to filter all appropriate model tables and find the relevant entities. Depending on what is found, the function proceeds as follows:
- If multiple entity types are found (say X genes, Y reagents and Z experiments) then the templates/repository/multipleTypesFound.html HTML template is returned as a response passing in all found entities by their types. From this page it is possible for a user to select the type you were intending to find. This user selection appends a type variable to the GET data indicating that other found entity types should be ignored the next time this view function is processed.
- If multiple entities of a single entity type are found then the corresponding HTML template that renders multiple entities of that type is returned as a response (e.g. templates/repository/gene/genes.html). The view passes in a list of the found entities to this template through the context dictionary parameter. This allows the user to find the specific entity.
- If only a single entity is found to match the search string then that entity page is shown by returning the HTML template that renders that specific entity.
- cpipilot.repository.views.geneSingle(request, id)¶
Returns an HttpResponse constructed by rendering the templates/repository/gene/geneSingle.html template with the appropriate context resulting in the gene page.
Logic Description:
- The gene is retrieved from the id parameter.
- Distinct targets related to this gene are retrived.
- Distinct reagents targetting these targets are retrieved.
- Distinct phenotypes produced through the use of these reagents are retrived.
- The QuerySets returned by these filtering steps are sent through to the geneSingle HTML template.
- cpipilot.repository.views.targetSingle(request, id)¶
Returns an HttpResponse constructed by rendering the templates/repository/target/targetSingle.html template with the appropriate context resulting in the target page.
Logic Description:
- The target is retrieved from the id parameter.
- Distinct phenotypes produced by the reagents that target this target are retrived.
- Distinct reagent/target links where the target is this target are retrived.
- A list of reagent/target links together with the experiments that claim these links is constructed.
- The QuerySets returned by these filtering steps and the constructed list are sent through to the targetSingle HTML template.
- cpipilot.repository.views.reagentSingle(request, id)¶
Returns an HttpResponse constructed by rendering the templates/repository/reagent/reagentSingle.html template with the appropriate context resulting in the reagent page.
Logic Description:
- The reagent is retrieved from the id parameter.
- Distinct phenotypes produced by the reagent are retrieved.
- ImageSets from wells where this reagent has been used are retrieved.
- Distinct reagent/target links where the reagent is this reagent are retrived.
- A list of reagent/target links together with the experiments that claim these links is constructed.
- The QuerySets returned by these filtering steps and the constructed list are sent through to the reagentSingle HTML template.
- cpipilot.repository.views.phenotypeToGene(request, id)¶
Returns an HttpResponse constructed by rendering the templates/repository/phenotype/phenotypeToGene.html template with the appropriate context. This HttpResponse forms the first tab in the phenotype page.
Logic Description:
- The phenotype is retrieved from the id parameter.
- Distinct targets targeted by the reagents that produce this phenotype are retrived.
- Distinct genes that are related to these targets are retrieved.
- A paginator is used to split the genes into contiguous lists of 18 genes and the right list of genes for the corresponing page is retrived. Normally paginators are used in the HTML template by invoking the correct template tag but in this special case the gene list needs to be broken up so that a duo list can be constructed and passed into the HTML template.
- A new duo list of gene/targets pairs is built from the gene page list by including all target ids and target external ids that are both related to the gene and that are in the target list retrived above.
- The QuerySets returned by these filtering steps and the constructed list are sent through to the phenotypeToGene HTML template.
- cpipilot.repository.views.phenotypeToReagent(request, id)¶
Returns an HttpResponse constructed by rendering the templates/repository/phenotype/phenotypeToReagent.html template with the appropriate context. This HttpResponse forms the second tab in the phenotype page.
Logic Description:
- The phenotype is retrieved from the id parameter.
- Distinct reagents that produce this phenotype are retrived.
- The QuerySets returned by these filtering steps are sent through to the phenotypeToReagent HTML template.
- cpipilot.repository.views.phenotypeGeneLinkage(request, phenotypeID, geneID)¶
Returns an HttpResponse constructed by rendering the templates/repository/phenotype/phenotypeGeneLinkage.html template with the appropriate contextresulting in the gene/phenotype linkage page.
Logic Description:
- The phenotype is retrieved from the phenotypeID parameter.
- The gene is retrieved from the geneID parameter.
- Distinct reagents that produce this phenotype and that are related to this gene through their targets are retrived.
- A dictionary is constructed in which each entry is itself a dictionary consisting of the reagents above as well as their targets and related imageSets.
- The gene and phenotype returned by these get steps and the constructed dictionary are sent through to the phenotypeGeneLinkage HTML template.
- cpipilot.repository.views.imageSetSingle(request, id)¶
Returns an HttpResponse constructed by rendering the templates/repository/phenotype/imageSetSingle.html template with the appropriate context resulting in the data page.
Logic Description:
- The imageSet is retrieved from the id parameter.
- The imageSet and the DATA_ROOT variable from the settings.py module are sent through to the imageSetSingle HTML template.
- cpipilot.repository.views.experimentsAll(request)¶
Returns an HttpResponse constructed by rendering the templates/repository/experiment/experiments.html template with the appropriate context resulting in the experiments page which lists all available experiments.
Logic Description:
- All experiments are retrived and set through to the experiments HTML template.
- cpipilot.repository.views.experimentSingle(request, id)¶
Returns an HttpResponse constructed by rendering the templates/repository/experiment/experimentSingle.html template with the appropriate context resulting in the experiment page.
Logic Description:
- The experiment is retrieved from the id parameter.
- All related phenotypes are retrived.
- An attempt is made to acertain the size of the initial zip file.
- If this attempt is successful then downloadExists will be set to true and the template will show the download link button for this experiment.
- The experiment, it’s related phenotypes and other informative variable are sent through to the experimentSingle HTML template.
- cpipilot.repository.views.experimentDownload(request, id)¶
Returns an HttpResponse constructed by rendering the templates/repository/experiment/experimentDownload.html template with the appropriate context resulting in a page which starts the download of the initial zip file and displays information on what the initial zip download contains together with instructions on downloading all experimental raw data.
Logic Description:
- The experiment is retrieved from the id parameter.
- The experiment and the download location of the initial zip file are sent through to the experimentDownload HTML template.