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

Add new Libraries and Samples: New fields addition #143

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open
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: 8 additions & 14 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 @@ -80,16 +76,12 @@ 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 + ("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 +94,16 @@ 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
15 changes: 4 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,20 +57,17 @@ class LibraryAdmin(admin.ModelAdmin):
"fields": (
"library_protocol",
"library_type",
"measuring_unit",
"measured_value",
"concentration",
"concentration_method",
"organism",
"volume",
"read_length",
"sequencing_depth",
"mean_fragment_size",
"equal_representation_nucleotides",
"index_type",
"index_reads",
"index_i7",
"index_i5",
"qpcr_result",
"amplification_cycles",
"comments",
"organism",
),
},
),
Expand All @@ -81,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,45 @@
# Generated by Django 4.2.14 on 2024-08-06 15:32

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


class Migration(migrations.Migration):

dependencies = [
("library", "0004_archived_feature"),
]

operations = [
migrations.AddField(
model_name="library",
name="measuring_unit",
field=models.CharField(
blank=True,
choices=[("bp", "bp (DNA)"), ("-", "Measure for Me")],
max_length=50,
null=True,
verbose_name="Measuring Unit",
),
),
migrations.AddField(
model_name="library",
name="volume",
field=models.FloatField(
blank=True,
null=True,
validators=[django.core.validators.MinValueValidator(10)],
verbose_name="Volume",
),
),
migrations.AlterField(
model_name="library",
name="mean_fragment_size",
field=models.FloatField(
blank=True,
null=True,
validators=[django.core.validators.MinValueValidator(-1)],
verbose_name="Measured Value",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.15 on 2024-08-22 11:36

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("library", "0005_library_measuring_unit_library_volume_and_more"),
]

operations = [
migrations.RenameField(
model_name="library",
old_name="mean_fragment_size",
new_name="measured_value",
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Generated by Django 4.2.15 on 2024-09-24 22:34

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("library", "0006_rename_mean_fragment_size_library_measured_value"),
]

operations = [
migrations.RenameField(
model_name="library",
old_name="amplification_cycles",
new_name="removed_amplification_cycles",
),
migrations.RenameField(
model_name="library",
old_name="comments",
new_name="removed_comments",
),
migrations.RenameField(
model_name="library",
old_name="comments_facility",
new_name="removed_comments_facility",
),
migrations.RenameField(
model_name="library",
old_name="concentration_method",
new_name="removed_concentration_method",
),
migrations.RenameField(
model_name="library",
old_name="concentration_method_facility",
new_name="removed_concentration_method_facility",
),
migrations.RenameField(
model_name="library",
old_name="equal_representation_nucleotides",
new_name="removed_equal_representation_nucleotides",
),
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",
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 4.2.15 on 2024-09-25 00:31

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", "0008_alter_library_removed_equal_representation_nucleotides"),
]

operations = [
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",
),
),
]
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
0009_alter_library_removed_concentration_method
32 changes: 24 additions & 8 deletions backend/library/models.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
from django.core.validators import MinValueValidator
from django.db import models
from library_sample_shared.models import GenericLibrarySample


class Library(GenericLibrarySample):
mean_fragment_size = models.PositiveIntegerField(
"Mean Fragment Size",
MEASURING_UNIT_CHOICES = [
("bp (DNA)", "bp", "DNA"),
("Measure for Me", "-", "Measure"),
]

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,
)

qpcr_result = models.FloatField("qPCR Result", null=True, blank=True)
measured_value = models.FloatField(
"Measured Value", validators=[MinValueValidator(-1)], null=True, blank=True
)

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

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,
)

archived = models.BooleanField("Archived", default=False)
) # This field is not in use

class Meta:
verbose_name = "Library"
Expand Down
Loading
Loading