We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Expose transformation option to API
### Context

https://github.com/AlexsLemonade/refinebio-frontend/issues/208

### Problem or idea

We want a dropdown to change the transformation option, but the API currently doesn't support changing that value.

### Solution or next step

I think transformation just needs to be added to the DataSetSerializer

### New Issue Checklist

- [x] The title is short and descriptive.
- [x] You have explained the context that led you to write this issue.
- [x] You have reported a problem or idea.
- [x] You have proposed a solution or next step.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `api/data_refinery_api/serializers.py`
Content:
```
1 from rest_framework import serializers
2 from rest_framework_hstore.fields import HStoreField
3 from data_refinery_common.models import ProcessorJob, DownloaderJob, SurveyJob
4 from data_refinery_common.models import (
5     Experiment,
6     ExperimentAnnotation,
7     Sample,
8     SampleAnnotation,
9     Organism,
10     OrganismIndex,
11     OriginalFile,
12     Processor,
13     ComputationalResult,
14     ComputationalResultAnnotation,
15     ComputedFile,
16     Dataset,
17     APIToken
18 )
19 
20 ##
21 # Organism
22 ##
23 
24 class OrganismSerializer(serializers.ModelSerializer):
25     class Meta:
26         model = Organism
27         fields = (
28                     'name',
29                     'taxonomy_id',
30                 )
31 
32 
33 ##
34 # Processor
35 ##
36 
37 class ProcessorSerializer(serializers.ModelSerializer):
38     class Meta:
39         model = Processor
40         fields = (
41             'name',
42             'docker_image',
43             'environment'
44         )
45 
46 
47 ##
48 # Transcriptome Index
49 ##
50 
51 class OrganismIndexSerializer(serializers.ModelSerializer):
52     class Meta:
53         model = OrganismIndex
54         fields = (
55                     's3_url',
56                     'source_version',
57                     'salmon_version',
58                     'last_modified',
59                 )
60 
61 ##
62 # Results
63 ##
64 
65 class ComputationalResultAnnotationSerializer(serializers.ModelSerializer):
66     data = HStoreField()
67 
68     class Meta:
69         model = ComputationalResultAnnotation
70         fields = (
71                     'id',
72                     'data',
73                     'is_ccdl',
74                     'created_at',
75                     'last_modified'
76                 )
77 
78 class ComputedFileSerializer(serializers.ModelSerializer):
79     class Meta:
80         model = ComputedFile
81         fields = (
82                     'id',
83                     'filename',
84                     'size_in_bytes',
85                     'sha1',
86                     's3_bucket',
87                     's3_key',
88                     'created_at',
89                     'last_modified'
90                 )
91 
92 class ComputationalResultSerializer(serializers.ModelSerializer):
93     annotations = ComputationalResultAnnotationSerializer(many=True, source='computationalresultannotation_set')
94     files = ComputedFileSerializer(many=True, source='computedfile_set')
95 
96     class Meta:
97         model = ComputationalResult
98         fields = (
99                     'id',
100                     'commands',
101                     'processor',
102                     'is_ccdl',
103                     'annotations',
104                     'files',
105                     'time_start',
106                     'time_end',
107                     'created_at',
108                     'last_modified'
109                 )
110 
111 
112 ##
113 # Samples
114 ##
115 
116 class SampleSerializer(serializers.ModelSerializer):
117     organism = OrganismSerializer(many=False)
118 
119     class Meta:
120         model = Sample
121         fields = (
122                     'id',
123                     'title',
124                     'accession_code',
125                     'source_database',
126                     'organism',
127                     'platform_accession_code',
128                     'platform_name',
129                     'pretty_platform',
130                     'technology',
131                     'manufacturer',
132                     'is_downloaded',
133                     'is_processed',
134                     'created_at',
135                     'last_modified',
136                 )
137 
138 class SampleAnnotationSerializer(serializers.ModelSerializer):
139     data = HStoreField()
140 
141     class Meta:
142         model = SampleAnnotation
143         fields = (
144                     'data',
145                     'is_ccdl',
146                     'created_at',
147                     'last_modified',
148                 )
149 
150 class DetailedSampleSerializer(serializers.ModelSerializer):
151     annotations = SampleAnnotationSerializer(many=True, source='sampleannotation_set')
152     organism = OrganismSerializer(many=False)
153     results = ComputationalResultSerializer(many=True)
154 
155     class Meta:
156         model = Sample
157         fields = (
158                     'id',
159                     'title',
160                     'accession_code',
161                     'source_database',
162                     'organism',
163                     'platform_accession_code',
164                     'platform_name',
165                     'pretty_platform',
166                     'technology',
167                     'manufacturer',
168                     'annotations',
169                     'results',
170                     'pipelines',
171                     'source_archive_url',
172                     'has_raw',
173                     'sex',
174                     'age',
175                     'specimen_part',
176                     'genotype',
177                     'disease',
178                     'disease_stage',
179                     'cell_line',
180                     'treatment',
181                     'race',
182                     'subject',
183                     'compound',
184                     'time',
185                     'is_downloaded',
186                     'is_processed',
187                     'created_at',
188                     'last_modified',
189                 )
190 
191 ##
192 # Experiments
193 ##
194 
195 class ExperimentSerializer(serializers.ModelSerializer):
196     organisms = serializers.StringRelatedField(many=True)
197     platforms = serializers.ReadOnlyField()
198     samples = serializers.StringRelatedField(many=True)
199     pretty_platforms = serializers.ReadOnlyField()
200 
201     class Meta:
202         model = Experiment
203         fields = (
204                     'id',
205                     'title',
206                     'description',
207                     'accession_code',
208                     'source_database',
209                     'source_url',
210                     'platforms',
211                     'pretty_platforms',
212                     'has_publication',
213                     'publication_title',
214                     'publication_doi',
215                     'publication_authors',
216                     'pubmed_id',
217                     'samples',
218                     'organisms',
219                     'submitter_institution',
220                     'created_at',
221                     'last_modified'
222                 )
223 
224 class ExperimentAnnotationSerializer(serializers.ModelSerializer):
225     data = HStoreField()
226 
227     class Meta:
228         model = ExperimentAnnotation
229         fields = (
230                     'data',
231                     'is_ccdl',
232                     'created_at',
233                     'last_modified',
234                 )
235 
236 class DetailedExperimentSerializer(serializers.ModelSerializer):
237     annotations = ExperimentAnnotationSerializer(many=True, source='experimentannotation_set')
238     samples = SampleSerializer(many=True)
239     organisms = OrganismSerializer(many=True)
240 
241     class Meta:
242         model = Experiment
243         fields = (
244                     'id',
245                     'title',
246                     'description',
247                     'annotations',
248                     'samples',
249                     'protocol_description',
250                     'accession_code',
251                     'source_database',
252                     'source_url',
253                     'has_publication',
254                     'publication_title',
255                     'publication_doi',
256                     'publication_authors',
257                     'pubmed_id',
258                     'source_first_published',
259                     'source_last_modified',
260                     'submitter_institution',
261                     'last_modified',
262                     'created_at',
263                     'organisms',
264                 )
265 
266 class PlatformSerializer(serializers.ModelSerializer):
267 
268     class Meta:
269         model = Sample
270         fields = (
271                     'platform_accession_code',
272                     'platform_name',
273                 )
274 
275 class InstitutionSerializer(serializers.ModelSerializer):
276 
277     class Meta:
278         model = Experiment
279         fields = (
280                     'submitter_institution',
281                 )
282 
283 ##
284 # Files
285 ##
286 
287 class OriginalFileSerializer(serializers.ModelSerializer):
288 
289     class Meta:
290         model = OriginalFile
291         fields = (
292                     'id',
293                     'filename',
294                     'size_in_bytes',
295                     'sha1',
296                     'source_url',
297                     'source_filename',
298                     'is_downloaded',
299                     'is_archive',
300                     'has_raw',
301                     'is_downloaded',
302                     'created_at',
303                     'last_modified'
304                 )
305 
306 ##
307 # Jobs
308 ##
309 
310 class SurveyJobSerializer(serializers.ModelSerializer):
311 
312     class Meta:
313         model = SurveyJob
314         fields = (
315                     'id',
316                     'source_type',
317                     'success',
318                     'start_time',
319                     'end_time',
320                     'created_at',
321                     'last_modified'
322                 )
323 
324 class DownloaderJobSerializer(serializers.ModelSerializer):
325     original_files = OriginalFileSerializer(many=True)
326 
327     class Meta:
328         model = DownloaderJob
329         fields = (
330                     'id',
331                     'downloader_task',
332                     'num_retries',
333                     'retried',
334                     'worker_id',
335                     'worker_version',
336                     'failure_reason',
337                     'success',
338                     'original_files',
339                     'start_time',
340                     'end_time',
341                     'created_at',
342                     'last_modified'
343                 )
344 
345 class ProcessorJobSerializer(serializers.ModelSerializer):
346     original_files = OriginalFileSerializer(many=True)
347 
348     class Meta:
349         model = ProcessorJob
350         fields = (
351                     'id',
352                     'pipeline_applied',
353                     'num_retries',
354                     'retried',
355                     'worker_id',
356                     'worker_version',
357                     'failure_reason',
358                     'success',
359                     'original_files',
360                     'start_time',
361                     'end_time',
362                     'created_at',
363                     'last_modified'
364                 )
365 
366 ##
367 # Datasets
368 ##
369 
370 def validate_dataset(data):
371     """ Basic dataset validation. Currently only checks formatting, not values. """
372     if data['data'] != None:
373         if type(data['data']) != dict:
374             raise serializers.ValidationError("`data` must be a dict of lists.")
375 
376         for key, value in data['data'].items():
377             if type(value) != list:
378                 raise serializers.ValidationError("`data` must be a dict of lists. Problem with `" + str(key) + "`")
379 
380             try:
381                 if len(value) != len(set(value)):
382                     raise serializers.ValidationError("Duplicate values detected in " + str(value))
383             except Exception as e:
384                 raise serializers.ValidationError("Received bad dataset data: " + str(e))
385 
386     else:
387         raise serializers.ValidationError("`data` must be a dict of lists.")
388 
389 class CreateDatasetSerializer(serializers.ModelSerializer):
390 
391     class Meta:
392         model = Dataset
393         fields = (
394                     'id',
395                     'data',
396                     'email_address'
397             )
398 
399     def validate(self, data):
400         """
401         Ensure this is something we want in our dataset.
402         """
403         try:
404             validate_dataset(data)
405         except Exception:
406             raise
407         return data
408 
409 class DatasetSerializer(serializers.ModelSerializer):
410 
411     start = serializers.NullBooleanField(required=False)
412 
413     class Meta:
414         model = Dataset
415         fields = (
416                     'id',
417                     'data',
418                     'aggregate_by',
419                     'is_processing',
420                     'is_processed',
421                     'is_available',
422                     'email_address',
423                     'expires_on',
424                     's3_bucket',
425                     's3_key',
426                     'created_at',
427                     'last_modified',
428                     'start'
429             )
430         extra_kwargs = {
431                         'id': {
432                             'read_only': True,
433                         },
434                         'is_processing': {
435                             'read_only': True,
436                         },
437                         'is_processed': {
438                             'read_only': True,
439                         },
440                         'is_available': {
441                             'read_only': True,
442                         },
443                         'expires_on': {
444                             'read_only': True,
445                         },
446                         's3_bucket': {
447                             'read_only': True,
448                         },
449                         's3_key': {
450                             'read_only': True,
451                         },
452                         'created_at': {
453                             'read_only': True,
454                         },
455                         'last_modified': {
456                             'read_only': True,
457                         }
458                     }
459 
460     def validate(self, data):
461         """
462         Ensure this is something we want in our dataset.
463         """
464         try:
465             validate_dataset(data)
466         except Exception:
467             raise
468         return data
469 
470 class APITokenSerializer(serializers.ModelSerializer):
471 
472     class Meta:
473         model = APIToken
474         fields = (
475                 'id',
476                 'is_activated',
477                 'terms_and_conditions'
478             )
479         extra_kwargs = {
480                         'id': {
481                             'read_only': True
482                         },
483                         'is_activated': {
484                             'read_only': False
485                         },
486                         'terms_and_conditions': {
487                             'read_only': True
488                         }
489                     }
490
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/api/data_refinery_api/serializers.py b/api/data_refinery_api/serializers.py
--- a/api/data_refinery_api/serializers.py
+++ b/api/data_refinery_api/serializers.py
@@ -416,6 +416,7 @@
                     'id',
                     'data',
                     'aggregate_by',
+                    'scale_by',
                     'is_processing',
                     'is_processed',
                     'is_available',

{"golden_diff": "diff --git a/api/data_refinery_api/serializers.py b/api/data_refinery_api/serializers.py\n--- a/api/data_refinery_api/serializers.py\n+++ b/api/data_refinery_api/serializers.py\n@@ -416,6 +416,7 @@\n                     'id',\n                     'data',\n                     'aggregate_by',\n+                    'scale_by',\n                     'is_processing',\n                     'is_processed',\n                     'is_available',\n", "issue": "Expose transformation option to API\n### Context\r\n\r\nhttps://github.com/AlexsLemonade/refinebio-frontend/issues/208\r\n\r\n### Problem or idea\r\n\r\nWe want a dropdown to change the transformation option, but the API currently doesn't support changing that value.\r\n\r\n### Solution or next step\r\n\r\nI think transformation just needs to be added to the DataSetSerializer\r\n\r\n### New Issue Checklist\r\n\r\n- [x] The title is short and descriptive.\r\n- [x] You have explained the context that led you to write this issue.\r\n- [x] You have reported a problem or idea.\r\n- [x] You have proposed a solution or next step.\r\n\n", "before_files": [{"content": "from rest_framework import serializers\nfrom rest_framework_hstore.fields import HStoreField\nfrom data_refinery_common.models import ProcessorJob, DownloaderJob, SurveyJob\nfrom data_refinery_common.models import (\n    Experiment,\n    ExperimentAnnotation,\n    Sample,\n    SampleAnnotation,\n    Organism,\n    OrganismIndex,\n    OriginalFile,\n    Processor,\n    ComputationalResult,\n    ComputationalResultAnnotation,\n    ComputedFile,\n    Dataset,\n    APIToken\n)\n\n##\n# Organism\n##\n\nclass OrganismSerializer(serializers.ModelSerializer):\n    class Meta:\n        model = Organism\n        fields = (\n                    'name',\n                    'taxonomy_id',\n                )\n\n\n##\n# Processor\n##\n\nclass ProcessorSerializer(serializers.ModelSerializer):\n    class Meta:\n        model = Processor\n        fields = (\n            'name',\n            'docker_image',\n            'environment'\n        )\n\n\n##\n# Transcriptome Index\n##\n\nclass OrganismIndexSerializer(serializers.ModelSerializer):\n    class Meta:\n        model = OrganismIndex\n        fields = (\n                    's3_url',\n                    'source_version',\n                    'salmon_version',\n                    'last_modified',\n                )\n\n##\n# Results\n##\n\nclass ComputationalResultAnnotationSerializer(serializers.ModelSerializer):\n    data = HStoreField()\n\n    class Meta:\n        model = ComputationalResultAnnotation\n        fields = (\n                    'id',\n                    'data',\n                    'is_ccdl',\n                    'created_at',\n                    'last_modified'\n                )\n\nclass ComputedFileSerializer(serializers.ModelSerializer):\n    class Meta:\n        model = ComputedFile\n        fields = (\n                    'id',\n                    'filename',\n                    'size_in_bytes',\n                    'sha1',\n                    's3_bucket',\n                    's3_key',\n                    'created_at',\n                    'last_modified'\n                )\n\nclass ComputationalResultSerializer(serializers.ModelSerializer):\n    annotations = ComputationalResultAnnotationSerializer(many=True, source='computationalresultannotation_set')\n    files = ComputedFileSerializer(many=True, source='computedfile_set')\n\n    class Meta:\n        model = ComputationalResult\n        fields = (\n                    'id',\n                    'commands',\n                    'processor',\n                    'is_ccdl',\n                    'annotations',\n                    'files',\n                    'time_start',\n                    'time_end',\n                    'created_at',\n                    'last_modified'\n                )\n\n\n##\n# Samples\n##\n\nclass SampleSerializer(serializers.ModelSerializer):\n    organism = OrganismSerializer(many=False)\n\n    class Meta:\n        model = Sample\n        fields = (\n                    'id',\n                    'title',\n                    'accession_code',\n                    'source_database',\n                    'organism',\n                    'platform_accession_code',\n                    'platform_name',\n                    'pretty_platform',\n                    'technology',\n                    'manufacturer',\n                    'is_downloaded',\n                    'is_processed',\n                    'created_at',\n                    'last_modified',\n                )\n\nclass SampleAnnotationSerializer(serializers.ModelSerializer):\n    data = HStoreField()\n\n    class Meta:\n        model = SampleAnnotation\n        fields = (\n                    'data',\n                    'is_ccdl',\n                    'created_at',\n                    'last_modified',\n                )\n\nclass DetailedSampleSerializer(serializers.ModelSerializer):\n    annotations = SampleAnnotationSerializer(many=True, source='sampleannotation_set')\n    organism = OrganismSerializer(many=False)\n    results = ComputationalResultSerializer(many=True)\n\n    class Meta:\n        model = Sample\n        fields = (\n                    'id',\n                    'title',\n                    'accession_code',\n                    'source_database',\n                    'organism',\n                    'platform_accession_code',\n                    'platform_name',\n                    'pretty_platform',\n                    'technology',\n                    'manufacturer',\n                    'annotations',\n                    'results',\n                    'pipelines',\n                    'source_archive_url',\n                    'has_raw',\n                    'sex',\n                    'age',\n                    'specimen_part',\n                    'genotype',\n                    'disease',\n                    'disease_stage',\n                    'cell_line',\n                    'treatment',\n                    'race',\n                    'subject',\n                    'compound',\n                    'time',\n                    'is_downloaded',\n                    'is_processed',\n                    'created_at',\n                    'last_modified',\n                )\n\n##\n# Experiments\n##\n\nclass ExperimentSerializer(serializers.ModelSerializer):\n    organisms = serializers.StringRelatedField(many=True)\n    platforms = serializers.ReadOnlyField()\n    samples = serializers.StringRelatedField(many=True)\n    pretty_platforms = serializers.ReadOnlyField()\n\n    class Meta:\n        model = Experiment\n        fields = (\n                    'id',\n                    'title',\n                    'description',\n                    'accession_code',\n                    'source_database',\n                    'source_url',\n                    'platforms',\n                    'pretty_platforms',\n                    'has_publication',\n                    'publication_title',\n                    'publication_doi',\n                    'publication_authors',\n                    'pubmed_id',\n                    'samples',\n                    'organisms',\n                    'submitter_institution',\n                    'created_at',\n                    'last_modified'\n                )\n\nclass ExperimentAnnotationSerializer(serializers.ModelSerializer):\n    data = HStoreField()\n\n    class Meta:\n        model = ExperimentAnnotation\n        fields = (\n                    'data',\n                    'is_ccdl',\n                    'created_at',\n                    'last_modified',\n                )\n\nclass DetailedExperimentSerializer(serializers.ModelSerializer):\n    annotations = ExperimentAnnotationSerializer(many=True, source='experimentannotation_set')\n    samples = SampleSerializer(many=True)\n    organisms = OrganismSerializer(many=True)\n\n    class Meta:\n        model = Experiment\n        fields = (\n                    'id',\n                    'title',\n                    'description',\n                    'annotations',\n                    'samples',\n                    'protocol_description',\n                    'accession_code',\n                    'source_database',\n                    'source_url',\n                    'has_publication',\n                    'publication_title',\n                    'publication_doi',\n                    'publication_authors',\n                    'pubmed_id',\n                    'source_first_published',\n                    'source_last_modified',\n                    'submitter_institution',\n                    'last_modified',\n                    'created_at',\n                    'organisms',\n                )\n\nclass PlatformSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Sample\n        fields = (\n                    'platform_accession_code',\n                    'platform_name',\n                )\n\nclass InstitutionSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Experiment\n        fields = (\n                    'submitter_institution',\n                )\n\n##\n# Files\n##\n\nclass OriginalFileSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = OriginalFile\n        fields = (\n                    'id',\n                    'filename',\n                    'size_in_bytes',\n                    'sha1',\n                    'source_url',\n                    'source_filename',\n                    'is_downloaded',\n                    'is_archive',\n                    'has_raw',\n                    'is_downloaded',\n                    'created_at',\n                    'last_modified'\n                )\n\n##\n# Jobs\n##\n\nclass SurveyJobSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = SurveyJob\n        fields = (\n                    'id',\n                    'source_type',\n                    'success',\n                    'start_time',\n                    'end_time',\n                    'created_at',\n                    'last_modified'\n                )\n\nclass DownloaderJobSerializer(serializers.ModelSerializer):\n    original_files = OriginalFileSerializer(many=True)\n\n    class Meta:\n        model = DownloaderJob\n        fields = (\n                    'id',\n                    'downloader_task',\n                    'num_retries',\n                    'retried',\n                    'worker_id',\n                    'worker_version',\n                    'failure_reason',\n                    'success',\n                    'original_files',\n                    'start_time',\n                    'end_time',\n                    'created_at',\n                    'last_modified'\n                )\n\nclass ProcessorJobSerializer(serializers.ModelSerializer):\n    original_files = OriginalFileSerializer(many=True)\n\n    class Meta:\n        model = ProcessorJob\n        fields = (\n                    'id',\n                    'pipeline_applied',\n                    'num_retries',\n                    'retried',\n                    'worker_id',\n                    'worker_version',\n                    'failure_reason',\n                    'success',\n                    'original_files',\n                    'start_time',\n                    'end_time',\n                    'created_at',\n                    'last_modified'\n                )\n\n##\n# Datasets\n##\n\ndef validate_dataset(data):\n    \"\"\" Basic dataset validation. Currently only checks formatting, not values. \"\"\"\n    if data['data'] != None:\n        if type(data['data']) != dict:\n            raise serializers.ValidationError(\"`data` must be a dict of lists.\")\n\n        for key, value in data['data'].items():\n            if type(value) != list:\n                raise serializers.ValidationError(\"`data` must be a dict of lists. Problem with `\" + str(key) + \"`\")\n\n            try:\n                if len(value) != len(set(value)):\n                    raise serializers.ValidationError(\"Duplicate values detected in \" + str(value))\n            except Exception as e:\n                raise serializers.ValidationError(\"Received bad dataset data: \" + str(e))\n\n    else:\n        raise serializers.ValidationError(\"`data` must be a dict of lists.\")\n\nclass CreateDatasetSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Dataset\n        fields = (\n                    'id',\n                    'data',\n                    'email_address'\n            )\n\n    def validate(self, data):\n        \"\"\"\n        Ensure this is something we want in our dataset.\n        \"\"\"\n        try:\n            validate_dataset(data)\n        except Exception:\n            raise\n        return data\n\nclass DatasetSerializer(serializers.ModelSerializer):\n\n    start = serializers.NullBooleanField(required=False)\n\n    class Meta:\n        model = Dataset\n        fields = (\n                    'id',\n                    'data',\n                    'aggregate_by',\n                    'is_processing',\n                    'is_processed',\n                    'is_available',\n                    'email_address',\n                    'expires_on',\n                    's3_bucket',\n                    's3_key',\n                    'created_at',\n                    'last_modified',\n                    'start'\n            )\n        extra_kwargs = {\n                        'id': {\n                            'read_only': True,\n                        },\n                        'is_processing': {\n                            'read_only': True,\n                        },\n                        'is_processed': {\n                            'read_only': True,\n                        },\n                        'is_available': {\n                            'read_only': True,\n                        },\n                        'expires_on': {\n                            'read_only': True,\n                        },\n                        's3_bucket': {\n                            'read_only': True,\n                        },\n                        's3_key': {\n                            'read_only': True,\n                        },\n                        'created_at': {\n                            'read_only': True,\n                        },\n                        'last_modified': {\n                            'read_only': True,\n                        }\n                    }\n\n    def validate(self, data):\n        \"\"\"\n        Ensure this is something we want in our dataset.\n        \"\"\"\n        try:\n            validate_dataset(data)\n        except Exception:\n            raise\n        return data\n\nclass APITokenSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = APIToken\n        fields = (\n                'id',\n                'is_activated',\n                'terms_and_conditions'\n            )\n        extra_kwargs = {\n                        'id': {\n                            'read_only': True\n                        },\n                        'is_activated': {\n                            'read_only': False\n                        },\n                        'terms_and_conditions': {\n                            'read_only': True\n                        }\n                    }\n", "path": "api/data_refinery_api/serializers.py"}], "after_files": [{"content": "from rest_framework import serializers\nfrom rest_framework_hstore.fields import HStoreField\nfrom data_refinery_common.models import ProcessorJob, DownloaderJob, SurveyJob\nfrom data_refinery_common.models import (\n    Experiment,\n    ExperimentAnnotation,\n    Sample,\n    SampleAnnotation,\n    Organism,\n    OrganismIndex,\n    OriginalFile,\n    Processor,\n    ComputationalResult,\n    ComputationalResultAnnotation,\n    ComputedFile,\n    Dataset,\n    APIToken\n)\n\n##\n# Organism\n##\n\nclass OrganismSerializer(serializers.ModelSerializer):\n    class Meta:\n        model = Organism\n        fields = (\n                    'name',\n                    'taxonomy_id',\n                )\n\n\n##\n# Processor\n##\n\nclass ProcessorSerializer(serializers.ModelSerializer):\n    class Meta:\n        model = Processor\n        fields = (\n            'name',\n            'docker_image',\n            'environment'\n        )\n\n\n##\n# Transcriptome Index\n##\n\nclass OrganismIndexSerializer(serializers.ModelSerializer):\n    class Meta:\n        model = OrganismIndex\n        fields = (\n                    's3_url',\n                    'source_version',\n                    'salmon_version',\n                    'last_modified',\n                )\n\n##\n# Results\n##\n\nclass ComputationalResultAnnotationSerializer(serializers.ModelSerializer):\n    data = HStoreField()\n\n    class Meta:\n        model = ComputationalResultAnnotation\n        fields = (\n                    'id',\n                    'data',\n                    'is_ccdl',\n                    'created_at',\n                    'last_modified'\n                )\n\nclass ComputedFileSerializer(serializers.ModelSerializer):\n    class Meta:\n        model = ComputedFile\n        fields = (\n                    'id',\n                    'filename',\n                    'size_in_bytes',\n                    'sha1',\n                    's3_bucket',\n                    's3_key',\n                    'created_at',\n                    'last_modified'\n                )\n\nclass ComputationalResultSerializer(serializers.ModelSerializer):\n    annotations = ComputationalResultAnnotationSerializer(many=True, source='computationalresultannotation_set')\n    files = ComputedFileSerializer(many=True, source='computedfile_set')\n\n    class Meta:\n        model = ComputationalResult\n        fields = (\n                    'id',\n                    'commands',\n                    'processor',\n                    'is_ccdl',\n                    'annotations',\n                    'files',\n                    'time_start',\n                    'time_end',\n                    'created_at',\n                    'last_modified'\n                )\n\n\n##\n# Samples\n##\n\nclass SampleSerializer(serializers.ModelSerializer):\n    organism = OrganismSerializer(many=False)\n\n    class Meta:\n        model = Sample\n        fields = (\n                    'id',\n                    'title',\n                    'accession_code',\n                    'source_database',\n                    'organism',\n                    'platform_accession_code',\n                    'platform_name',\n                    'pretty_platform',\n                    'technology',\n                    'manufacturer',\n                    'is_downloaded',\n                    'is_processed',\n                    'created_at',\n                    'last_modified',\n                )\n\nclass SampleAnnotationSerializer(serializers.ModelSerializer):\n    data = HStoreField()\n\n    class Meta:\n        model = SampleAnnotation\n        fields = (\n                    'data',\n                    'is_ccdl',\n                    'created_at',\n                    'last_modified',\n                )\n\nclass DetailedSampleSerializer(serializers.ModelSerializer):\n    annotations = SampleAnnotationSerializer(many=True, source='sampleannotation_set')\n    organism = OrganismSerializer(many=False)\n    results = ComputationalResultSerializer(many=True)\n\n    class Meta:\n        model = Sample\n        fields = (\n                    'id',\n                    'title',\n                    'accession_code',\n                    'source_database',\n                    'organism',\n                    'platform_accession_code',\n                    'platform_name',\n                    'pretty_platform',\n                    'technology',\n                    'manufacturer',\n                    'annotations',\n                    'results',\n                    'pipelines',\n                    'source_archive_url',\n                    'has_raw',\n                    'sex',\n                    'age',\n                    'specimen_part',\n                    'genotype',\n                    'disease',\n                    'disease_stage',\n                    'cell_line',\n                    'treatment',\n                    'race',\n                    'subject',\n                    'compound',\n                    'time',\n                    'is_downloaded',\n                    'is_processed',\n                    'created_at',\n                    'last_modified',\n                )\n\n##\n# Experiments\n##\n\nclass ExperimentSerializer(serializers.ModelSerializer):\n    organisms = serializers.StringRelatedField(many=True)\n    platforms = serializers.ReadOnlyField()\n    samples = serializers.StringRelatedField(many=True)\n    pretty_platforms = serializers.ReadOnlyField()\n\n    class Meta:\n        model = Experiment\n        fields = (\n                    'id',\n                    'title',\n                    'description',\n                    'accession_code',\n                    'source_database',\n                    'source_url',\n                    'platforms',\n                    'pretty_platforms',\n                    'has_publication',\n                    'publication_title',\n                    'publication_doi',\n                    'publication_authors',\n                    'pubmed_id',\n                    'samples',\n                    'organisms',\n                    'submitter_institution',\n                    'created_at',\n                    'last_modified'\n                )\n\nclass ExperimentAnnotationSerializer(serializers.ModelSerializer):\n    data = HStoreField()\n\n    class Meta:\n        model = ExperimentAnnotation\n        fields = (\n                    'data',\n                    'is_ccdl',\n                    'created_at',\n                    'last_modified',\n                )\n\nclass DetailedExperimentSerializer(serializers.ModelSerializer):\n    annotations = ExperimentAnnotationSerializer(many=True, source='experimentannotation_set')\n    samples = SampleSerializer(many=True)\n    organisms = OrganismSerializer(many=True)\n\n    class Meta:\n        model = Experiment\n        fields = (\n                    'id',\n                    'title',\n                    'description',\n                    'annotations',\n                    'samples',\n                    'protocol_description',\n                    'accession_code',\n                    'source_database',\n                    'source_url',\n                    'has_publication',\n                    'publication_title',\n                    'publication_doi',\n                    'publication_authors',\n                    'pubmed_id',\n                    'source_first_published',\n                    'source_last_modified',\n                    'submitter_institution',\n                    'last_modified',\n                    'created_at',\n                    'organisms',\n                )\n\nclass PlatformSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Sample\n        fields = (\n                    'platform_accession_code',\n                    'platform_name',\n                )\n\nclass InstitutionSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Experiment\n        fields = (\n                    'submitter_institution',\n                )\n\n##\n# Files\n##\n\nclass OriginalFileSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = OriginalFile\n        fields = (\n                    'id',\n                    'filename',\n                    'size_in_bytes',\n                    'sha1',\n                    'source_url',\n                    'source_filename',\n                    'is_downloaded',\n                    'is_archive',\n                    'has_raw',\n                    'is_downloaded',\n                    'created_at',\n                    'last_modified'\n                )\n\n##\n# Jobs\n##\n\nclass SurveyJobSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = SurveyJob\n        fields = (\n                    'id',\n                    'source_type',\n                    'success',\n                    'start_time',\n                    'end_time',\n                    'created_at',\n                    'last_modified'\n                )\n\nclass DownloaderJobSerializer(serializers.ModelSerializer):\n    original_files = OriginalFileSerializer(many=True)\n\n    class Meta:\n        model = DownloaderJob\n        fields = (\n                    'id',\n                    'downloader_task',\n                    'num_retries',\n                    'retried',\n                    'worker_id',\n                    'worker_version',\n                    'failure_reason',\n                    'success',\n                    'original_files',\n                    'start_time',\n                    'end_time',\n                    'created_at',\n                    'last_modified'\n                )\n\nclass ProcessorJobSerializer(serializers.ModelSerializer):\n    original_files = OriginalFileSerializer(many=True)\n\n    class Meta:\n        model = ProcessorJob\n        fields = (\n                    'id',\n                    'pipeline_applied',\n                    'num_retries',\n                    'retried',\n                    'worker_id',\n                    'worker_version',\n                    'failure_reason',\n                    'success',\n                    'original_files',\n                    'start_time',\n                    'end_time',\n                    'created_at',\n                    'last_modified'\n                )\n\n##\n# Datasets\n##\n\ndef validate_dataset(data):\n    \"\"\" Basic dataset validation. Currently only checks formatting, not values. \"\"\"\n    if data['data'] != None:\n        if type(data['data']) != dict:\n            raise serializers.ValidationError(\"`data` must be a dict of lists.\")\n\n        for key, value in data['data'].items():\n            if type(value) != list:\n                raise serializers.ValidationError(\"`data` must be a dict of lists. Problem with `\" + str(key) + \"`\")\n\n            try:\n                if len(value) != len(set(value)):\n                    raise serializers.ValidationError(\"Duplicate values detected in \" + str(value))\n            except Exception as e:\n                raise serializers.ValidationError(\"Received bad dataset data: \" + str(e))\n\n    else:\n        raise serializers.ValidationError(\"`data` must be a dict of lists.\")\n\nclass CreateDatasetSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Dataset\n        fields = (\n                    'id',\n                    'data',\n                    'email_address'\n            )\n\n    def validate(self, data):\n        \"\"\"\n        Ensure this is something we want in our dataset.\n        \"\"\"\n        try:\n            validate_dataset(data)\n        except Exception:\n            raise\n        return data\n\nclass DatasetSerializer(serializers.ModelSerializer):\n\n    start = serializers.NullBooleanField(required=False)\n\n    class Meta:\n        model = Dataset\n        fields = (\n                    'id',\n                    'data',\n                    'aggregate_by',\n                    'scale_by',\n                    'is_processing',\n                    'is_processed',\n                    'is_available',\n                    'email_address',\n                    'expires_on',\n                    's3_bucket',\n                    's3_key',\n                    'created_at',\n                    'last_modified',\n                    'start'\n            )\n        extra_kwargs = {\n                        'id': {\n                            'read_only': True,\n                        },\n                        'is_processing': {\n                            'read_only': True,\n                        },\n                        'is_processed': {\n                            'read_only': True,\n                        },\n                        'is_available': {\n                            'read_only': True,\n                        },\n                        'expires_on': {\n                            'read_only': True,\n                        },\n                        's3_bucket': {\n                            'read_only': True,\n                        },\n                        's3_key': {\n                            'read_only': True,\n                        },\n                        'created_at': {\n                            'read_only': True,\n                        },\n                        'last_modified': {\n                            'read_only': True,\n                        }\n                    }\n\n    def validate(self, data):\n        \"\"\"\n        Ensure this is something we want in our dataset.\n        \"\"\"\n        try:\n            validate_dataset(data)\n        except Exception:\n            raise\n        return data\n\nclass APITokenSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = APIToken\n        fields = (\n                'id',\n                'is_activated',\n                'terms_and_conditions'\n            )\n        extra_kwargs = {\n                        'id': {\n                            'read_only': True\n                        },\n                        'is_activated': {\n                            'read_only': False\n                        },\n                        'terms_and_conditions': {\n                            'read_only': True\n                        }\n                    }\n", "path": "api/data_refinery_api/serializers.py"}]}