Skip to content

Commit

Permalink
Updated last reviewer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Shettland committed Jul 23, 2024
1 parent da9f113 commit a09d1d6
Show file tree
Hide file tree
Showing 22 changed files with 230 additions and 268 deletions.
93 changes: 35 additions & 58 deletions relecov_core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,7 @@
from django.contrib.auth.models import User

# Local imports
from relecov_core.models import (
BioinfoAnalysisValue,
BioinfoAnalysisField,
Classification,
Chromosome,
ConfigSetting,
Effect,
Error,
Gene,
Filter,
LineageFields,
LineageValues,
LineageInfo,
MetadataVisualization,
OrganismAnnotation,
Profile,
PropertyOptions,
PublicDatabaseFields,
PublicDatabaseValues,
PublicDatabaseType,
Sample,
SampleState,
Schema,
SchemaProperties,
TemporalSampleStorage,
Variant,
VariantInSample,
VariantAnnotation,
DateUpdateState,
)
import relecov_core.models


def custom_date_format(self):
Expand All @@ -43,7 +14,7 @@ def custom_date_format(self):


class ProfileInLine(admin.StackedInline):
model = Profile
model = relecov_core.models.Profile
can_delete = False
verbose_name_plural = "Profile"
fk_name = "user"
Expand Down Expand Up @@ -201,30 +172,36 @@ class MetadataVisualizationAdmin(admin.ModelAdmin):
# Register models
admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)
admin.site.register(ConfigSetting, ConfigSettingAdmin)
admin.site.register(Filter, FilterAdmin)
admin.site.register(Effect, EffectAdmin)
admin.site.register(Gene, GeneAdmin)
admin.site.register(Chromosome, ChromosomeAdmin)
admin.site.register(LineageFields, LineageFieldsAdmin)
admin.site.register(LineageValues, LineageValuesAdmin)
admin.site.register(Sample, SampleAdmin)
admin.site.register(SampleState, SampleStateAdmin)
admin.site.register(Variant, VariantAdmin)
admin.site.register(VariantInSample, VariantInSampleAdmin)
admin.site.register(VariantAnnotation, VariantAnnotationAdmin)
admin.site.register(Schema, SchemaAdmin)
admin.site.register(SchemaProperties, SchemaPropertiesAdmin)
admin.site.register(PropertyOptions, PropertyOptionsAdmin)
admin.site.register(PublicDatabaseType, PublicDatabaseTypeAdmin)
admin.site.register(PublicDatabaseFields, PublicDatabaseFieldsAdmin)
admin.site.register(PublicDatabaseValues, PublicDatabaseValuesAdmin)
admin.site.register(MetadataVisualization, MetadataVisualizationAdmin)
admin.site.register(BioinfoAnalysisField, BioinfoAnalysisFielddAdmin)
admin.site.register(BioinfoAnalysisValue, BioinfoAnalysisValueAdmin)
admin.site.register(Classification, ClassificationAdmin)
admin.site.register(TemporalSampleStorage, TemporalSampleStorageAdmin)
admin.site.register(Error, ErrorAdmin)
admin.site.register(DateUpdateState, DateUpdateStateAdmin)
admin.site.register(LineageInfo, LineageInfoAdmin)
admin.site.register(OrganismAnnotation, OrganismAnnotationAdmin)
admin.site.register(relecov_core.models.ConfigSetting, ConfigSettingAdmin)
admin.site.register(relecov_core.models.Filter, FilterAdmin)
admin.site.register(relecov_core.models.Effect, EffectAdmin)
admin.site.register(relecov_core.models.Gene, GeneAdmin)
admin.site.register(relecov_core.models.Chromosome, ChromosomeAdmin)
admin.site.register(relecov_core.models.LineageFields, LineageFieldsAdmin)
admin.site.register(relecov_core.models.LineageValues, LineageValuesAdmin)
admin.site.register(relecov_core.models.Sample, SampleAdmin)
admin.site.register(relecov_core.models.SampleState, SampleStateAdmin)
admin.site.register(relecov_core.models.Variant, VariantAdmin)
admin.site.register(relecov_core.models.VariantInSample, VariantInSampleAdmin)
admin.site.register(relecov_core.models.VariantAnnotation, VariantAnnotationAdmin)
admin.site.register(relecov_core.models.Schema, SchemaAdmin)
admin.site.register(relecov_core.models.SchemaProperties, SchemaPropertiesAdmin)
admin.site.register(relecov_core.models.PropertyOptions, PropertyOptionsAdmin)
admin.site.register(relecov_core.models.PublicDatabaseType, PublicDatabaseTypeAdmin)
admin.site.register(relecov_core.models.PublicDatabaseFields, PublicDatabaseFieldsAdmin)
admin.site.register(relecov_core.models.PublicDatabaseValues, PublicDatabaseValuesAdmin)
admin.site.register(
relecov_core.models.MetadataVisualization, MetadataVisualizationAdmin
)
admin.site.register(
relecov_core.models.BioinfoAnalysisField, BioinfoAnalysisFielddAdmin
)
admin.site.register(relecov_core.models.BioinfoAnalysisValue, BioinfoAnalysisValueAdmin)
admin.site.register(relecov_core.models.Classification, ClassificationAdmin)
admin.site.register(
relecov_core.models.TemporalSampleStorage, TemporalSampleStorageAdmin
)
admin.site.register(relecov_core.models.Error, ErrorAdmin)
admin.site.register(relecov_core.models.DateUpdateState, DateUpdateStateAdmin)
admin.site.register(relecov_core.models.LineageInfo, LineageInfoAdmin)
admin.site.register(relecov_core.models.OrganismAnnotation, OrganismAnnotationAdmin)
1 change: 1 addition & 0 deletions relecov_core/api/apps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generic imports
from django.apps import AppConfig


