Computational data (Views)¶
The models that these views work on can be found in Computational data (Models)
Where the views are used (frontend)¶
Note: For the Diamond instance of fragalysis, authentication is handled by api.security.ISpyBSafeQuerySet,
a version of the standard DRF (see RESTful API (Views)) viewsets.ReadOnlyModelViewSet.
viewer.views.ComputedSetView: This view is used to generate a list of all of the computed sets that exist for a specific target, so that the drop-down list for the third tab on the right-hand side (RHS) can be generated for each target-specific pageviewer.views.ComputedMolAndScoreView: This view is used to get all information about 3D molecules in a given computed set for a given target (computed sets obtained fromviewer.views.ComputedSetView). The smiles string is used to generate the 2D image shown on each molecule in the RHS computed set tab usingviewer.views.img_from_smiles. The scores for each molecule are displayed on the respective molecule card.viewer.views.cset_key: This view is used to generate a computed set upload key at<root>/viewer/cset_key, and email it to the user to allow them to upload new computed sets at<root>/viewer/upload_csetviewer.views.UploadCSet: This view is used to generate the form found at<root>/viewer/upload_cset, and to pass the values to the celery tasks controlled throughviewer.views.ValidateTaskViewandviewer.views.UploadTaskViewthat validate and process the uploaded data, saving it into the relevant models (see Computational data (Models))so that the data can be displayed on the RHS of a target specific page.
Other views listed below are currently not in use by the front-end.
View details¶
-
class
viewer.views.ComputedSetView(**kwargs)¶ DjagnoRF view to retrieve information about computed sets
-
url: api/compound-sets
-
queryset: viewer.models.ComputedSet.objects.filter()
-
filter fields: viewer.models.ComputedSet.target - ?target=<int>
-
returns: JSON name: name of the computed set
submitted_sdf: link to the uploaded sdf file
spec_version: version of the upload specification used to generate the computed set sdf
method_url: link to url describing the methodology used to create the computed set
unique_name: auto-generated human-readable name for the computed set
target: id for the associated target
submitter: id for the associated submitter
-
example output: "results": [ { "name": "100threehop2020-07-27S8vv3vx", "submitted_sdf": "http://fragalysis.diamond.ac.uk/media/code/media/compound_sets/Top_100_three_hop_2020-07-27_S8vv3vx.sdf", "spec_version": 1.2, "method_url": "https://github.com/Waztom/xchem-xCOS", "unique_name": "WT-xCOS2-ThreeHop", "target": 62, "submitter": 13 },]
-
serializer_class¶ alias of
viewer.serializers.ComputedSetSerializer
-
-
class
viewer.views.ComputedMoleculesView(**kwargs)¶ DjagnoRF view to retrieve information about computed molecules - 3D info
-
url: api/compound-molecules
-
queryset: viewer.models.ComputedMolecule.objects.filter()
-
filter fields: viewer.models.ComputedMolecule.computed_set - ?computed_set=<int>
-
returns: JSON id: id of the molecule
sdf_info: 3D coordinates of the molecule in MDL format
name: a name for the molecule
smiles: SMILES string
pdb_info: link to the associated pdb file (apo)
compound: id for the associated 2D compound
computed_set: name for the associated computed set
computed_inspirations: list of ids for the inspirations used in the design/computation of the molecule
-
example output: "results": [ { "id": 1997, "sdf_info": "FRA-DIA-8640f307-1 RDKit 3D 38 42 0 0 0 0 0 0 0 0999 V2000..." "name": "FRA-DIA-8640f307-1", "smiles": "CC(=O)NCCc1c[nH]c2c([C@H](CN(Cc3cc(C)on3)C(=O)NC3CC3)c3nnc(C)s3)cc(F)cc12", "pdb_info": "http://fragalysis.diamond.ac.uk/media/pdbs/Fragmenstein_J6Sfvrs.pdb", "compound": 4030, "computed_set": "100XCOS2Teo2020-07-23yuZJZFY", "computed_inspirations": [] },]
-
serializer_class¶ alias of
viewer.serializers.ComputedMoleculeSerializer
-
-
class
viewer.views.NumericalScoresView(**kwargs)¶ DjagnoRF view to retrieve information about numerical computed molecule scores
-
url: api/numerical-scores
-
queryset: viewer.models.NumericalScoreValues.objects.filter()
-
filter fields: viewer.models.NumericalScoreValues.compound - ?compound=<int>
viewer.models.NumericalScoreValues.score - ?score=<int>
-
returns: JSON id: id of the score
- score: dict of the score info:
id: id of the score description
name: name of the score
description: description of the score
computed_set: name of the computed set that the score is associated to
value: numerical value of the score
compound: id of the associated compound object
-
example output: "results": [ "results": [ { "id": 8145, "score": { "id": 48, "name": "Score_1", "description": "The score is scaled by the number of bit atoms", "computed_set": "100XCOS2Teo2020-07-23yuZJZFY" }, "value": 19.8653, "compound": 1997 },
-
serializer_class¶ alias of
viewer.serializers.NumericalScoreSerializer
-
-
class
viewer.views.TextScoresView(**kwargs)¶ DjagnoRF view to retrieve information about text computed molecule scores
-
url: api/text-scores
-
queryset: viewer.models.TextScoreValues.objects.filter()
-
filter fields: viewer.models.TextScoreValues.compound - ?compound=<int>
viewer.models.TextScoreValues.score - ?score=<int>
-
returns: JSON id: id of the score
- score: dict of the score info:
id: id of the score description
name: name of the score
description: description of the score
computed_set: name of the computed set that the score is associated to
value: text value of the score
compound: id of the associated compound object
-
example output: "results": [ "results": [ { "id": 8145, "score": { "id": 48, "name": "Score_1", "description": "Desctription", "computed_set": "100XCOS2Teo2020-07-23yuZJZFY" }, "value": "Yes", "compound": 1997 },
-
serializer_class¶ alias of
viewer.serializers.TextScoreSerializer
-
-
class
viewer.views.CompoundScoresView(**kwargs)¶ DjagnoRF view to retrieve descriptions of scores for a given name or computed set
-
url: api/compound-scores
-
queryset: viewer.models.ScoreDescription.objects.filter()
-
filter fields: viewer.models.ScoreDescription.computed_set - ?computed_set=<int>
viewer.models..ScoreDescription.name - ?name=<str>
-
returns: JSON id: id of the score
- score: dict of the score info:
id: id of the score description
name: name of the score
description: description of the score
computed_set: name of the computed set that the score is associated to
-
example output: "results": [ { "id": 22, "name": "FeatureSteinScore", "description": "FeatureStein Score", "computed_set": "top26062020axX6Vqt" },]
-
serializer_class¶ alias of
viewer.serializers.ScoreDescriptionSerializer
-
-
class
viewer.views.ComputedMolAndScoreView(**kwargs)¶ DjagnoRF view to retrieve all information about molecules from a computed set, along with all of their scores
-
url: api/compound-mols-scores
-
queryset: viewer.models.ComputedMolecule.objects.filter()
-
filter fields: viewer.models.ComputedMolecule.computed_set - ?computed_set=<int>
-
returns: JSON id: id of the molecule
sdf_info: 3D coordinates of the molecule in MDL format
name: a name for the molecule
smiles: SMILES string
pdb_info: link to the associated pdb file (apo)
compound: id for the associated 2D compound
computed_set: name for the associated computed set
computed_inspirations: list of ids for the inspirations used in the design/computation of the molecule
numerical_scores: dict of numerical scores, where each key is a score name, and each value is the associated score
text_scores: dict of text scores, where each key is a score name, and each value is the associated score
-
example output: "results": [ { "id": 1997, "sdf_info": "FRA-DIA-8640f307-1 RDKit 3D 38 42 0 0 0 0 0 0 0" "name": "FRA-DIA-8640f307-1", "smiles": "CC(=O)NCCc1c[nH]c2c([C@H](CN(Cc3cc(C)on3)C(=O)NC3CC3)c3nnc(C)s3)cc(F)cc12", "pdb_info": "http://fragalysis.diamond.ac.uk/media/pdbs/Fragmenstein_J6Sfvrs.pdb", "compound": 4030, "computed_set": "100XCOS2Teo2020-07-23yuZJZFY", "computed_inspirations": [], "numerical_scores": { "Score_1": 19.8653, "N_hits": 4.0 }, "text_scores": {} },]
-
serializer_class¶ alias of
viewer.serializers.ComputedMolAndScoreSerializer
-
-
class
viewer.views.cset_key(request)¶ View to render and control viewer/generate-key.html - a page allowing an upload key to be generated for a user allowing upload of computed sets
-
allowed requests: GET: renders form
POST: generates an upload key, emails it to the user, and informs the user that this will happen
-
url: viewer/cset_key
-
template: viewer/generate-key.html
-
request params: contact_email (django.forms.FormField): user contact email
-
context: form (django.Forms.form): instance of viewer.forms.UploadKeyForm
message (str): A message rendered in the template. Informs the user that their upload key will be emailed
-
-
class
viewer.views.UploadCSet(**kwargs)¶ View to render and control viewer/upload-cset.html - a page allowing upload of computed sets. Validation and upload tasks are defined in viewer.compound_set_upload, viewer.sdf_check and viewer.tasks and the task response handling is done by viewer.views.ValidateTaskView and viewer.views.UploadTaskView
-
allowed requests: GET: renders form
POST: validates and optionally uploads the computed set that the user provides via the template form
-
url: viewer/upload_cset
-
template: viewer/upload-cset.html
-
request params: target_name (django.forms.CharField): Name of the existing fragalysis target to add the computed set to
sdf_file (django.forms.FileField): SDF file of all computed molecules to upload for the computed set
pdb_zip (django.forms.FileField): zip file of apo pdb files referenced in the ref_pdb field for molecules in sdf_file (optional)
submit_choice (django.forms.CharField): 0 to validate, 1 to validate and upload
upload_key (django.forms.CharField): users unique upload key, generated by viewer.views.cset_key
-
context: form (django.Forms.form): instance of viewer.forms.CSetForm
validate_task_id (str): celery task id for validation step
validate_task_status (str): celery task status for validation step
upload_task_id (str): celery task id for upload step
upload_task_status (str): celery task status for upload step
-
-
class
viewer.views.ValidateTaskView(**kwargs)¶ View to handle dynamic loading of validation results from viewer.tasks.validate - the validation of files uploaded to viewer/upload_cset
-
allowed requests: GET: takes a task id, checks it’s status and returns the status, and result if the task is complete
-
url: validate_task/<validate_task_id>
-
template: viewer/upload-cset.html
-
get(request, validate_task_id)¶ Get method for ValidateTaskView. Takes a validate task id, checks it’s status and returns the status, and result if the task is complete
- Parameters
request (request) – Context sent by UploadCSet
validate_task_id (str) – task id provided by UploadCSet
- Returns
response_data –
- response data (dict) in JSON format:
- if status = ‘RUNNING’:
validate_task_status (str): task.status
validate_task_id (str): task.id
- if status = ‘FAILURE’:
validate_task_status (str): task.status
validate_task_id (str): task.id
validate_traceback (str): task.traceback
- if status = ‘SUCCESS’:
validate_task_status (str): task.status
validate_task_id (str): task.id
html (str): html of task outcome - success message or html table of errors & fail message
- Return type
JSON
-
-
class
viewer.views.UploadTaskView(**kwargs)¶ View to handle dynamic loading of upload results from viewer.tasks.process_compound_set - the upload of files for a computed set by a user at viewer/upload_cset
-
allowed requests: GET: takes a task id, checks it’s status and returns the status, and result if the task is complete
-
url: upload_task/<uploads_task_id>
-
template: viewer/upload-cset.html
-
get(request, upload_task_id)¶ Get method for UploadTaskView. Takes an upload task id, checks it’s status and returns the status, and result if the task is complete
- Parameters
request (request) – Context sent by UploadCSet
upload_task_id (str) – task id provided by UploadCSet
- Returns
response_data –
- response data (dict) in JSON format:
- if status = ‘RUNNING’:
upload_task_status (str): task.status
upload_task_id (str): task.id
- if status = ‘FAILURE’:
upload_task_status (str): task.status
upload_task_id (str): task.id
upload_traceback (str): task.traceback
- if status = ‘SUCCESS’:
upload_task_status (str): task.status
upload_task_id (str): task.id
- if results are a list (data was not validated):
validated (str): ‘Not validated’
html (str): html table of validation errors
- if results are a string (data was validated and uploaded:
validated (str): ‘Validated’
results (dict): results
results[‘cset_download_url’] (str): download url for computed set sdf file
results[‘pset_download_url’] (str): download url for computed set pdb files (zip)
- if results are not string or list:
processed (str): ‘None’
html (str): message to tell the user their data was not processed
- Return type
JSON
-
-
class
viewer.views.cset_download(request, name)¶ View to download an SDF file of a computed set by name
-
allowed requests: GET: return the SDF file as a download
-
url: viewer/compound_set/(<name>)
-
request params: name (str): the name of the computed set to download
- Returns
<name>.sdf: sdf file for the computed set
- Return type
Response (attachment; text/plain)
-
-
class
viewer.views.pset_download(request, name)¶ View to download a zip file of all protein structures (apo) for a computed set
-
allowed requests: GET: return the zip file as a download
-
url: viewer/compound_set/(<name>)
-
request params: name (str): the name of the computed set to download
- Returns
<name>.zip: zip file for the computed set
- Return type
Response (attachment; application/zip)
-