Skip to content

Commit

Permalink
- fixed bug in serializer of InferenceExperiments
Browse files Browse the repository at this point in the history
- fixed bug in the models of StatisticalValidation sources
  • Loading branch information
GonzzaG committed Sep 18, 2024
1 parent a2dc9bf commit cff4aa8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
15 changes: 8 additions & 7 deletions src/inferences/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
from django.db.models import Q, OuterRef
from rest_framework import serializers
from rest_framework.generics import get_object_or_404

from api_service.serializers import ExperimentSourceSerializer
from feature_selection.fs_algorithms import FitnessFunction
from feature_selection.models import ClusterLabelsSet, ClusterLabel, PredictionRangeLabelsSet, PredictionRangeLabel
from .models import InferenceExperiment, SampleAndClusterPrediction, SampleAndTimePrediction
from api_service.models import ExperimentClinicalSource, ExperimentSource


def generate_prediction_condition(predicted_time: Union[float, OuterRef]) -> Q:
Expand All @@ -20,15 +21,15 @@ class InferenceExperimentSerializer(serializers.ModelSerializer):
model = serializers.SerializerMethodField(method_name='get_model')
trained_model = serializers.PrimaryKeyRelatedField(read_only=True)

clinical_source = ExperimentClinicalSource()
mrna_source = ExperimentSource()
mirna_source = ExperimentSource()
cna_source = ExperimentSource()
methylation_source = ExperimentSource()
clinical_source = ExperimentSourceSerializer()
mrna_source = ExperimentSourceSerializer()
mirna_source = ExperimentSourceSerializer()
cna_source = ExperimentSourceSerializer()
methylation_source = ExperimentSourceSerializer()

class Meta:
model = InferenceExperiment
fields = ['id', 'name', 'description', 'created', 'model', 'state', 'trained_model', 'clinical_source_id',
fields = ['id', 'name', 'description', 'created', 'model', 'state', 'trained_model',
'clinical_source', 'mrna_source', 'mirna_source', 'cna_source', 'methylation_source']

@staticmethod
Expand Down
8 changes: 4 additions & 4 deletions src/statistical_properties/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ class StatisticalValidation(models.Model):
related_name='statistical_validations', null=True, blank=True)

# Sources
mrna_source_result = models.OneToOneField('StatisticalValidationSourceResult', on_delete=models.CASCADE, null=True,
mrna_source_result = models.OneToOneField('api_service.ExperimentClinicalSource', on_delete=models.CASCADE, null=True,
blank=True, related_name='statistical_validations_as_mrna')
mirna_source_result = models.OneToOneField(StatisticalValidationSourceResult, on_delete=models.CASCADE, null=True,
mirna_source_result = models.OneToOneField('api_service.ExperimentClinicalSource', on_delete=models.CASCADE, null=True,
blank=True, related_name='statistical_validations_as_mirna')
cna_source_result = models.OneToOneField(StatisticalValidationSourceResult, on_delete=models.CASCADE, null=True,
cna_source_result = models.OneToOneField('api_service.ExperimentClinicalSource', on_delete=models.CASCADE, null=True,
blank=True, related_name='statistical_validations_as_cna')
methylation_source_result = models.OneToOneField('StatisticalValidationSourceResult', on_delete=models.CASCADE,
methylation_source_result = models.OneToOneField('api_service.ExperimentClinicalSource', on_delete=models.CASCADE,
null=True, blank=True,
related_name='statistical_validations_as_methylation')
# Number of attempts to prevent a buggy statistical validation running forever
Expand Down
10 changes: 5 additions & 5 deletions src/statistical_properties/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ class StatisticalValidationSimpleSerializer(serializers.ModelSerializer):
fitness_function = serializers.SerializerMethodField(method_name='get_fitness_function')
trained_model = serializers.PrimaryKeyRelatedField(read_only=True)

clinical_source = ExperimentClinicalSource()
mrna_source_result = ExperimentSource()
mirna_source_result = ExperimentSource()
cna_source_result = ExperimentSource()
methylation_source_result = ExperimentSource()
clinical_source = ExperimentClinicalSourceSerializer()
mrna_source_result = ExperimentSourceSerializer()
mirna_source_result = ExperimentSourceSerializer()
cna_source_result = ExperimentSourceSerializer()
methylation_source_result = ExperimentSourceSerializer()

class Meta:
model = StatisticalValidation
Expand Down

0 comments on commit cff4aa8

Please sign in to comment.