Skip to content

Commit

Permalink
Merge pull request #400 from xchem/staging
Browse files Browse the repository at this point in the history
Fixes for 944, 1065 and 1066
  • Loading branch information
alanbchristie authored Jun 20, 2023
2 parents ad808ce + d1ca76b commit 6807884
Show file tree
Hide file tree
Showing 7 changed files with 319 additions and 19 deletions.
1 change: 1 addition & 0 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
router.register(r"job_file_transfer", viewer_views.JobFileTransferView, basename='job_file_transfer')
router.register(r"job_callback", viewer_views.JobCallBackView, basename='job_callback')
router.register(r"job_config", viewer_views.JobConfigView, basename='job_config')
router.register(r"job_override", viewer_views.JobOverrideView, basename='job_override')

from rest_framework_swagger.renderers import OpenAPIRenderer, SwaggerUIRenderer
from rest_framework.decorators import api_view, renderer_classes
Expand Down
11 changes: 6 additions & 5 deletions viewer/download_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,12 @@ def _create_structures_zip(target,
errors += _molecule_files_zip(zip_contents, ziparchive,
combined_sdf_file, error_file)

# Add combined_sdf_file to the archive.
combined_sdf_file_exists = os.path.isfile(combined_sdf_file)

if zip_contents['molecules']['single_sdf_file'] is True \
and combined_sdf_file_exists:
# Add combined_sdf_file to the archive?
if (
zip_contents['molecules']['single_sdf_file'] is True
and combined_sdf_file
and os.path.isfile(combined_sdf_file)
):
ziparchive.write(
combined_sdf_file,
os.path.join(_ZIP_FILEPATHS['single_sdf_file'],
Expand Down
28 changes: 28 additions & 0 deletions viewer/migrations/0032_add_job_override_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.1.14 on 2023-05-31 13:44

from django.conf import settings
import django.core.serializers.json
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('viewer', '0031_fix_JobFileTransfer_sub_path'),
]

operations = [
migrations.CreateModel(
name='JobOverride',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('override', models.JSONField(encoder=django.core.serializers.json.DjangoJSONEncoder)),
('author', models.ForeignKey(help_text='The user that uploaded the override', null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
],
options={
'db_table': 'viewer_joboverride',
},
),
]
10 changes: 10 additions & 0 deletions viewer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,16 @@ def job_has_finished(self):
"""
return self.job_status in [JobRequest.SUCCESS, JobRequest.FAILURE, 'LOST']


class JobOverride(models.Model):
override = models.JSONField(encoder=DjangoJSONEncoder)
author = models.ForeignKey(User, null=True, on_delete=models.SET_NULL,
help_text="The user that uploaded the override")

class Meta:
db_table = 'viewer_joboverride'


class Squonk2Org(models.Model):
"""Django model to store Squonk2 Organisations (UUIDs) and the Account Servers
they belong to. Managed by the Squonk2Agent class.
Expand Down
14 changes: 13 additions & 1 deletion viewer/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
MoleculeTag,
SessionProjectTag,
JobFileTransfer,
JobRequest
JobRequest,
JobOverride
)
from viewer.utils import get_https_host

Expand Down Expand Up @@ -789,3 +790,14 @@ class Meta:
fields = ("job_status", "state_transition_time")

# End of Serializers for Squonk Jobs

class JobOverrideReadSerializer(serializers.ModelSerializer):
class Meta:
model = JobOverride
fields = '__all__'


class JobOverrideWriteSerializer(serializers.ModelSerializer):
class Meta:
model = JobOverride
fields = ('override',)
191 changes: 191 additions & 0 deletions viewer/squonk/day-1-job-override.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
{
"global": {
"job_dir": "fragalysis-jobs/{username}/{job_name}-{timestamp}",
"protein_id": "{selected_protein}"
},
"precompilation_ignore": ["job_dir", "protein_id"],
"fragalysis-jobs": [
{
"job_collection": "fragmenstein",
"job_name": "fragmenstein-combine",
"job_version": "1.0.0",
"inputs": {
"fragments": {
"type": "array",
"uniqueItems": true,
"format": "chemical/x-mdl-molfile",
"items": {
"from": "lhs",
"enum": "{inputs_dir}/{target}-{item}.mol",
"enumNames": "{item}"
}
},
"protein": {
"type": "string",
"format": "chemical/x-pdb",
"from": "lhs",
"enum": "{inputs_dir}/{target}-{item}_apo-desolv.pdb",
"enumNames": "{item}"
}
},
"options": {
"outfile": {
"default": "{job_dir}/merged.sdf",
"ui:widget": "hidden"
},
"count": {
"type": "integer",
"default": 5
},
"smilesFieldName": {
"type": "string",
"default": "original SMILES",
"ui:widget": "hidden"
},
"fragIdField": {
"type": "string",
"default": "_Name",
"ui:widget": "hidden"
},
"proteinFieldName": {
"type": "string",
"default": "ref_pdb",
"ui:widget": "hidden"
},
"proteinFieldValue": {
"type": "string",
"default": "{protein_id}",
"ui:widget": "hidden"
}
},
"outputs": {
"outputs": { "type": "string" }
},
"results": ["Merged molecules"]
},

{
"job_collection": "fragmenstein",
"job_name": "fragmenstein-combine-multi-scoring",
"job_version": "1.0.0",
"inputs": {
"fragments": {
"type": "array",
"uniqueItems": true,
"format": "chemical/x-mdl-molfile",
"items": {
"from": "lhs",
"enum": "{inputs_dir}/{target}-{item}.mol",
"enumNames": "{item}"
}
},
"protein": {
"type": "string",
"format": "chemical/x-pdb",
"from": "lhs",
"enum": "{inputs_dir}/{target}-{item}_apo-desolv.pdb",
"enumNames": "{item}"
}
},
"options": {
"outfile": {
"default": "{job_dir}/merged.sdf",
"ui:widget": "hidden"
},
"count": {
"type": "integer",
"default": 5
},
"smilesFieldName": {
"type": "string",
"default": "original SMILES",
"ui:widget": "hidden"
},
"fragIdField": {
"type": "string",
"default": "_Name",
"ui:widget": "hidden"
},
"proteinFieldName": {
"type": "string",
"default": "ref_pdb",
"ui:widget": "hidden"
},
"proteinFieldValue": {
"type": "string",
"value": "{protein_id}",
"ui:widget": "hidden"
}
},
"outputs": {
"outputs": { "type": "string" }
},
"results": ["Merged molecules"]
},

{
"job_collection": "fragmenstein",
"job_name": "fragmenstein-place-string",
"job_version": "1.0.0",
"inputs": {
"fragments": {
"type": "array",
"uniqueItems": true,
"format": "chemical/x-mdl-molfile",
"items": {
"from": "lhs",
"enum": "{inputs_dir}/{target}-{item}.mol",
"enumNames": "{item}"
}
},
"protein": {
"type": "string",
"format": "chemical/x-pdb",
"from": "lhs",
"enum": "{inputs_dir}/{target}-{item}_apo-desolv.pdb",
"enumNames": "{item}"
}
},
"options": {
"outfile": {
"default": "{job_dir}/merged.sdf",
"ui:widget": "hidden"
},
"count": {
"type": "integer",
"default": 5
},
"smilesFieldName": {
"type": "string",
"default": "original SMILES",
"ui:widget": "hidden"
},
"smiles": {
"items": {
"ui:widget": "textarea"
}
},
"fragIdField": {
"type": "string",
"default": "_Name",
"ui:widget": "hidden"
},
"proteinFieldName": {
"type": "string",
"default": "ref_pdb",
"ui:widget": "hidden"
},
"proteinFieldValue": {
"type": "string",
"value": "{protein_id}",
"ui:widget": "hidden"
}
},
"outputs": {
"outputs": { "type": "string" }
},
"results": ["Merged molecules"]
}
]
}

Loading

0 comments on commit 6807884

Please sign in to comment.