django-to-galaxy 0.7.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_to_galaxy/__init__.py +1 -0
- django_to_galaxy/admin/__init__.py +13 -0
- django_to_galaxy/admin/galaxy_element.py +6 -0
- django_to_galaxy/admin/galaxy_instance.py +26 -0
- django_to_galaxy/admin/galaxy_output_file.py +79 -0
- django_to_galaxy/admin/galaxy_user.py +183 -0
- django_to_galaxy/admin/history.py +91 -0
- django_to_galaxy/admin/invocation.py +154 -0
- django_to_galaxy/admin/tag.py +17 -0
- django_to_galaxy/admin/utils.py +116 -0
- django_to_galaxy/admin/workflow.py +131 -0
- django_to_galaxy/api/__init__.py +0 -0
- django_to_galaxy/api/serializers/asymetricslugrelatedfield.py +31 -0
- django_to_galaxy/api/serializers/create_dataset_collection.py +118 -0
- django_to_galaxy/api/serializers/create_history.py +6 -0
- django_to_galaxy/api/serializers/galaxy_instance.py +10 -0
- django_to_galaxy/api/serializers/galaxy_output_file.py +17 -0
- django_to_galaxy/api/serializers/galaxy_user.py +20 -0
- django_to_galaxy/api/serializers/history.py +17 -0
- django_to_galaxy/api/serializers/invocation.py +22 -0
- django_to_galaxy/api/serializers/invoke_workflow.py +24 -0
- django_to_galaxy/api/serializers/upload_to_history.py +25 -0
- django_to_galaxy/api/serializers/workflow.py +41 -0
- django_to_galaxy/api/urls.py +53 -0
- django_to_galaxy/api/views/create_dataset_collection.py +461 -0
- django_to_galaxy/api/views/create_history.py +23 -0
- django_to_galaxy/api/views/galaxy_instance.py +13 -0
- django_to_galaxy/api/views/galaxy_output_file.py +15 -0
- django_to_galaxy/api/views/galaxy_user.py +13 -0
- django_to_galaxy/api/views/history.py +14 -0
- django_to_galaxy/api/views/invocation.py +45 -0
- django_to_galaxy/api/views/invoke_workflow.py +181 -0
- django_to_galaxy/api/views/upload_to_history.py +78 -0
- django_to_galaxy/api/views/workflow.py +14 -0
- django_to_galaxy/apps.py +6 -0
- django_to_galaxy/migrations/0001_new_initial.py +171 -0
- django_to_galaxy/migrations/0002_rename_state_history_galaxy_state_and_more.py +37 -0
- django_to_galaxy/migrations/0003_invocation_create_time.py +20 -0
- django_to_galaxy/migrations/0004_alter_galaxyuser_email_galaxyoutputfile.py +46 -0
- django_to_galaxy/migrations/0005_alter_galaxyoutputfile_invocation_and_more.py +37 -0
- django_to_galaxy/migrations/0006_tag_history_tags_workflow_tags.py +42 -0
- django_to_galaxy/migrations/0007_format_alter_history_tags_alter_workflow_tags_and_more.py +63 -0
- django_to_galaxy/migrations/0008_workflowinput_label.py +21 -0
- django_to_galaxy/migrations/0009_galaxyoutputfile_unique_galaxy_id_per_invocation.py +20 -0
- django_to_galaxy/migrations/0010_workflow__is_meta_workflow__step_jobs_count.py +23 -0
- django_to_galaxy/migrations/0011_rename__step_jobs_count_workflow__step_count_and_more.py +23 -0
- django_to_galaxy/migrations/0012_workflowinput_collection_type_and_more.py +136 -0
- django_to_galaxy/migrations/__init__.py +0 -0
- django_to_galaxy/models/__init__.py +8 -0
- django_to_galaxy/models/accepted_input.py +139 -0
- django_to_galaxy/models/galaxy_element.py +52 -0
- django_to_galaxy/models/galaxy_instance.py +29 -0
- django_to_galaxy/models/galaxy_output_file.py +53 -0
- django_to_galaxy/models/galaxy_user.py +94 -0
- django_to_galaxy/models/history.py +73 -0
- django_to_galaxy/models/invocation.py +251 -0
- django_to_galaxy/models/workflow.py +440 -0
- django_to_galaxy/schemas/__init__.py +0 -0
- django_to_galaxy/schemas/dataset.py +16 -0
- django_to_galaxy/settings.py +8 -0
- django_to_galaxy/templates/admin/import_workflows.html +89 -0
- django_to_galaxy/urls.py +3 -0
- django_to_galaxy/utils.py +61 -0
- django_to_galaxy/version.py +3 -0
- django_to_galaxy-0.7.0.0.dist-info/METADATA +17 -0
- django_to_galaxy-0.7.0.0.dist-info/RECORD +68 -0
- django_to_galaxy-0.7.0.0.dist-info/WHEEL +4 -0
- django_to_galaxy-0.7.0.0.dist-info/licenses/LICENSE +661 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Generated by Django 4.1 on 2023-03-02 10:28
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
import django.db.models.deletion
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
("django_to_galaxy", "0006_tag_history_tags_workflow_tags"),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
operations = [
|
|
14
|
+
migrations.CreateModel(
|
|
15
|
+
name="Format",
|
|
16
|
+
fields=[
|
|
17
|
+
(
|
|
18
|
+
"id",
|
|
19
|
+
models.BigAutoField(
|
|
20
|
+
auto_created=True,
|
|
21
|
+
primary_key=True,
|
|
22
|
+
serialize=False,
|
|
23
|
+
verbose_name="ID",
|
|
24
|
+
),
|
|
25
|
+
),
|
|
26
|
+
("format", models.CharField(max_length=200, unique=True)),
|
|
27
|
+
],
|
|
28
|
+
),
|
|
29
|
+
migrations.AlterField(
|
|
30
|
+
model_name="history",
|
|
31
|
+
name="tags",
|
|
32
|
+
field=models.ManyToManyField(blank=True, to="django_to_galaxy.tag"),
|
|
33
|
+
),
|
|
34
|
+
migrations.AlterField(
|
|
35
|
+
model_name="workflow",
|
|
36
|
+
name="tags",
|
|
37
|
+
field=models.ManyToManyField(blank=True, to="django_to_galaxy.tag"),
|
|
38
|
+
),
|
|
39
|
+
migrations.CreateModel(
|
|
40
|
+
name="WorkflowInput",
|
|
41
|
+
fields=[
|
|
42
|
+
(
|
|
43
|
+
"id",
|
|
44
|
+
models.BigAutoField(
|
|
45
|
+
auto_created=True,
|
|
46
|
+
primary_key=True,
|
|
47
|
+
serialize=False,
|
|
48
|
+
verbose_name="ID",
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
("galaxy_step_id", models.IntegerField()),
|
|
52
|
+
("optional", models.BooleanField(default=False)),
|
|
53
|
+
("formats", models.ManyToManyField(to="django_to_galaxy.format")),
|
|
54
|
+
(
|
|
55
|
+
"workflow",
|
|
56
|
+
models.ForeignKey(
|
|
57
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
58
|
+
to="django_to_galaxy.workflow",
|
|
59
|
+
),
|
|
60
|
+
),
|
|
61
|
+
],
|
|
62
|
+
),
|
|
63
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Generated by Django 4.1 on 2023-03-08 17:21
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
(
|
|
10
|
+
"django_to_galaxy",
|
|
11
|
+
"0007_format_alter_history_tags_alter_workflow_tags_and_more",
|
|
12
|
+
),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
migrations.AddField(
|
|
17
|
+
model_name="workflowinput",
|
|
18
|
+
name="label",
|
|
19
|
+
field=models.CharField(blank=True, max_length=100),
|
|
20
|
+
),
|
|
21
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Generated by Django 4.1 on 2023-10-27 11:17
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
("django_to_galaxy", "0008_workflowinput_label"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AddConstraint(
|
|
14
|
+
model_name="galaxyoutputfile",
|
|
15
|
+
constraint=models.UniqueConstraint(
|
|
16
|
+
fields=("galaxy_id", "invocation"),
|
|
17
|
+
name="unique_galaxy_id_per_invocation",
|
|
18
|
+
),
|
|
19
|
+
),
|
|
20
|
+
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Generated by Django 4.1 on 2025-02-12 13:28
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
("django_to_galaxy", "0009_galaxyoutputfile_unique_galaxy_id_per_invocation"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AddField(
|
|
14
|
+
model_name="workflow",
|
|
15
|
+
name="_is_meta",
|
|
16
|
+
field=models.BooleanField(default=None, null=True),
|
|
17
|
+
),
|
|
18
|
+
migrations.AddField(
|
|
19
|
+
model_name="workflow",
|
|
20
|
+
name="_step_jobs_count",
|
|
21
|
+
field=models.PositiveIntegerField(default=0),
|
|
22
|
+
),
|
|
23
|
+
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Generated by Django 5.2.3 on 2025-07-18 14:07
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
("django_to_galaxy", "0010_workflow__is_meta_workflow__step_jobs_count"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.RenameField(
|
|
14
|
+
model_name="workflow",
|
|
15
|
+
old_name="_step_jobs_count",
|
|
16
|
+
new_name="_step_count",
|
|
17
|
+
),
|
|
18
|
+
migrations.AlterField(
|
|
19
|
+
model_name="workflow",
|
|
20
|
+
name="_is_meta",
|
|
21
|
+
field=models.BooleanField(blank=True, default=None, null=True),
|
|
22
|
+
),
|
|
23
|
+
]
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Generated by Django 5.2.3 on 2025-09-09 13:15
|
|
2
|
+
|
|
3
|
+
import django.db.models.deletion
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
(
|
|
11
|
+
"django_to_galaxy",
|
|
12
|
+
"0011_rename__step_jobs_count_workflow__step_count_and_more",
|
|
13
|
+
),
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
operations = [
|
|
17
|
+
migrations.AddField(
|
|
18
|
+
model_name="workflowinput",
|
|
19
|
+
name="collection_type",
|
|
20
|
+
field=models.CharField(
|
|
21
|
+
blank=True,
|
|
22
|
+
choices=[
|
|
23
|
+
("record", "Record"),
|
|
24
|
+
("paired", "Dataset Pair"),
|
|
25
|
+
("list", "List of Datasets"),
|
|
26
|
+
("list:record", "List of Records"),
|
|
27
|
+
("list:paired", "List of Dataset Pairs"),
|
|
28
|
+
(
|
|
29
|
+
"list:paired_or_unpaired",
|
|
30
|
+
"Mixed List of Paired and Unpaired Datasets",
|
|
31
|
+
),
|
|
32
|
+
],
|
|
33
|
+
default=None,
|
|
34
|
+
max_length=25,
|
|
35
|
+
null=True,
|
|
36
|
+
),
|
|
37
|
+
),
|
|
38
|
+
migrations.AddField(
|
|
39
|
+
model_name="workflowinput",
|
|
40
|
+
name="default_value",
|
|
41
|
+
field=models.CharField(blank=True, max_length=255, null=True),
|
|
42
|
+
),
|
|
43
|
+
migrations.AddField(
|
|
44
|
+
model_name="workflowinput",
|
|
45
|
+
name="input_type",
|
|
46
|
+
field=models.CharField(
|
|
47
|
+
choices=[
|
|
48
|
+
("data_input", "data_input"),
|
|
49
|
+
("data_collection_input", "data_collection_input"),
|
|
50
|
+
("parameter_input", "parameter_input"),
|
|
51
|
+
],
|
|
52
|
+
default="data_input",
|
|
53
|
+
max_length=25,
|
|
54
|
+
),
|
|
55
|
+
),
|
|
56
|
+
migrations.AddField(
|
|
57
|
+
model_name="workflowinput",
|
|
58
|
+
name="multiple",
|
|
59
|
+
field=models.BooleanField(default=False),
|
|
60
|
+
),
|
|
61
|
+
migrations.AddField(
|
|
62
|
+
model_name="workflowinput",
|
|
63
|
+
name="parameter_type",
|
|
64
|
+
field=models.CharField(
|
|
65
|
+
blank=True,
|
|
66
|
+
choices=[
|
|
67
|
+
("text", "text"),
|
|
68
|
+
("integer", "integer"),
|
|
69
|
+
("float", "float"),
|
|
70
|
+
("boolean", "boolean"),
|
|
71
|
+
("color", "color"),
|
|
72
|
+
("directory_uri", "directory_uri"),
|
|
73
|
+
],
|
|
74
|
+
default=None,
|
|
75
|
+
max_length=15,
|
|
76
|
+
null=True,
|
|
77
|
+
),
|
|
78
|
+
),
|
|
79
|
+
migrations.CreateModel(
|
|
80
|
+
name="WorkflowInputTextOption",
|
|
81
|
+
fields=[
|
|
82
|
+
(
|
|
83
|
+
"id",
|
|
84
|
+
models.BigAutoField(
|
|
85
|
+
auto_created=True,
|
|
86
|
+
primary_key=True,
|
|
87
|
+
serialize=False,
|
|
88
|
+
verbose_name="ID",
|
|
89
|
+
),
|
|
90
|
+
),
|
|
91
|
+
("text_option", models.CharField(max_length=255)),
|
|
92
|
+
(
|
|
93
|
+
"workflow_input",
|
|
94
|
+
models.ForeignKey(
|
|
95
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
96
|
+
to="django_to_galaxy.workflowinput",
|
|
97
|
+
),
|
|
98
|
+
),
|
|
99
|
+
],
|
|
100
|
+
),
|
|
101
|
+
migrations.AddField(
|
|
102
|
+
model_name="workflowinput",
|
|
103
|
+
name="restrict_text_values",
|
|
104
|
+
field=models.ManyToManyField(to="django_to_galaxy.workflowinputtextoption"),
|
|
105
|
+
),
|
|
106
|
+
migrations.AddConstraint(
|
|
107
|
+
model_name="workflowinput",
|
|
108
|
+
constraint=models.CheckConstraint(
|
|
109
|
+
condition=models.Q(
|
|
110
|
+
models.Q(
|
|
111
|
+
("input_type", "parameter_input"),
|
|
112
|
+
("parameter_type__isnull", False),
|
|
113
|
+
("collection_type__isnull", True),
|
|
114
|
+
),
|
|
115
|
+
models.Q(
|
|
116
|
+
("input_type", "data_input"),
|
|
117
|
+
("parameter_type__isnull", True),
|
|
118
|
+
("collection_type__isnull", True),
|
|
119
|
+
),
|
|
120
|
+
models.Q(
|
|
121
|
+
("input_type", "data_collection_input"),
|
|
122
|
+
("parameter_type__isnull", True),
|
|
123
|
+
("collection_type__isnull", False),
|
|
124
|
+
),
|
|
125
|
+
_connector="OR",
|
|
126
|
+
),
|
|
127
|
+
name="workflowinputs_types_congruant",
|
|
128
|
+
),
|
|
129
|
+
),
|
|
130
|
+
migrations.AddConstraint(
|
|
131
|
+
model_name="workflowinputtextoption",
|
|
132
|
+
constraint=models.UniqueConstraint(
|
|
133
|
+
fields=("workflow_input", "text_option"), name="unique_input_option"
|
|
134
|
+
),
|
|
135
|
+
),
|
|
136
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from .galaxy_instance import GalaxyInstance # noqa
|
|
2
|
+
from .galaxy_user import GalaxyUser # noqa
|
|
3
|
+
from .galaxy_output_file import GalaxyOutputFile # noqa
|
|
4
|
+
from .history import History # noqa
|
|
5
|
+
from .invocation import Invocation # noqa
|
|
6
|
+
from .workflow import Workflow # noqa
|
|
7
|
+
from .galaxy_element import Tag # noqa
|
|
8
|
+
from .accepted_input import WorkflowInput, Format, WorkflowInputTextOption # noqa
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
from django.db import models
|
|
2
|
+
from django.db.models import Q
|
|
3
|
+
|
|
4
|
+
DATA = "data_input"
|
|
5
|
+
COLLECTION = "data_collection_input"
|
|
6
|
+
PARAMETER = "parameter_input"
|
|
7
|
+
INPUT_TYPE_CHOICES = [
|
|
8
|
+
(DATA, "data_input"),
|
|
9
|
+
(COLLECTION, "data_collection_input"),
|
|
10
|
+
(PARAMETER, "parameter_input"),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
P_TEXT = "text"
|
|
14
|
+
P_INTEGER = "integer"
|
|
15
|
+
P_FLOAT = "float"
|
|
16
|
+
P_BOOLEAN = "boolean"
|
|
17
|
+
P_COLOR = "color"
|
|
18
|
+
P_DIRECTORY_URI = "directory_uri"
|
|
19
|
+
PARAMETER_TYPE_CHOICES = [
|
|
20
|
+
(P_TEXT, "text"),
|
|
21
|
+
(P_INTEGER, "integer"),
|
|
22
|
+
(P_FLOAT, "float"),
|
|
23
|
+
(P_BOOLEAN, "boolean"),
|
|
24
|
+
(P_COLOR, "color"),
|
|
25
|
+
(P_DIRECTORY_URI, "directory_uri"),
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
C_RECORD = "record"
|
|
29
|
+
C_PAIRED = "paired"
|
|
30
|
+
C_LIST = "list"
|
|
31
|
+
C_LIST_RECORD = "list:record"
|
|
32
|
+
C_LIST_PAIRED = "list:paired"
|
|
33
|
+
C_LIST_PAIRED_UNPAIRED = "list:paired_or_unpaired"
|
|
34
|
+
COLLECTION_TYPE_CHOICES = [
|
|
35
|
+
(C_RECORD, "Record"),
|
|
36
|
+
(C_PAIRED, "Dataset Pair"),
|
|
37
|
+
(C_LIST, "List of Datasets"),
|
|
38
|
+
(C_LIST_RECORD, "List of Records"),
|
|
39
|
+
(C_LIST_PAIRED, "List of Dataset Pairs"),
|
|
40
|
+
(C_LIST_PAIRED_UNPAIRED, "Mixed List of Paired and Unpaired Datasets"),
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class Format(models.Model):
|
|
45
|
+
"""Format on the galaxy side."""
|
|
46
|
+
|
|
47
|
+
format = models.CharField(max_length=200, unique=True)
|
|
48
|
+
|
|
49
|
+
def __str__(self):
|
|
50
|
+
return f"{self.format}"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class WorkflowInputTextOption(models.Model):
|
|
54
|
+
"""Text option for a workflow input on Galaxy side."""
|
|
55
|
+
|
|
56
|
+
workflow_input = models.ForeignKey(
|
|
57
|
+
"WorkflowInput", null=False, on_delete=models.CASCADE
|
|
58
|
+
)
|
|
59
|
+
text_option = models.CharField(max_length=255)
|
|
60
|
+
|
|
61
|
+
class Meta:
|
|
62
|
+
constraints = [
|
|
63
|
+
models.UniqueConstraint(
|
|
64
|
+
fields=["workflow_input", "text_option"], name="unique_input_option"
|
|
65
|
+
)
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
def __str__(self):
|
|
69
|
+
return f"{self.text_option}"
|
|
70
|
+
|
|
71
|
+
def __repr__(self):
|
|
72
|
+
return f"Input: {self!s}"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class WorkflowInput(models.Model):
|
|
76
|
+
"""Accepted input for a workflow on Galaxy side."""
|
|
77
|
+
|
|
78
|
+
galaxy_step_id = models.IntegerField(null=False)
|
|
79
|
+
"""Step id on the galaxy side."""
|
|
80
|
+
label = models.CharField(max_length=100, blank=True)
|
|
81
|
+
"""Label on the galaxy side."""
|
|
82
|
+
workflow = models.ForeignKey("Workflow", null=False, on_delete=models.CASCADE)
|
|
83
|
+
"""Workflow id."""
|
|
84
|
+
input_type = models.CharField(
|
|
85
|
+
max_length=25, choices=INPUT_TYPE_CHOICES, default=DATA
|
|
86
|
+
)
|
|
87
|
+
"""Type of input on the galaxy side."""
|
|
88
|
+
formats = models.ManyToManyField("Format")
|
|
89
|
+
"""Accepted input formats on the galaxy side."""
|
|
90
|
+
parameter_type = models.CharField(
|
|
91
|
+
max_length=15,
|
|
92
|
+
choices=PARAMETER_TYPE_CHOICES,
|
|
93
|
+
default=None,
|
|
94
|
+
null=True,
|
|
95
|
+
blank=True,
|
|
96
|
+
)
|
|
97
|
+
"""Type of input if it is a parameter input."""
|
|
98
|
+
collection_type = models.CharField(
|
|
99
|
+
max_length=25,
|
|
100
|
+
choices=COLLECTION_TYPE_CHOICES,
|
|
101
|
+
default=None,
|
|
102
|
+
null=True,
|
|
103
|
+
blank=True,
|
|
104
|
+
)
|
|
105
|
+
"""Type of input if it is a parameter input."""
|
|
106
|
+
optional = models.BooleanField(default=False)
|
|
107
|
+
"""Workflow input optional information on the galaxy side."""
|
|
108
|
+
default_value = models.CharField(max_length=255, null=True, blank=True)
|
|
109
|
+
"""Default value of the input (either text, integer, float, boolean)"""
|
|
110
|
+
multiple = models.BooleanField(default=False)
|
|
111
|
+
"""If the input can get multiple values on the galaxy side."""
|
|
112
|
+
|
|
113
|
+
class Meta:
|
|
114
|
+
constraints = [
|
|
115
|
+
models.CheckConstraint(
|
|
116
|
+
check=Q(
|
|
117
|
+
Q(input_type=PARAMETER)
|
|
118
|
+
& Q(parameter_type__isnull=False)
|
|
119
|
+
& Q(collection_type__isnull=True)
|
|
120
|
+
)
|
|
121
|
+
| Q(
|
|
122
|
+
Q(input_type=DATA)
|
|
123
|
+
& Q(parameter_type__isnull=True)
|
|
124
|
+
& Q(collection_type__isnull=True)
|
|
125
|
+
)
|
|
126
|
+
| Q(
|
|
127
|
+
Q(input_type=COLLECTION)
|
|
128
|
+
& Q(parameter_type__isnull=True)
|
|
129
|
+
& Q(collection_type__isnull=False)
|
|
130
|
+
),
|
|
131
|
+
name="workflowinputs_types_congruant",
|
|
132
|
+
)
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
def __str__(self):
|
|
136
|
+
return f"{self.label}"
|
|
137
|
+
|
|
138
|
+
def __repr__(self):
|
|
139
|
+
return f"Input: {self!s}"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
|
|
3
|
+
from django.db import models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Tag(models.Model):
|
|
7
|
+
label = models.CharField(null=False, max_length=200, unique=True)
|
|
8
|
+
|
|
9
|
+
def __str__(self):
|
|
10
|
+
return f"{self.label}"
|
|
11
|
+
|
|
12
|
+
def __repr__(self):
|
|
13
|
+
return f"Tag: {self!s}"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class GalaxyElement(models.Model):
|
|
17
|
+
"""Base class for all Galaxy elements with galaxy id that are likely to evolve or change."""
|
|
18
|
+
|
|
19
|
+
galaxy_id = models.CharField(null=False, max_length=50)
|
|
20
|
+
"""Invocation id used on the galaxy side."""
|
|
21
|
+
name = models.CharField(null=False, max_length=200)
|
|
22
|
+
"""Name used on the galaxy side."""
|
|
23
|
+
annotation = models.CharField(max_length=200)
|
|
24
|
+
"""Annotation on the galaxy side."""
|
|
25
|
+
tags = models.ManyToManyField("Tag", blank=True)
|
|
26
|
+
"""tags on the galaxy side."""
|
|
27
|
+
published = models.BooleanField(null=False)
|
|
28
|
+
"""Whether it is published or not on the galaxy side."""
|
|
29
|
+
galaxy_owner = models.ForeignKey("GalaxyUser", null=False, on_delete=models.CASCADE)
|
|
30
|
+
"""Galaxy user that owns this element."""
|
|
31
|
+
|
|
32
|
+
@abstractmethod
|
|
33
|
+
def synchronize(self):
|
|
34
|
+
"""
|
|
35
|
+
@TODO
|
|
36
|
+
method to synchronize entry in django from galaxy based on galaxy_id.
|
|
37
|
+
"""
|
|
38
|
+
raise NotImplementedError
|
|
39
|
+
|
|
40
|
+
@abstractmethod
|
|
41
|
+
def is_valid(self):
|
|
42
|
+
"""
|
|
43
|
+
@TODO
|
|
44
|
+
method to check if galaxy_id is still pointing to a valid element.
|
|
45
|
+
"""
|
|
46
|
+
raise NotImplementedError
|
|
47
|
+
|
|
48
|
+
def __str__(self):
|
|
49
|
+
return f"{self.name} ({self.galaxy_id})"
|
|
50
|
+
|
|
51
|
+
class Meta:
|
|
52
|
+
abstract = True
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
from django.db import models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class GalaxyInstance(models.Model):
|
|
7
|
+
"""Table for Galaxy instances."""
|
|
8
|
+
|
|
9
|
+
url = models.URLField(max_length=100)
|
|
10
|
+
"""url of the Galaxy instance."""
|
|
11
|
+
name = models.CharField(max_length=100, unique=True)
|
|
12
|
+
"""Name of the Galaxy Instance."""
|
|
13
|
+
|
|
14
|
+
def __str__(self):
|
|
15
|
+
return f"{self.name} [{self.url}]"
|
|
16
|
+
|
|
17
|
+
def is_online(self) -> bool:
|
|
18
|
+
"""
|
|
19
|
+
Check the status of the instance.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
Whether the instance is available or not.
|
|
23
|
+
"""
|
|
24
|
+
try:
|
|
25
|
+
response = requests.head(self.url, timeout=30)
|
|
26
|
+
response.raise_for_status()
|
|
27
|
+
return True
|
|
28
|
+
except Exception:
|
|
29
|
+
return False
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from bioblend.galaxy.objects import wrappers
|
|
2
|
+
from django.db import models
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class GalaxyOutputFile(models.Model):
|
|
6
|
+
"""Handle output files."""
|
|
7
|
+
|
|
8
|
+
galaxy_id = models.CharField(null=False, max_length=50)
|
|
9
|
+
"""Dataset id used on the galaxy side."""
|
|
10
|
+
workflow_name = models.CharField(null=False, max_length=200)
|
|
11
|
+
"""Name used in the workflow on the galaxy side."""
|
|
12
|
+
galaxy_state = models.CharField(max_length=100, null=True)
|
|
13
|
+
"""State on the galaxy side."""
|
|
14
|
+
history_name = models.CharField(null=True, max_length=200)
|
|
15
|
+
"""Name used in the history on the galaxy side."""
|
|
16
|
+
src = models.CharField(null=False, max_length=50)
|
|
17
|
+
"""Src type on the galaxy side."""
|
|
18
|
+
invocation = models.ForeignKey(
|
|
19
|
+
"Invocation", null=False, on_delete=models.CASCADE, related_name="output_files"
|
|
20
|
+
)
|
|
21
|
+
"""Invocation that generated the output."""
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def galaxy_dataset(self) -> wrappers.Invocation:
|
|
25
|
+
"""Galaxy object using bioblend."""
|
|
26
|
+
if getattr(self, "_galaxy_dataset", None) is None:
|
|
27
|
+
self._galaxy_dataset = self._get_galaxy_dataset()
|
|
28
|
+
return self._galaxy_dataset
|
|
29
|
+
|
|
30
|
+
def _get_galaxy_dataset(self) -> wrappers.Invocation:
|
|
31
|
+
"""Get galaxy object using bioblend."""
|
|
32
|
+
return self.invocation.history.galaxy_history.get_dataset(self.galaxy_id)
|
|
33
|
+
|
|
34
|
+
def synchronize(self):
|
|
35
|
+
"""Synchronize state from Galaxy instance."""
|
|
36
|
+
dataset = self._get_galaxy_dataset()
|
|
37
|
+
self.galaxy_state = dataset.state
|
|
38
|
+
self.history_name = dataset.name
|
|
39
|
+
self.save()
|
|
40
|
+
|
|
41
|
+
def __str__(self):
|
|
42
|
+
return f"{self.history_name} (from {self.invocation.galaxy_id})"
|
|
43
|
+
|
|
44
|
+
class Meta:
|
|
45
|
+
constraints = [
|
|
46
|
+
models.UniqueConstraint(
|
|
47
|
+
fields=(
|
|
48
|
+
"galaxy_id",
|
|
49
|
+
"invocation",
|
|
50
|
+
),
|
|
51
|
+
name="unique_galaxy_id_per_invocation",
|
|
52
|
+
)
|
|
53
|
+
]
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from bioblend.galaxy.objects import GalaxyInstance as BioblendGalaxyInstance
|
|
5
|
+
from django.db import models
|
|
6
|
+
|
|
7
|
+
from django_to_galaxy.apps import DjangoToGalaxyConfig
|
|
8
|
+
from django_to_galaxy.utils import load_galaxy_history_time_to_datetime
|
|
9
|
+
from .history import History
|
|
10
|
+
from .workflow import Workflow
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class GalaxyUser(models.Model):
|
|
14
|
+
"""Table for Galaxy users."""
|
|
15
|
+
|
|
16
|
+
email = models.EmailField(null=False)
|
|
17
|
+
"""Email used for the Galaxy account."""
|
|
18
|
+
api_key = models.CharField(null=False, max_length=50)
|
|
19
|
+
"""API key of the user."""
|
|
20
|
+
galaxy_instance = models.ForeignKey(
|
|
21
|
+
"GalaxyInstance", null=False, on_delete=models.CASCADE, related_name="users"
|
|
22
|
+
)
|
|
23
|
+
"""Galaxy instance the user comes from."""
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def obj_gi(self):
|
|
27
|
+
"""Bioblend object to interact with Galaxy instance."""
|
|
28
|
+
if getattr(self, "_obj_gi", None) is None:
|
|
29
|
+
self._obj_gi = self.get_bioblend_obj_gi()
|
|
30
|
+
return self._obj_gi
|
|
31
|
+
|
|
32
|
+
@obj_gi.setter
|
|
33
|
+
def obj_gi(self, val):
|
|
34
|
+
self._obj_gi = val
|
|
35
|
+
|
|
36
|
+
def get_bioblend_obj_gi(self):
|
|
37
|
+
"""Retrieve bioblend object to interact with Galaxy instance."""
|
|
38
|
+
return BioblendGalaxyInstance(self.galaxy_instance.url, self.api_key)
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def available_workflows(self) -> List[Workflow]:
|
|
42
|
+
"""Available workflows for the user."""
|
|
43
|
+
if getattr(self, "_available_workflows", None) is None:
|
|
44
|
+
self._available_workflows = self.get_available_workflows()
|
|
45
|
+
return self._available_workflows
|
|
46
|
+
|
|
47
|
+
def get_available_workflows(self) -> List[Workflow]:
|
|
48
|
+
"""List all available workflows for the user."""
|
|
49
|
+
bioblend_wfs = self.obj_gi.workflows.list()
|
|
50
|
+
wfs_tag = []
|
|
51
|
+
for wf in bioblend_wfs:
|
|
52
|
+
wfs_tag.append(
|
|
53
|
+
(
|
|
54
|
+
Workflow(
|
|
55
|
+
galaxy_owner=self,
|
|
56
|
+
galaxy_id=wf.id,
|
|
57
|
+
name=wf.name,
|
|
58
|
+
published=wf.published,
|
|
59
|
+
annotation=wf.wrapped["annotation"],
|
|
60
|
+
),
|
|
61
|
+
wf.wrapped["tags"],
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
return wfs_tag
|
|
65
|
+
|
|
66
|
+
def _generate_history_name(self) -> str:
|
|
67
|
+
"""
|
|
68
|
+
Generate history name using current date.
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
Generated history name.
|
|
72
|
+
"""
|
|
73
|
+
current_time = datetime.now()
|
|
74
|
+
str_date = current_time.strftime("%Y%m%d-%f")
|
|
75
|
+
suffix = f"created_by_{DjangoToGalaxyConfig.name}"
|
|
76
|
+
return f"{str_date}_{suffix}"
|
|
77
|
+
|
|
78
|
+
def create_history(self, name=None):
|
|
79
|
+
"""Create history on the Galaxy instance."""
|
|
80
|
+
name = self._generate_history_name() if name is None else name
|
|
81
|
+
galaxy_history = self.obj_gi.histories.create(name=name)
|
|
82
|
+
local_history = History(
|
|
83
|
+
galaxy_id=galaxy_history.id,
|
|
84
|
+
name=galaxy_history.name,
|
|
85
|
+
published=galaxy_history.published,
|
|
86
|
+
galaxy_state=galaxy_history.state,
|
|
87
|
+
create_time=load_galaxy_history_time_to_datetime(galaxy_history),
|
|
88
|
+
galaxy_owner=self,
|
|
89
|
+
)
|
|
90
|
+
local_history.save()
|
|
91
|
+
return local_history
|
|
92
|
+
|
|
93
|
+
def __str__(self):
|
|
94
|
+
return f"{self.email} at {self.galaxy_instance}"
|