Skip to content

Commit

Permalink
removed field occurences from frontend and backend
Browse files Browse the repository at this point in the history
  • Loading branch information
hash-bash committed Oct 6, 2024
1 parent 99e4832 commit a42fd8a
Show file tree
Hide file tree
Showing 31 changed files with 83 additions and 423 deletions.
9 changes: 0 additions & 9 deletions backend/flowcell/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class LaneSerializer(ModelSerializer):
read_length_name = SerializerMethodField()
index_i7_show = SerializerMethodField()
index_i5_show = SerializerMethodField()
equal_representation = SerializerMethodField()
quality_check = CharField(required=False)
request = SerializerMethodField()
protocol = SerializerMethodField()
Expand All @@ -73,7 +72,6 @@ class Meta:
"read_length_name",
"index_i7_show",
"index_i5_show",
"equal_representation",
"loading_concentration",
"phix",
"quality_check",
Expand Down Expand Up @@ -168,13 +166,6 @@ def get_index_i5_show(self, obj):
return ""
# return None

def get_equal_representation(self, obj):
records = list(
itertools.chain(obj.pool.libraries.all(), obj.pool.samples.all())
)
ern = [x.equal_representation_nucleotides for x in records].count(True)
return len(records) == ern


class FlowcellListSerializer(ModelSerializer):
flowcell = SerializerMethodField()
Expand Down
4 changes: 2 additions & 2 deletions backend/flowcell/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ def get_queryset(self):
libraries_qs = (
Library.objects.filter(~Q(status=-1))
.prefetch_related("read_length", "index_type")
.only("read_length", "index_type", "equal_representation_nucleotides")
.only("read_length", "index_type")
)

samples_qs = (
Sample.objects.filter(~Q(status=-1))
.prefetch_related("read_length", "index_type")
.only("read_length", "index_type", "equal_representation_nucleotides")
.only("read_length", "index_type")
)

lanes_qs = (
Expand Down
22 changes: 10 additions & 12 deletions backend/incoming_libraries/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,12 @@ class Meta:
"record_type",
"library_protocol",
"concentration",
"concentration_method",
"dilution_factor",
"concentration_facility",
"concentration_method_facility",
"sample_volume_facility",
"amount_facility",
"quality_check",
"size_distribution_facility",
"comments_facility",
"sequencing_depth",
"library_protocol_name",
)
Expand All @@ -66,7 +63,6 @@ class Meta:
"barcode": {"required": False},
"library_protocol": {"required": False},
"concentration": {"required": False},
"concentration_method": {"required": False},
"sequencing_depth": {"required": False},
}

Expand All @@ -81,15 +77,14 @@ class LibrarySerializer(BaseSerializer):
class Meta(BaseSerializer.Meta):
model = Library
fields = BaseSerializer.Meta.fields + (
"qpcr_result",
"qpcr_result_facility",
"mean_fragment_size",
"measuring_unit",
"measured_value"
)
extra_kwargs = {
**BaseSerializer.Meta.extra_kwargs,
**{
"qpcr_result": {"required": False},
"mean_fragment_size": {"required": False},
"measuring_unit": {"required": False},
"measured_value": {"required": False},
},
}

Expand All @@ -102,14 +97,17 @@ class Meta(BaseSerializer.Meta):
fields = BaseSerializer.Meta.fields + (
"nucleic_acid_type",
"nucleic_acid_type_name",
"rna_quality",
"rna_quality_facility",
"measuring_unit",
"measured_value"
"measuring_unit_facility",
"measured_value_facility"
)
extra_kwargs = {
**BaseSerializer.Meta.extra_kwargs,
**{
"nucleic_acid_type": {"required": False},
"rna_quality": {"required": False},
"measuring_unit": {"required": False},
"measured_value": {"required": False},
},
}

Expand Down
2 changes: 0 additions & 2 deletions backend/incoming_libraries/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ def list(self, request):
"""Get the list of all incoming libraries and samples."""
libraries_qs = Library.objects.select_related(
"library_protocol",
"concentration_method",
).filter(status=1)
samples_qs = Sample.objects.select_related(
"library_protocol",
"concentration_method",
"nucleic_acid_type",
).filter(status=1)

