diff --git a/relecov_core/api/utils/samples.py b/relecov_core/api/utils/samples.py index b1811c9..6444b1d 100644 --- a/relecov_core/api/utils/samples.py +++ b/relecov_core/api/utils/samples.py @@ -3,12 +3,17 @@ import relecov_core.models import relecov_core.utils.samples + 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(): + if not relecov_core.models.SampleState.objects.filter( + state__exact="Defined" + ).exists(): return {"ERROR": ERROR_INTIAL_SETTINGS_NOT_DEFINED} s_data["state"] = ( - relecov_core.models.SampleState.objects.filter(state__exact="Defined").last().get_state_id() + relecov_core.models.SampleState.objects.filter(state__exact="Defined") + .last() + .get_state_id() ) if "biosample_accession_ENA" not in s_data: s_data["biosample_accession_ENA"] = None @@ -49,15 +54,21 @@ def split_sample_data(data): # add user and state to sample data split_data["sample"]["state"] = ( - relecov_core.models.SampleState.objects.filter(state__exact="Defined").last().get_state_id() + relecov_core.models.SampleState.objects.filter(state__exact="Defined") + .last() + .get_state_id() ) - split_data["sample"]["user"] = relecov_core.utils.samples.get_user_id_from_collecting_institution( - split_data["sample"]["collecting_institution"] + split_data["sample"]["user"] = ( + relecov_core.utils.samples.get_user_id_from_collecting_institution( + split_data["sample"]["collecting_institution"] + ) ) if relecov_core.models.Sample.objects.all().exists(): - last_unique_value = relecov_core.models.Sample.objects.all().last().get_unique_id() - split_data["sample"]["sample_unique_id"] = relecov_core.utils.samples.increase_unique_value( - last_unique_value + last_unique_value = ( + relecov_core.models.Sample.objects.all().last().get_unique_id() + ) + split_data["sample"]["sample_unique_id"] = ( + relecov_core.utils.samples.increase_unique_value(last_unique_value) ) else: split_data["sample"]["sample_unique_id"] = "AAA-0001" diff --git a/relecov_core/api/utils/variants.py b/relecov_core/api/utils/variants.py index b6eefbd..2d16f3c 100644 --- a/relecov_core/api/utils/variants.py +++ b/relecov_core/api/utils/variants.py @@ -14,10 +14,13 @@ ERROR_UNABLE_TO_STORE_IN_DATABASE, ) + def create_or_get_filter_obj(filter_value): """Return the filter instance or create if not exists""" if relecov_core.models.Filter.objects.filter(filter__iexact=filter_value).exists(): - return relecov_core.models.Filter.objects.filter(filter__iexact=filter_value).last() + return relecov_core.models.Filter.objects.filter( + filter__iexact=filter_value + ).last() filter_serializer = CreateFilterSerializer(data={"filter": filter_value}) if filter_serializer.is_valid(): filter_obj = filter_serializer.save() @@ -28,7 +31,9 @@ def create_or_get_filter_obj(filter_value): def create_or_get_effect_obj(effect_value): """Return the effect instance or create if not exists""" if relecov_core.models.Effect.objects.filter(effect__iexact=effect_value).exists(): - return relecov_core.models.Effect.objects.filter(effect__iexact=effect_value).last() + return relecov_core.models.Effect.objects.filter( + effect__iexact=effect_value + ).last() effect_serializer = CreateEffectSerializer(data={"effect": effect_value}) if effect_serializer.is_valid(): effect_obj = effect_serializer.save() @@ -90,9 +95,9 @@ def get_variant_id(data): def get_variant_analysis_defined(s_obj): - return relecov_core.models.VariantInSample.objects.filter(sampleID_id=s_obj).values_list( - "analysis_date", flat=True - ) + return relecov_core.models.VariantInSample.objects.filter( + sampleID_id=s_obj + ).values_list("analysis_date", flat=True) def get_required_variant_ann_id(data): diff --git a/relecov_core/utils/plotly_graphics.py b/relecov_core/utils/plotly_graphics.py index a8223e2..71a9171 100644 --- a/relecov_core/utils/plotly_graphics.py +++ b/relecov_core/utils/plotly_graphics.py @@ -109,6 +109,7 @@ def gauge_graphic(data): plot_div = plot(graph, output_type="div", config={"displaylogo": False}) return plot_div + # FIXME: This function es never called within the platform def bullet_graphic(value, title): point = str(value)