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

Refactor of database tables and api related core utilities #181

Open
wants to merge 12 commits into
base: pathoweb-core
Choose a base branch
from
Open
167 changes: 167 additions & 0 deletions conf/first_install_tables.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,172 @@
"name": "RelecovManager",
"permissions": []
}
}, {
"model": "core.errorname",
"pk": 1,
"fields": {
"error_code": "0",
"error_name": "No Error"
}
},
{
"model": "core.errorname",
"pk": 2,
"fields": {
"error_code": "100",
"error_name": "AttributeError: An object attribute is missing or invalid"
}
},
{
"model": "core.errorname",
"pk": 3,
"fields": {
"error_code": "101",
"error_name": "TypeError: An operation or function was applied to an object of inappropriate type"
}
},
{
"model": "core.errorname",
"pk": 4,
"fields": {
"error_code": "102",
"error_name": "ValueError: An operation received an argument with the right type but inappropriate value"
}
},
{
"model": "core.errorname",
"pk": 5,
"fields": {
"error_code": "103",
"error_name": "KeyError: A key was not found in a mapping or dictionary"
}
},
{
"model": "core.errorname",
"pk": 6,
"fields": {
"error_code": "104",
"error_name": "IndexError: A sequence subscript was out of range"
}
},
{
"model": "core.errorname",
"pk": 7,
"fields": {
"error_code": "105",
"error_name": "ImportError: A module or object could not be imported"
}
},
{
"model": "core.errorname",
"pk": 8,
"fields": {
"error_code": "106",
"error_name": "ModuleNotFoundError: A specified module could not be found"
}
},
{
"model": "core.errorname",
"pk": 9,
"fields": {
"error_code": "107",
"error_name": "ZeroDivisionError: Division or modulo by zero"
}
},
{
"model": "core.errorname",
"pk": 10,
"fields": {
"error_code": "108",
"error_name": "FileNotFoundError: A file or directory was requested but does not exist"
}
},
{
"model": "core.errorname",
"pk": 11,
"fields": {
"error_code": "109",
"error_name": "IOError: An input/output operation failed"
}
},
{
"model": "core.errorname",
"pk": 12,
"fields": {
"error_code": "110",
"error_name": "PermissionError: An operation lacked the necessary permissions"
}
},
{
"model": "core.errorname",
"pk": 13,
"fields": {
"error_code": "111",
"error_name": "TimeoutError: An operation exceeded its designated time limit"
}
},
{
"model": "core.errorname",
"pk": 14,
"fields": {
"error_code": "112",
"error_name": "MemoryError: An operation ran out of memory"
}
},
{
"model": "core.errorname",
"pk": 15,
"fields": {
"error_code": "113",
"error_name": "RecursionError: The maximum recursion depth was exceeded"
}
},
{
"model": "core.errorname",
"pk": 16,
"fields": {
"error_code": "114",
"error_name": "NameError: A variable or function name is not defined"
}
},
{
"model": "core.errorname",
"pk": 17,
"fields": {
"error_code": "115",
"error_name": "SyntaxError: Invalid syntax in the code"
}
},
{
"model": "core.errorname",
"pk": 18,
"fields": {
"error_code": "116",
"error_name": "IndentationError: Code indentation is incorrect"
}
},
{
"model": "core.errorname",
"pk": 19,
"fields": {
"error_code": "117",
"error_name": "StopIteration: Iteration has no further items"
}
},
{
"model": "core.errorname",
"pk": 20,
"fields": {
"error_code": "118",
"error_name": "OverflowError: A numerical calculation exceeded a range limit"
}
},
{
"model": "core.errorname",
"pk": 21,
"fields": {
"error_code": "999",
"error_name": "Other unspecified error occurred"
}
}
]
35 changes: 20 additions & 15 deletions core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ class AnalysisPerformedAdmin(admin.ModelAdmin):
list_display = ["typeID", "sampleID"]


class BioinfoAnalysisFielddAdmin(admin.ModelAdmin):
list_display = ["property_name", "label_name"]
search_fields = ("property_name__icontains",)


