Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Parkour Fields #166

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -48,26 +48,28 @@ class Meta:
"barcode",
"record_type",
"library_protocol",
"concentration",
"concentration_method",
"measuring_unit",
"measured_value",
"dilution_factor",
"concentration_facility",
"concentration_method_facility",
"sample_volume_facility",
"amount_facility",
"quality_check",
"size_distribution_facility",
"comments_facility",
"sequencing_depth",
"library_protocol_name",
"measuring_unit_facility",
"measured_value_facility",
)
extra_kwargs = {
"name": {"required": False},
"barcode": {"required": False},
"library_protocol": {"required": False},
"concentration": {"required": False},
"concentration_method": {"required": False},
"sequencing_depth": {"required": False},
"measuring_unit": {"required": False},
"measured_value": {"required": False},
"measuring_unit_facility": {"required": False},
"measured_value_facility": {"required": False},
}

def get_record_type(self, obj):
Expand All @@ -80,15 +82,11 @@ def get_library_protocol_name(self, obj):
class LibrarySerializer(BaseSerializer):
class Meta(BaseSerializer.Meta):
model = Library
fields = BaseSerializer.Meta.fields + (
"qpcr_result",
"qpcr_result_facility",
"mean_fragment_size",
)
fields = BaseSerializer.Meta.fields + ("mean_fragment_size",)

extra_kwargs = {
**BaseSerializer.Meta.extra_kwargs,
**{
"qpcr_result": {"required": False},
"mean_fragment_size": {"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
18 changes: 7 additions & 11 deletions backend/library/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class LibraryAdmin(admin.ModelAdmin):
list_filter = (
("library_protocol", RelatedDropdownFilter),
("library_type", RelatedDropdownFilter),
("concentration_method", RelatedDropdownFilter),
("organism", RelatedDropdownFilter),
("read_length", RelatedDropdownFilter),
("index_type", RelatedDropdownFilter),
Expand All @@ -58,19 +57,17 @@ class LibraryAdmin(admin.ModelAdmin):
"fields": (
"library_protocol",
"library_type",
"concentration",
"concentration_method",
"organism",
"measuring_unit",
"measured_value",
"mean_fragment_size",
"volume",
"read_length",
"sequencing_depth",
"mean_fragment_size",
"equal_representation_nucleotides",
"index_type",
"index_reads",
"index_i7",
"index_i5",
"qpcr_result",
"amplification_cycles",
"organism",
"comments",
),
},
Expand All @@ -79,13 +76,12 @@ class LibraryAdmin(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",
"qpcr_result_facility",
"comments_facility",
),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Generated by Django 4.2.16 on 2024-10-23 01:27

import django.core.validators
import library_sample_shared.models
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
(
"library_sample_shared",
"0011_alter_indexi5_number_alter_indexi5_prefix_and_more",
),
("library", "0004_archived_feature"),
]

operations = [
migrations.RenameField(
model_name="library",
old_name="amplification_cycles",
new_name="removed_amplification_cycles",
),
migrations.RenameField(
model_name="library",
old_name="concentration_facility",
new_name="measured_value_facility",
),
migrations.RenameField(
model_name="library",
old_name="concentration_method_facility",
new_name="removed_concentration_method_facility",
),
migrations.RenameField(
model_name="library",
old_name="qpcr_result",
new_name="removed_qpcr_result",
),
migrations.RenameField(
model_name="library",
old_name="qpcr_result_facility",
new_name="removed_qpcr_result_facility",
),
migrations.RenameField(
model_name="library",
old_name="concentration",
new_name="measured_value",
),
migrations.RenameField(
model_name="library",
old_name="concentration_method",
new_name="removed_concentration_method",
),
migrations.RenameField(
model_name="library",
old_name="equal_representation_nucleotides",
new_name="removed_equal_representation_nucleotides",
),
migrations.AddField(
model_name="library",
name="measuring_unit",
field=models.CharField(
blank=True,
choices=[("concentration", "Concentration (ng/µl)"), ("-", "Unknown")],
max_length=50,
null=True,
verbose_name="Measuring Unit",
),
),
migrations.AddField(
model_name="library",
name="measuring_unit_facility",
field=models.CharField(
blank=True,
choices=[("concentration", "Concentration (ng/µl)"), ("-", "Unknown")],
max_length=50,
null=True,
verbose_name="Measuring Unit (facility)",
),
),
migrations.AddField(
model_name="library",
name="volume",
field=models.FloatField(
blank=True,
null=True,
validators=[django.core.validators.MinValueValidator(10)],
verbose_name="Volume",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Generated by Django 4.2.16 on 2024-10-23 01:52

import django.core.validators
import library_sample_shared.models
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
(
"library_sample_shared",
"0011_alter_indexi5_number_alter_indexi5_prefix_and_more",
),
(
"library",
"0005_rename_amplification_cycles_library_removed_amplification_cycles_and_more",
),
]

operations = [
migrations.AlterField(
model_name="library",
name="measured_value",
field=models.FloatField(
blank=True,
null=True,
validators=[django.core.validators.MinValueValidator(-1)],
verbose_name="Measured Value",
),
),
migrations.AlterField(
model_name="library",
name="measured_value_facility",
field=models.FloatField(
blank=True,
null=True,
validators=[django.core.validators.MinValueValidator(-1)],
verbose_name="Measured Value (facility)",
),
),
migrations.AlterField(
model_name="library",
name="removed_concentration_method",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=models.SET(
library_sample_shared.models.get_removed_concentrationmethod
),
to="library_sample_shared.concentrationmethod",
verbose_name="Concentration Method",
),
),
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 @@
0004_archived_feature
0006_alter_library_measured_value_and_more
37 changes: 33 additions & 4 deletions backend/library/models.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,54 @@
from django.core.validators import MinValueValidator
from django.db import models
from library_sample_shared.models import GenericLibrarySample


class Library(GenericLibrarySample):
MEASURING_UNIT_CHOICES = [
("Concentration (ng/µl)", "concentration", "Concentration"),
("Unknown", "-", "Unknown"),
]

measuring_unit = models.CharField(
"Measuring Unit",
max_length=50,
choices=[
(unit, display_name)
for display_name, unit, input_type in MEASURING_UNIT_CHOICES
],
null=True,
blank=True,
)

mean_fragment_size = models.PositiveIntegerField(
"Mean Fragment Size",
null=True,
blank=True,
)

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

# Quality Control
qpcr_result_facility = models.FloatField(
removed_qpcr_result_facility = models.FloatField(
"qPCR Result (facility)",
null=True,
blank=True,
)
) # This field is not in use

archived = models.BooleanField("Archived", default=False)

measuring_unit_facility = models.CharField(
"Measuring Unit (facility)",
max_length=50,
choices=[
(unit, display_name)
for display_name, unit, input_type in MEASURING_UNIT_CHOICES
],
null=True,
blank=True,
)

class Meta:
verbose_name = "Library"
verbose_name_plural = "Libraries"
3 changes: 2 additions & 1 deletion backend/library/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class Meta(LibrarySampleBaseSerializer.Meta):
"index_i7",
"index_i5",
"mean_fragment_size",
"qpcr_result",
"measuring_unit",
"measured_value",
)

def get_record_type(self, obj):
Expand Down
Loading
Loading