Expand Down
3 changes: 0 additions & 3 deletions backend/library/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,9 @@ class LibraryAdmin(admin.ModelAdmin):
"fields": (
"dilution_factor",
"concentration_facility",
"concentration_method_facility",
"sample_volume_facility",
"amount_facility",
"size_distribution_facility",
"qpcr_result_facility",
"comments_facility",
),
},
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.15 on 2024-09-24 23:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('library', '0007_rename_amplification_cycles_library_removed_amplification_cycles_and_more'),
]

operations = [
migrations.AlterField(
model_name='library',
name='removed_equal_representation_nucleotides',
field=models.BooleanField(blank=True, default=False, verbose_name='Equal Representation of Nucleotides'),
),
]
2 changes: 1 addition & 1 deletion backend/library/migrations/max_migration.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0007_rename_amplification_cycles_library_removed_amplification_cycles_and_more
0008_alter_library_removed_equal_representation_nucleotides
15 changes: 0 additions & 15 deletions backend/library/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ def create_library(name, status=0, save=True, read_length=None, index_type=None)
organism = Organism(name="Organism")
organism.save()

concentration_method = ConcentrationMethod(name="Concentration Method")
concentration_method.save()

if read_length is None:
read_length = ReadLength(name="Read Length")
read_length.save()
Expand Down Expand Up @@ -56,12 +53,10 @@ def create_library(name, status=0, save=True, read_length=None, index_type=None)
status=status,
organism_id=organism.pk,
concentration=1.0,
concentration_method_id=concentration_method.pk,
read_length_id=read_length.pk,
sequencing_depth=1,
library_protocol_id=library_protocol.pk,
library_type_id=library_type.pk,
amplification_cycles=1,
index_type_id=index_type.pk,
index_reads=0,
mean_fragment_size=1,
Expand Down Expand Up @@ -214,12 +209,10 @@ def test_add_library(self):
"name": name,
"organism": library.organism.pk,
"concentration": 1.0,
"concentration_method": library.concentration_method.pk,
"read_length": library.read_length.pk,
"sequencing_depth": 1,
"library_protocol": library.library_protocol.pk,
"library_type": library.library_type.pk,
"amplification_cycles": 1,
"index_type": library.index_type.pk,
"index_reads": 0,
"mean_fragment_size": 1,
Expand All @@ -246,12 +239,10 @@ def test_add_library_contains_invalid(self):
"name": name,
"organism": self.library.organism.pk,
"concentration": 1.0,
"concentration_method": self.library.concentration_method.pk,
"read_length": self.library.read_length.pk,
"sequencing_depth": 1,
"library_protocol": self.library.library_protocol.pk,
"library_type": self.library.library_type.pk,
"amplification_cycles": 1,
"index_type": self.library.index_type.pk,
"index_reads": 0,
"mean_fragment_size": 1,
Expand All @@ -260,7 +251,6 @@ def test_add_library_contains_invalid(self):
"name": self._get_random_name(),
"concentration": 1.0,
"sequencing_depth": 1,
"amplification_cycles": 1,
"index_reads": 0,
"mean_fragment_size": 1,
},
Expand Down Expand Up @@ -317,12 +307,10 @@ def test_update_library(self):
"name": new_name,
"organism": library.organism.pk,
"concentration": 1.0,
"concentration_method": library.concentration_method.pk,
"read_length": library.read_length.pk,
"sequencing_depth": 1,
"library_protocol": library.library_protocol.pk,
"library_type": library.library_type.pk,
"amplification_cycles": 1,
"index_type": library.index_type.pk,
"index_reads": 0,
"mean_fragment_size": 1,
Expand Down Expand Up @@ -352,12 +340,10 @@ def test_update_library_contains_invalid(self):
"name": new_name1,
"organism": library1.organism.pk,
"concentration": 1.0,
"concentration_method": library1.concentration_method.pk,
"read_length": library1.read_length.pk,
"sequencing_depth": 1,
"library_protocol": library1.library_protocol.pk,
"library_type": library1.library_type.pk,
"amplification_cycles": 1,
"index_type": library1.index_type.pk,
"index_reads": 0,
"mean_fragment_size": 1,
Expand All @@ -367,7 +353,6 @@ def test_update_library_contains_invalid(self):
"name": new_name2,
"concentration": 2.0,
"sequencing_depth": 2,
"amplification_cycles": 2,
"index_reads": 0,
"mean_fragment_size": 2,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.15 on 2024-09-24 23:54

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('library_preparation', '0004_librarypreparation_smear_analysis'),
]