Expand Down
39 changes: 15 additions & 24 deletions relecov_core/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,86 +1,77 @@
# Generic imports
from rest_framework import serializers

from relecov_core.models import (
BioinfoAnalysisValue,
DateUpdateState,
Effect,
Filter,
LineageValues,
Sample,
Variant,
VariantAnnotation,
VariantInSample,
PublicDatabaseValues,
)
# Local imports
import relecov_core.models


class CreateBioinfoAnalysisValueSerializer(serializers.ModelSerializer):
class Meta:
model = BioinfoAnalysisValue
model = relecov_core.models.BioinfoAnalysisValue
fields = "__all__"


class CreateDateAfterChangeStateSerializer(serializers.ModelSerializer):
class Meta:
model = DateUpdateState
model = relecov_core.models.DateUpdateState
fields = "__all__"


class CreateSampleSerializer(serializers.ModelSerializer):
class Meta:
model = Sample
model = relecov_core.models.Sample
fields = "__all__"


class CreateEffectSerializer(serializers.ModelSerializer):
class Meta:
model = Effect
model = relecov_core.models.Effect
fields = "__all__"


class CreateErrorSerializer(serializers.ModelSerializer):
class Meta:
model = Sample
model = relecov_core.models.Sample
fields = "__all__"


class CreateVariantInSampleSerializer(serializers.ModelSerializer):
class Meta:
model = VariantInSample
model = relecov_core.models.VariantInSample
fields = "__all__"


class CreateVariantAnnotationSerializer(serializers.ModelSerializer):
class Meta:
model = VariantAnnotation
model = relecov_core.models.VariantAnnotation
fields = "__all__"


class CreateFilterSerializer(serializers.ModelSerializer):
class Meta:
model = Filter
model = relecov_core.models.Filter
fields = "__all__"


class CreateVariantSerializer(serializers.ModelSerializer):
class Meta:
model = Variant
model = relecov_core.models.Variant
fields = "__all__"


class CreateLineageValueSerializer(serializers.ModelSerializer):
class Meta:
model = LineageValues
model = relecov_core.models.LineageValues
fields = "__all__"


class CreatePublicDatabaseValueSerializer(serializers.ModelSerializer):
class Meta:
model = PublicDatabaseValues
model = relecov_core.models.PublicDatabaseValues
fields = "__all__"


class UpdateStateSampleSerializer(serializers.ModelSerializer):
class Meta:
model = Sample
model = relecov_core.models.Sample
fields = "__all__"
23 changes: 18 additions & 5 deletions relecov_core/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
# Generic imports
from django.urls import path
from relecov_core.api import views

