diff --git a/genotype_api/constants.py b/genotype_api/constants.py index 8b2fca7..78d1325 100644 --- a/genotype_api/constants.py +++ b/genotype_api/constants.py @@ -1,9 +1,13 @@ """Constants used over the package""" -from enum import Enum +from enum import Enum, StrEnum from pydantic import BaseModel +class FileExtension(StrEnum): + VCF: str = ".vcf" + + class Types(str, Enum): GENOTYPE = "genotype" SEQUENCE = "sequence" diff --git a/genotype_api/services/analysis_service/analysis_service.py b/genotype_api/services/analysis_service/analysis_service.py index a6992bd..41753ed 100644 --- a/genotype_api/services/analysis_service/analysis_service.py +++ b/genotype_api/services/analysis_service/analysis_service.py @@ -5,7 +5,7 @@ from fastapi import UploadFile from sqlmodel import Session -from genotype_api.constants import Types +from genotype_api.constants import Types, FileExtension from genotype_api.database.crud.create import create_analyses_samples, create_analysis from genotype_api.database.crud.read import ( get_analysis_by_id, @@ -48,7 +48,7 @@ def get_upload_sequence_analyses(self, file: UploadFile) -> list[AnalysisRespons """ Reading VCF file, creating and uploading sequence analyses and sample objects to the database. """ - file_name: Path = check_file(file_path=file.filename, extension=".vcf") + file_name: Path = check_file(file_path=file.filename, extension=FileExtension.VCF) content = file.file.read().decode("utf-8") sequence_analysis = SequenceAnalysis(vcf_file=content, source=str(file_name)) analyses: list[Analysis] = list(sequence_analysis.generate_analyses())