class BioinfoAnalysisValueAdmin(admin.ModelAdmin):
list_display = ["value", "bioinfo_analysis_fieldID"]
class MetadataValuesAdmin(admin.ModelAdmin):
list_display = ["value", "sample", "schema_property", "analysis_date"]
search_fields = ("value__icontains",)


Expand All @@ -51,16 +46,26 @@ class ConfigSettingAdmin(admin.ModelAdmin):
list_display = ["configuration_name", "configuration_value"]


class DateUpdateStateAdmin(admin.ModelAdmin):
list_display = ["sampleID", "stateID", custom_date_format]
class SampleStateHistoryAdmin(admin.ModelAdmin):
list_display = [
"is_current",
custom_date_format,
"sample_id",
"state_id",
"error_name_id",
]


class EffectAdmin(admin.ModelAdmin):
list_display = ["effect"]


class ErrorNameAdmin(admin.ModelAdmin):
list_display = ["error_name", "error_code", "error_text"]


class ErrorAdmin(admin.ModelAdmin):
list_display = ["error_name", "display_string"]
list_display = ["error_name", "error_code", "erorr_text"]


class FilterAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -109,7 +114,6 @@ class SampleAdmin(admin.ModelAdmin):
"sequencing_sample_id",
"submitting_lab_sample_id",
"collecting_lab_sample_id",
"state",
]
search_fields = ["sequencing_sample_id__icontains"]
list_filter = ["created_at"]
Expand Down Expand Up @@ -177,6 +181,7 @@ class MetadataVisualizationAdmin(admin.ModelAdmin):
admin.site.register(core.models.Effect, EffectAdmin)
admin.site.register(core.models.Gene, GeneAdmin)
admin.site.register(core.models.Chromosome, ChromosomeAdmin)
# TODO: Remove the line below when we remove lineage things
admin.site.register(core.models.LineageFields, LineageFieldsAdmin)
admin.site.register(core.models.LineageValues, LineageValuesAdmin)
admin.site.register(core.models.Sample, SampleAdmin)
Expand All @@ -191,11 +196,11 @@ class MetadataVisualizationAdmin(admin.ModelAdmin):
admin.site.register(core.models.PublicDatabaseFields, PublicDatabaseFieldsAdmin)
admin.site.register(core.models.PublicDatabaseValues, PublicDatabaseValuesAdmin)
admin.site.register(core.models.MetadataVisualization, MetadataVisualizationAdmin)
admin.site.register(core.models.BioinfoAnalysisField, BioinfoAnalysisFielddAdmin)
admin.site.register(core.models.BioinfoAnalysisValue, BioinfoAnalysisValueAdmin)
admin.site.register(core.models.MetadataValues, MetadataValuesAdmin)
admin.site.register(core.models.Classification, ClassificationAdmin)
admin.site.register(core.models.TemporalSampleStorage, TemporalSampleStorageAdmin)
admin.site.register(core.models.Error, ErrorAdmin)
admin.site.register(core.models.DateUpdateState, DateUpdateStateAdmin)
# TODO: Remove the line below when we remove lineage things
admin.site.register(core.models.LineageInfo, LineageInfoAdmin)
admin.site.register(core.models.ErrorName, ErrorNameAdmin)
admin.site.register(core.models.SampleStateHistory, SampleStateHistoryAdmin)
admin.site.register(core.models.OrganismAnnotation, OrganismAnnotationAdmin)
14 changes: 4 additions & 10 deletions core/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import core.models


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


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


Expand All @@ -29,12 +29,6 @@ class Meta:
fields = "__all__"


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


class CreateVariantInSampleSerializer(serializers.ModelSerializer):
class Meta:
model = core.models.VariantInSample
Expand Down
4 changes: 2 additions & 2 deletions core/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
urlpatterns = [
path(
"createBioinfoData",
core.api.views.create_bioinfo_metadata,
name="create_bioinfo_data",
core.api.views.create_metadata_value,
name="create_metadata_value",
),
path(
"createSampleData",
Expand Down
90 changes: 0 additions & 90 deletions core/api/utils/bioinfo_metadata.py

This file was deleted.

Loading
Loading