Skip to content

Commit

Permalink
Merge pull request #3415 from AlexsLemonade/ark/3408-change-sample-ge…
Browse files Browse the repository at this point in the history
…notype-field

Rename Sample::genotype to Sample::genetic_information
  • Loading branch information
arkid15r authored Oct 17, 2023
2 parents 06511fa + 548dc82 commit f5d4b39
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 10 deletions.
6 changes: 3 additions & 3 deletions api/data_refinery_api/views/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Meta:
"sex",
"age",
"specimen_part",
"genotype",
"genetic_information",
"disease",
"disease_stage",
"cell_line",
Expand Down Expand Up @@ -158,7 +158,7 @@ class SampleListView(generics.ListAPIView):
"sex",
"age",
"specimen_part",
"genotype",
"genetic_information",
"disease",
"disease_stage",
"cell_line",
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
),
]
2 changes: 1 addition & 1 deletion common/data_refinery_common/models/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def get_sample_metadata_fields(self):
"sex",
"age",
"specimen_part",
"genotype",
"genetic_information",
"disease",
"disease_stage",
"cell_line",
Expand Down
4 changes: 2 additions & 2 deletions common/data_refinery_common/models/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions common/tests/models/test_sample.py
Original file line number Diff line number Diff line change
@@ -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",
],
)
8 changes: 4 additions & 4 deletions foreman/data_refinery_foreman/surveyor/harmony.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
`sex`,
`age`,
`specimen_part`,
`genotype`,
`genetic_information`,
`disease`,
`disease_stage`,
`cell_line`,
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions scripts/make_migrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f5d4b39

Please sign in to comment.