operations = [
migrations.RenameField(
model_name='librarypreparation',
old_name='qpcr_result',
new_name='removed_qpcr_result',
),
]
2 changes: 1 addition & 1 deletion backend/library_preparation/migrations/max_migration.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0004_librarypreparation_smear_analysis
0005_rename_qpcr_result_librarypreparation_removed_qpcr_result
4 changes: 2 additions & 2 deletions backend/library_preparation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ class LibraryPreparation(DateTimeMixin):
blank=True,
)

qpcr_result = models.FloatField(
removed_qpcr_result = models.FloatField(
"qPCR Result",
null=True,
blank=True,
)
) # This field is not in use

comments = models.TextField(
"Comments",
Expand Down
3 changes: 2 additions & 1 deletion backend/library_sample_shared/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ def index_i5_id(self):

removed_equal_representation_nucleotides = models.BooleanField(
"Equal Representation of Nucleotides",
default=True,
blank=True,
default=False,
) # This field is not in use

removed_comments = models.TextField(
Expand Down
26 changes: 0 additions & 26 deletions backend/library_sample_shared/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@ def test_organism_name(self):
self.assertEqual(self.organism.__str__(), self.organism.name)


class ConcentrationMethodTest(TestCase):
def setUp(self):
self.method = ConcentrationMethod(name=get_random_name())

def test_concentration_method_name(self):
self.assertTrue(isinstance(self.method, ConcentrationMethod))
self.assertEqual(self.method.__str__(), self.method.name)


class ReadLengthTest(TestCase):
def setUp(self):
self.read_length = ReadLength(name=get_random_name())
Expand Down Expand Up @@ -229,23 +220,6 @@ def test_organisms_list(self):
self.assertIn(self.read_length.name, read_lengths)


class TestConcentrationMethods(BaseTestCase):
def setUp(self):
self.create_user("[email protected]", "foo-foo")
self.client.login(email="[email protected]", password="foo-foo")

self.concentration_method = ConcentrationMethod(name=self._get_random_name())
self.concentration_method.save()

def test_organisms_list(self):
"""Ensure get concentration methods behaves correctly."""
response = self.client.get(reverse("concentration-method-list"))
data = response.json()
concentration_methods = [x["name"] for x in data]
self.assertEqual(response.status_code, 200)
self.assertIn(self.concentration_method.name, concentration_methods)


class TestIndexTypes(BaseTestCase):
def setUp(self):
self.create_user("[email protected]", "foo-foo")
Expand Down
10 changes: 3 additions & 7 deletions backend/request/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,14 +1093,10 @@ def export_request(request):
dataset = Dataset()
dataset.headers = (
# The following are not submitted by user...
# id barcode create_time update_time status concentration concentration_method
# equal_representation_nucleotides comments is_pooled amplification_cycles
# dilution_factor concentration_facility concentration_method_facility archived
# id barcode create_time update_time status concentration
# is_pooled dilution_factor concentration_facility archived
# sample_volume_facility amount_facility size_distribution_facility comments_facility
##libraries-exclusively:
# qpcr_result qpcr_result_facility
##sample-exclusively:
# is_converted
## sample-exclusively: is_converted
"id",
"name",
"barcode",
Expand Down
5 changes: 2 additions & 3 deletions backend/sample/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,13 @@ class SampleAdmin(admin.ModelAdmin):
"Determined by Facility",
{
"fields": (
"measuring_unit_facility",
"measured_value_facility",
"dilution_factor",
"concentration_facility",
"concentration_method_facility",
"sample_volume_facility",
"amount_facility",
"size_distribution_facility",
"rna_quality_facility",
"comments_facility",
),
},
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.15 on 2024-09-24 23:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sample', '0011_alter_sample_measured_value_facility'),
]

operations = [
migrations.AlterField(
model_name='sample',
name='removed_equal_representation_nucleotides',
field=models.BooleanField(blank=True, default=False, verbose_name='Equal Representation of Nucleotides'),
),
]
2 changes: 1 addition & 1 deletion backend/sample/migrations/max_migration.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0011_alter_sample_measured_value_facility
0012_alter_sample_removed_equal_representation_nucleotides
Loading

0 comments on commit a42fd8a

Please sign in to comment.