# Local imports
import relecov_core.api

app_name = "relecov_api"


urlpatterns = [
path(
"createBioinfoData", views.create_bioinfo_metadata, name="create_bioinfo_data"
"createBioinfoData",
relecov_core.api.views.create_bioinfo_metadata,
name="create_bioinfo_data",
),
path(
"createSampleData",
relecov_core.api.views.create_sample_data,
name="create_sample_data",
),
path(
"createVariantData",
relecov_core.api.views.create_variant_data,
name="create_variant_data",
),
path("createSampleData", views.create_sample_data, name="create_sample_data"),
path("createVariantData", views.create_variant_data, name="create_variant_data"),
path("updateState", views.update_state, name="update_state"),
path("updateState", relecov_core.api.views.update_state, name="update_state"),
]
16 changes: 11 additions & 5 deletions relecov_core/api/utils/bioinfo_metadata.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Local imports
import relecov_core.models
import relecov_core.api.serializers
from relecov_core.core_config import (
ERROR_UNABLE_TO_STORE_IN_DATABASE,
)
import relecov_core.config


def split_bioinfo_data(data, schema_obj):
Expand Down Expand Up @@ -58,7 +56,11 @@ def store_bioinfo_data(s_data, schema_obj):
relecov_core.api.serializers.CreateBioinfoAnalysisValueSerializer(data=data)
)
if not bio_value_serializer.is_valid():
return {"ERROR": str(field + " " + ERROR_UNABLE_TO_STORE_IN_DATABASE)}
return {
"ERROR": str(
field + " " + relecov_core.config.ERROR_UNABLE_TO_STORE_IN_DATABASE
)
}
bio_value_obj = bio_value_serializer.save()
sample_obj.bio_analysis_values.add(bio_value_obj)

Expand All @@ -77,7 +79,11 @@ def store_bioinfo_data(s_data, schema_obj):
)

if not lineage_value_serializer.is_valid():
return {"ERROR": str(field + " " + ERROR_UNABLE_TO_STORE_IN_DATABASE)}
return {
"ERROR": str(
field + " " + relecov_core.config.ERROR_UNABLE_TO_STORE_IN_DATABASE
)
}
lineage_value_obj = lineage_value_serializer.save()
sample_obj.lineage_values.add(lineage_value_obj)

Expand Down
10 changes: 8 additions & 2 deletions relecov_core/api/utils/public_db.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Local imports
import relecov_core.models
import relecov_core.api.serializers
from relecov_core.core_config import ERROR_UNABLE_TO_STORE_IN_DATABASE
import relecov_core.config


def store_pub_databases_data(data, pub_db, schema_obj, sample_id):
Expand All @@ -23,6 +23,12 @@ def store_pub_databases_data(data, pub_db, schema_obj, sample_id):
)
)
if not value_serializer.is_valid():
return {"ERROR": str(prop_name + " " + ERROR_UNABLE_TO_STORE_IN_DATABASE)}
return {
"ERROR": str(
prop_name
+ " "
+ relecov_core.config.ERROR_UNABLE_TO_STORE_IN_DATABASE
)
}
value_serializer.save()
return {"SUCCESS": "success"}
4 changes: 2 additions & 2 deletions relecov_core/api/utils/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# Local imports
import relecov_core.models
import relecov_core.utils.samples
from relecov_core.core_config import ERROR_INTIAL_SETTINGS_NOT_DEFINED
import relecov_core.config


def prepare_fields_in_sample(s_data):
"""Add sample state and set to None GISAID and ENA if not set"""
if not relecov_core.models.SampleState.objects.filter(
state__exact="Defined"
).exists():
return {"ERROR": ERROR_INTIAL_SETTINGS_NOT_DEFINED}
return {"ERROR": relecov_core.config.ERROR_INTIAL_SETTINGS_NOT_DEFINED}
s_data["state"] = (
relecov_core.models.SampleState.objects.filter(state__exact="Defined")
.last()
Expand Down
Loading

0 comments on commit a09d1d6

Please sign in to comment.