From 548dc82c102feb4e8f9be9883d1ce70d1527c2c5 Mon Sep 17 00:00:00 2001 From: Arkadii Yakovets Date: Thu, 12 Oct 2023 15:14:30 -0700 Subject: [PATCH] Rename Sample::genotype to Sample::genetic_information --- api/data_refinery_api/views/sample.py | 6 ++-- ...ame_genotype_sample_genetic_information.py | 18 ++++++++++ .../data_refinery_common/models/experiment.py | 2 +- common/data_refinery_common/models/sample.py | 4 +-- common/tests/models/test_sample.py | 36 +++++++++++++++++++ .../data_refinery_foreman/surveyor/harmony.py | 8 ++--- scripts/make_migrations.sh | 1 + 7 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 common/data_refinery_common/migrations/0073_rename_genotype_sample_genetic_information.py create mode 100644 common/tests/models/test_sample.py diff --git a/api/data_refinery_api/views/sample.py b/api/data_refinery_api/views/sample.py index d8333d292..124c28124 100644 --- a/api/data_refinery_api/views/sample.py +++ b/api/data_refinery_api/views/sample.py @@ -87,7 +87,7 @@ class Meta: "sex", "age", "specimen_part", - "genotype", + "genetic_information", "disease", "disease_stage", "cell_line", @@ -158,7 +158,7 @@ class SampleListView(generics.ListAPIView): "sex", "age", "specimen_part", - "genotype", + "genetic_information", "disease", "disease_stage", "cell_line", @@ -217,7 +217,7 @@ def get_queryset(self): | Q(sex__icontains=filter_by) | Q(age__icontains=filter_by) | Q(specimen_part__icontains=filter_by) - | Q(genotype__icontains=filter_by) + | Q(genetic_information__icontains=filter_by) | Q(disease__icontains=filter_by) | Q(disease_stage__icontains=filter_by) | Q(cell_line__icontains=filter_by) diff --git a/common/data_refinery_common/migrations/0073_rename_genotype_sample_genetic_information.py b/common/data_refinery_common/migrations/0073_rename_genotype_sample_genetic_information.py new file mode 100644 index 000000000..474aaa5bc --- /dev/null +++ b/common/data_refinery_common/migrations/0073_rename_genotype_sample_genetic_information.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.18 on 2023-10-12 16:07 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("data_refinery_common", "0072_auto_20220927_2235"), + ] + + operations = [ + migrations.RenameField( + model_name="sample", + old_name="genotype", + new_name="genetic_information", + ), + ] diff --git a/common/data_refinery_common/models/experiment.py b/common/data_refinery_common/models/experiment.py index aa63debea..21faec292 100644 --- a/common/data_refinery_common/models/experiment.py +++ b/common/data_refinery_common/models/experiment.py @@ -148,7 +148,7 @@ def get_sample_metadata_fields(self): "sex", "age", "specimen_part", - "genotype", + "genetic_information", "disease", "disease_stage", "cell_line", diff --git a/common/data_refinery_common/models/sample.py b/common/data_refinery_common/models/sample.py index 93f9629ea..c5b1a8329 100644 --- a/common/data_refinery_common/models/sample.py +++ b/common/data_refinery_common/models/sample.py @@ -59,7 +59,7 @@ def __str__(self): sex = models.CharField(max_length=255, blank=True) age = models.DecimalField(max_length=255, blank=True, max_digits=8, decimal_places=3, null=True) specimen_part = models.CharField(max_length=255, blank=True) - genotype = models.CharField(max_length=255, blank=True) + genetic_information = models.CharField(max_length=255, blank=True) disease = models.CharField(max_length=255, blank=True) disease_stage = models.CharField(max_length=255, blank=True) cell_line = models.CharField(max_length=255, blank=True) @@ -112,7 +112,7 @@ def to_metadata_dict(self, computed_file=None): metadata["refinebio_sex"] = self.sex metadata["refinebio_age"] = self.age or "" metadata["refinebio_specimen_part"] = self.specimen_part - metadata["refinebio_genetic_information"] = self.genotype + metadata["refinebio_genetic_information"] = self.genetic_information metadata["refinebio_disease"] = self.disease metadata["refinebio_disease_stage"] = self.disease_stage metadata["refinebio_cell_line"] = self.cell_line diff --git a/common/tests/models/test_sample.py b/common/tests/models/test_sample.py new file mode 100644 index 000000000..7d12a1fa8 --- /dev/null +++ b/common/tests/models/test_sample.py @@ -0,0 +1,36 @@ +from django.test import TestCase + +from data_refinery_common.models import Sample + + +class TestSample(TestCase): + def setUp(self): + self.sample = Sample() + self.sample.save() + + def test_to_metadata_dict(self): + self.assertListEqual( + sorted(self.sample.to_metadata_dict().keys()), + [ + "refinebio_accession_code", + "refinebio_age", + "refinebio_annotations", + "refinebio_cell_line", + "refinebio_compound", + "refinebio_disease", + "refinebio_disease_stage", + "refinebio_genetic_information", + "refinebio_organism", + "refinebio_platform", + "refinebio_processed", + "refinebio_race", + "refinebio_sex", + "refinebio_source_archive_url", + "refinebio_source_database", + "refinebio_specimen_part", + "refinebio_subject", + "refinebio_time", + "refinebio_title", + "refinebio_treatment", + ], + ) diff --git a/foreman/data_refinery_foreman/surveyor/harmony.py b/foreman/data_refinery_foreman/surveyor/harmony.py index b0fb7996d..277a80f96 100644 --- a/foreman/data_refinery_foreman/surveyor/harmony.py +++ b/foreman/data_refinery_foreman/surveyor/harmony.py @@ -5,7 +5,7 @@ `sex`, `age`, `specimen_part`, - `genotype`, + `genetic_information`, `disease`, `disease_stage`, `cell_line`, @@ -626,7 +626,7 @@ def __init__(self): ] self.specimen_part_fields = create_variants(specimen_part_fields) - genotype_fields = [ + genetic_information_fields = [ "strain/background", "strain", "strain or line", @@ -639,7 +639,7 @@ def __init__(self): "cultivar", "strain/genotype", ] - self.genotype_fields = create_variants(genotype_fields) + self.genetic_information_fields = create_variants(genetic_information_fields) disease_fields = [ "disease", @@ -797,7 +797,7 @@ def harmonize_sample(self, sample_metadata: Dict, title_field: str = None) -> Di "sex_fields", "age_fields", "specimen_part_fields", - "genotype_fields", + "genetic_information_fields", "disease_fields", "disease_stage_fields", "cell_line_fields", diff --git a/scripts/make_migrations.sh b/scripts/make_migrations.sh index 523ede986..54b87154b 100755 --- a/scripts/make_migrations.sh +++ b/scripts/make_migrations.sh @@ -14,6 +14,7 @@ script_directory="$( )" cd "$script_directory" || exit +./prepare_image.sh -i base -s common ./prepare_image.sh -i migrations -s common . ./common.sh